babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param overrideAspectRatio Override the aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, overrideAspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. }
  12732. }
  12733. }
  12734. declare module "babylonjs/Materials/Textures/rawTexture" {
  12735. import { Scene } from "babylonjs/scene";
  12736. import { Texture } from "babylonjs/Materials/Textures/texture";
  12737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12738. /**
  12739. * Raw texture can help creating a texture directly from an array of data.
  12740. * This can be super useful if you either get the data from an uncompressed source or
  12741. * if you wish to create your texture pixel by pixel.
  12742. */
  12743. export class RawTexture extends Texture {
  12744. /**
  12745. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12746. */
  12747. format: number;
  12748. private _engine;
  12749. /**
  12750. * Instantiates a new RawTexture.
  12751. * Raw texture can help creating a texture directly from an array of data.
  12752. * This can be super useful if you either get the data from an uncompressed source or
  12753. * if you wish to create your texture pixel by pixel.
  12754. * @param data define the array of data to use to create the texture
  12755. * @param width define the width of the texture
  12756. * @param height define the height of the texture
  12757. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12758. * @param scene define the scene the texture belongs to
  12759. * @param generateMipMaps define whether mip maps should be generated or not
  12760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12762. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12763. */
  12764. constructor(data: ArrayBufferView, width: number, height: number,
  12765. /**
  12766. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12767. */
  12768. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12769. /**
  12770. * Updates the texture underlying data.
  12771. * @param data Define the new data of the texture
  12772. */
  12773. update(data: ArrayBufferView): void;
  12774. /**
  12775. * Creates a luminance texture from some data.
  12776. * @param data Define the texture data
  12777. * @param width Define the width of the texture
  12778. * @param height Define the height of the texture
  12779. * @param scene Define the scene the texture belongs to
  12780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12783. * @returns the luminance texture
  12784. */
  12785. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12786. /**
  12787. * Creates a luminance alpha texture from some data.
  12788. * @param data Define the texture data
  12789. * @param width Define the width of the texture
  12790. * @param height Define the height of the texture
  12791. * @param scene Define the scene the texture belongs to
  12792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @returns the luminance alpha texture
  12796. */
  12797. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12798. /**
  12799. * Creates an alpha texture from some data.
  12800. * @param data Define the texture data
  12801. * @param width Define the width of the texture
  12802. * @param height Define the height of the texture
  12803. * @param scene Define the scene the texture belongs to
  12804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12807. * @returns the alpha texture
  12808. */
  12809. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12810. /**
  12811. * Creates a RGB texture from some data.
  12812. * @param data Define the texture data
  12813. * @param width Define the width of the texture
  12814. * @param height Define the height of the texture
  12815. * @param scene Define the scene the texture belongs to
  12816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12820. * @returns the RGB alpha texture
  12821. */
  12822. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12823. /**
  12824. * Creates a RGBA texture from some data.
  12825. * @param data Define the texture data
  12826. * @param width Define the width of the texture
  12827. * @param height Define the height of the texture
  12828. * @param scene Define the scene the texture belongs to
  12829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. * @returns the RGBA texture
  12834. */
  12835. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12836. /**
  12837. * Creates a R texture from some data.
  12838. * @param data Define the texture data
  12839. * @param width Define the width of the texture
  12840. * @param height Define the height of the texture
  12841. * @param scene Define the scene the texture belongs to
  12842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12846. * @returns the R texture
  12847. */
  12848. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12849. }
  12850. }
  12851. declare module "babylonjs/Maths/math.size" {
  12852. /**
  12853. * Interface for the size containing width and height
  12854. */
  12855. export interface ISize {
  12856. /**
  12857. * Width
  12858. */
  12859. width: number;
  12860. /**
  12861. * Heighht
  12862. */
  12863. height: number;
  12864. }
  12865. /**
  12866. * Size containing widht and height
  12867. */
  12868. export class Size implements ISize {
  12869. /**
  12870. * Width
  12871. */
  12872. width: number;
  12873. /**
  12874. * Height
  12875. */
  12876. height: number;
  12877. /**
  12878. * Creates a Size object from the given width and height (floats).
  12879. * @param width width of the new size
  12880. * @param height height of the new size
  12881. */
  12882. constructor(width: number, height: number);
  12883. /**
  12884. * Returns a string with the Size width and height
  12885. * @returns a string with the Size width and height
  12886. */
  12887. toString(): string;
  12888. /**
  12889. * "Size"
  12890. * @returns the string "Size"
  12891. */
  12892. getClassName(): string;
  12893. /**
  12894. * Returns the Size hash code.
  12895. * @returns a hash code for a unique width and height
  12896. */
  12897. getHashCode(): number;
  12898. /**
  12899. * Updates the current size from the given one.
  12900. * @param src the given size
  12901. */
  12902. copyFrom(src: Size): void;
  12903. /**
  12904. * Updates in place the current Size from the given floats.
  12905. * @param width width of the new size
  12906. * @param height height of the new size
  12907. * @returns the updated Size.
  12908. */
  12909. copyFromFloats(width: number, height: number): Size;
  12910. /**
  12911. * Updates in place the current Size from the given floats.
  12912. * @param width width to set
  12913. * @param height height to set
  12914. * @returns the updated Size.
  12915. */
  12916. set(width: number, height: number): Size;
  12917. /**
  12918. * Multiplies the width and height by numbers
  12919. * @param w factor to multiple the width by
  12920. * @param h factor to multiple the height by
  12921. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12922. */
  12923. multiplyByFloats(w: number, h: number): Size;
  12924. /**
  12925. * Clones the size
  12926. * @returns a new Size copied from the given one.
  12927. */
  12928. clone(): Size;
  12929. /**
  12930. * True if the current Size and the given one width and height are strictly equal.
  12931. * @param other the other size to compare against
  12932. * @returns True if the current Size and the given one width and height are strictly equal.
  12933. */
  12934. equals(other: Size): boolean;
  12935. /**
  12936. * The surface of the Size : width * height (float).
  12937. */
  12938. readonly surface: number;
  12939. /**
  12940. * Create a new size of zero
  12941. * @returns a new Size set to (0.0, 0.0)
  12942. */
  12943. static Zero(): Size;
  12944. /**
  12945. * Sums the width and height of two sizes
  12946. * @param otherSize size to add to this size
  12947. * @returns a new Size set as the addition result of the current Size and the given one.
  12948. */
  12949. add(otherSize: Size): Size;
  12950. /**
  12951. * Subtracts the width and height of two
  12952. * @param otherSize size to subtract to this size
  12953. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12954. */
  12955. subtract(otherSize: Size): Size;
  12956. /**
  12957. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12958. * @param start starting size to lerp between
  12959. * @param end end size to lerp between
  12960. * @param amount amount to lerp between the start and end values
  12961. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12962. */
  12963. static Lerp(start: Size, end: Size, amount: number): Size;
  12964. }
  12965. }
  12966. declare module "babylonjs/Animations/runtimeAnimation" {
  12967. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12968. import { Animatable } from "babylonjs/Animations/animatable";
  12969. import { Scene } from "babylonjs/scene";
  12970. /**
  12971. * Defines a runtime animation
  12972. */
  12973. export class RuntimeAnimation {
  12974. private _events;
  12975. /**
  12976. * The current frame of the runtime animation
  12977. */
  12978. private _currentFrame;
  12979. /**
  12980. * The animation used by the runtime animation
  12981. */
  12982. private _animation;
  12983. /**
  12984. * The target of the runtime animation
  12985. */
  12986. private _target;
  12987. /**
  12988. * The initiating animatable
  12989. */
  12990. private _host;
  12991. /**
  12992. * The original value of the runtime animation
  12993. */
  12994. private _originalValue;
  12995. /**
  12996. * The original blend value of the runtime animation
  12997. */
  12998. private _originalBlendValue;
  12999. /**
  13000. * The offsets cache of the runtime animation
  13001. */
  13002. private _offsetsCache;
  13003. /**
  13004. * The high limits cache of the runtime animation
  13005. */
  13006. private _highLimitsCache;
  13007. /**
  13008. * Specifies if the runtime animation has been stopped
  13009. */
  13010. private _stopped;
  13011. /**
  13012. * The blending factor of the runtime animation
  13013. */
  13014. private _blendingFactor;
  13015. /**
  13016. * The BabylonJS scene
  13017. */
  13018. private _scene;
  13019. /**
  13020. * The current value of the runtime animation
  13021. */
  13022. private _currentValue;
  13023. /** @hidden */
  13024. _animationState: _IAnimationState;
  13025. /**
  13026. * The active target of the runtime animation
  13027. */
  13028. private _activeTargets;
  13029. private _currentActiveTarget;
  13030. private _directTarget;
  13031. /**
  13032. * The target path of the runtime animation
  13033. */
  13034. private _targetPath;
  13035. /**
  13036. * The weight of the runtime animation
  13037. */
  13038. private _weight;
  13039. /**
  13040. * The ratio offset of the runtime animation
  13041. */
  13042. private _ratioOffset;
  13043. /**
  13044. * The previous delay of the runtime animation
  13045. */
  13046. private _previousDelay;
  13047. /**
  13048. * The previous ratio of the runtime animation
  13049. */
  13050. private _previousRatio;
  13051. private _enableBlending;
  13052. private _keys;
  13053. private _minFrame;
  13054. private _maxFrame;
  13055. private _minValue;
  13056. private _maxValue;
  13057. private _targetIsArray;
  13058. /**
  13059. * Gets the current frame of the runtime animation
  13060. */
  13061. readonly currentFrame: number;
  13062. /**
  13063. * Gets the weight of the runtime animation
  13064. */
  13065. readonly weight: number;
  13066. /**
  13067. * Gets the current value of the runtime animation
  13068. */
  13069. readonly currentValue: any;
  13070. /**
  13071. * Gets the target path of the runtime animation
  13072. */
  13073. readonly targetPath: string;
  13074. /**
  13075. * Gets the actual target of the runtime animation
  13076. */
  13077. readonly target: any;
  13078. /** @hidden */
  13079. _onLoop: () => void;
  13080. /**
  13081. * Create a new RuntimeAnimation object
  13082. * @param target defines the target of the animation
  13083. * @param animation defines the source animation object
  13084. * @param scene defines the hosting scene
  13085. * @param host defines the initiating Animatable
  13086. */
  13087. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13088. private _preparePath;
  13089. /**
  13090. * Gets the animation from the runtime animation
  13091. */
  13092. readonly animation: Animation;
  13093. /**
  13094. * Resets the runtime animation to the beginning
  13095. * @param restoreOriginal defines whether to restore the target property to the original value
  13096. */
  13097. reset(restoreOriginal?: boolean): void;
  13098. /**
  13099. * Specifies if the runtime animation is stopped
  13100. * @returns Boolean specifying if the runtime animation is stopped
  13101. */
  13102. isStopped(): boolean;
  13103. /**
  13104. * Disposes of the runtime animation
  13105. */
  13106. dispose(): void;
  13107. /**
  13108. * Apply the interpolated value to the target
  13109. * @param currentValue defines the value computed by the animation
  13110. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13111. */
  13112. setValue(currentValue: any, weight: number): void;
  13113. private _getOriginalValues;
  13114. private _setValue;
  13115. /**
  13116. * Gets the loop pmode of the runtime animation
  13117. * @returns Loop Mode
  13118. */
  13119. private _getCorrectLoopMode;
  13120. /**
  13121. * Move the current animation to a given frame
  13122. * @param frame defines the frame to move to
  13123. */
  13124. goToFrame(frame: number): void;
  13125. /**
  13126. * @hidden Internal use only
  13127. */
  13128. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13129. /**
  13130. * Execute the current animation
  13131. * @param delay defines the delay to add to the current frame
  13132. * @param from defines the lower bound of the animation range
  13133. * @param to defines the upper bound of the animation range
  13134. * @param loop defines if the current animation must loop
  13135. * @param speedRatio defines the current speed ratio
  13136. * @param weight defines the weight of the animation (default is -1 so no weight)
  13137. * @param onLoop optional callback called when animation loops
  13138. * @returns a boolean indicating if the animation is running
  13139. */
  13140. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13141. }
  13142. }
  13143. declare module "babylonjs/Animations/animatable" {
  13144. import { Animation } from "babylonjs/Animations/animation";
  13145. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13146. import { Nullable } from "babylonjs/types";
  13147. import { Observable } from "babylonjs/Misc/observable";
  13148. import { Scene } from "babylonjs/scene";
  13149. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13150. import { Node } from "babylonjs/node";
  13151. /**
  13152. * Class used to store an actual running animation
  13153. */
  13154. export class Animatable {
  13155. /** defines the target object */
  13156. target: any;
  13157. /** defines the starting frame number (default is 0) */
  13158. fromFrame: number;
  13159. /** defines the ending frame number (default is 100) */
  13160. toFrame: number;
  13161. /** defines if the animation must loop (default is false) */
  13162. loopAnimation: boolean;
  13163. /** defines a callback to call when animation ends if it is not looping */
  13164. onAnimationEnd?: (() => void) | null | undefined;
  13165. /** defines a callback to call when animation loops */
  13166. onAnimationLoop?: (() => void) | null | undefined;
  13167. private _localDelayOffset;
  13168. private _pausedDelay;
  13169. private _runtimeAnimations;
  13170. private _paused;
  13171. private _scene;
  13172. private _speedRatio;
  13173. private _weight;
  13174. private _syncRoot;
  13175. /**
  13176. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13177. * This will only apply for non looping animation (default is true)
  13178. */
  13179. disposeOnEnd: boolean;
  13180. /**
  13181. * Gets a boolean indicating if the animation has started
  13182. */
  13183. animationStarted: boolean;
  13184. /**
  13185. * Observer raised when the animation ends
  13186. */
  13187. onAnimationEndObservable: Observable<Animatable>;
  13188. /**
  13189. * Observer raised when the animation loops
  13190. */
  13191. onAnimationLoopObservable: Observable<Animatable>;
  13192. /**
  13193. * Gets the root Animatable used to synchronize and normalize animations
  13194. */
  13195. readonly syncRoot: Nullable<Animatable>;
  13196. /**
  13197. * Gets the current frame of the first RuntimeAnimation
  13198. * Used to synchronize Animatables
  13199. */
  13200. readonly masterFrame: number;
  13201. /**
  13202. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13203. */
  13204. weight: number;
  13205. /**
  13206. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13207. */
  13208. speedRatio: number;
  13209. /**
  13210. * Creates a new Animatable
  13211. * @param scene defines the hosting scene
  13212. * @param target defines the target object
  13213. * @param fromFrame defines the starting frame number (default is 0)
  13214. * @param toFrame defines the ending frame number (default is 100)
  13215. * @param loopAnimation defines if the animation must loop (default is false)
  13216. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13217. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13218. * @param animations defines a group of animation to add to the new Animatable
  13219. * @param onAnimationLoop defines a callback to call when animation loops
  13220. */
  13221. constructor(scene: Scene,
  13222. /** defines the target object */
  13223. target: any,
  13224. /** defines the starting frame number (default is 0) */
  13225. fromFrame?: number,
  13226. /** defines the ending frame number (default is 100) */
  13227. toFrame?: number,
  13228. /** defines if the animation must loop (default is false) */
  13229. loopAnimation?: boolean, speedRatio?: number,
  13230. /** defines a callback to call when animation ends if it is not looping */
  13231. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13232. /** defines a callback to call when animation loops */
  13233. onAnimationLoop?: (() => void) | null | undefined);
  13234. /**
  13235. * Synchronize and normalize current Animatable with a source Animatable
  13236. * This is useful when using animation weights and when animations are not of the same length
  13237. * @param root defines the root Animatable to synchronize with
  13238. * @returns the current Animatable
  13239. */
  13240. syncWith(root: Animatable): Animatable;
  13241. /**
  13242. * Gets the list of runtime animations
  13243. * @returns an array of RuntimeAnimation
  13244. */
  13245. getAnimations(): RuntimeAnimation[];
  13246. /**
  13247. * Adds more animations to the current animatable
  13248. * @param target defines the target of the animations
  13249. * @param animations defines the new animations to add
  13250. */
  13251. appendAnimations(target: any, animations: Animation[]): void;
  13252. /**
  13253. * Gets the source animation for a specific property
  13254. * @param property defines the propertyu to look for
  13255. * @returns null or the source animation for the given property
  13256. */
  13257. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13258. /**
  13259. * Gets the runtime animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the runtime animation for the given property
  13262. */
  13263. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13264. /**
  13265. * Resets the animatable to its original state
  13266. */
  13267. reset(): void;
  13268. /**
  13269. * Allows the animatable to blend with current running animations
  13270. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13271. * @param blendingSpeed defines the blending speed to use
  13272. */
  13273. enableBlending(blendingSpeed: number): void;
  13274. /**
  13275. * Disable animation blending
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. */
  13278. disableBlending(): void;
  13279. /**
  13280. * Jump directly to a given frame
  13281. * @param frame defines the frame to jump to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * Pause the animation
  13286. */
  13287. pause(): void;
  13288. /**
  13289. * Restart the animation
  13290. */
  13291. restart(): void;
  13292. private _raiseOnAnimationEnd;
  13293. /**
  13294. * Stop and delete the current animation
  13295. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13296. * @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)
  13297. */
  13298. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13299. /**
  13300. * Wait asynchronously for the animation to end
  13301. * @returns a promise which will be fullfilled when the animation ends
  13302. */
  13303. waitAsync(): Promise<Animatable>;
  13304. /** @hidden */
  13305. _animate(delay: number): boolean;
  13306. }
  13307. module "babylonjs/scene" {
  13308. interface Scene {
  13309. /** @hidden */
  13310. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13311. /** @hidden */
  13312. _processLateAnimationBindingsForMatrices(holder: {
  13313. totalWeight: number;
  13314. animations: RuntimeAnimation[];
  13315. originalValue: Matrix;
  13316. }): any;
  13317. /** @hidden */
  13318. _processLateAnimationBindingsForQuaternions(holder: {
  13319. totalWeight: number;
  13320. animations: RuntimeAnimation[];
  13321. originalValue: Quaternion;
  13322. }, refQuaternion: Quaternion): Quaternion;
  13323. /** @hidden */
  13324. _processLateAnimationBindings(): void;
  13325. /**
  13326. * Will start the animation sequence of a given target
  13327. * @param target defines the target
  13328. * @param from defines from which frame should animation start
  13329. * @param to defines until which frame should animation run.
  13330. * @param weight defines the weight to apply to the animation (1.0 by default)
  13331. * @param loop defines if the animation loops
  13332. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13333. * @param onAnimationEnd defines the function to be executed when the animation ends
  13334. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13335. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13336. * @param onAnimationLoop defines the callback to call when an animation loops
  13337. * @returns the animatable object created for this animation
  13338. */
  13339. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13340. /**
  13341. * Will start the animation sequence of a given target
  13342. * @param target defines the target
  13343. * @param from defines from which frame should animation start
  13344. * @param to defines until which frame should animation run.
  13345. * @param loop defines if the animation loops
  13346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13347. * @param onAnimationEnd defines the function to be executed when the animation ends
  13348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13349. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13350. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13351. * @param onAnimationLoop defines the callback to call when an animation loops
  13352. * @returns the animatable object created for this animation
  13353. */
  13354. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13355. /**
  13356. * Will start the animation sequence of a given target and its hierarchy
  13357. * @param target defines the target
  13358. * @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.
  13359. * @param from defines from which frame should animation start
  13360. * @param to defines until which frame should animation run.
  13361. * @param loop defines if the animation loops
  13362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13363. * @param onAnimationEnd defines the function to be executed when the animation ends
  13364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13365. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13366. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13367. * @param onAnimationLoop defines the callback to call when an animation loops
  13368. * @returns the list of created animatables
  13369. */
  13370. 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[];
  13371. /**
  13372. * Begin a new animation on a given node
  13373. * @param target defines the target where the animation will take place
  13374. * @param animations defines the list of animations to start
  13375. * @param from defines the initial value
  13376. * @param to defines the final value
  13377. * @param loop defines if you want animation to loop (off by default)
  13378. * @param speedRatio defines the speed ratio to apply to all animations
  13379. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13380. * @param onAnimationLoop defines the callback to call when an animation loops
  13381. * @returns the list of created animatables
  13382. */
  13383. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13384. /**
  13385. * Begin a new animation on a given node and its hierarchy
  13386. * @param target defines the root node where the animation will take place
  13387. * @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.
  13388. * @param animations defines the list of animations to start
  13389. * @param from defines the initial value
  13390. * @param to defines the final value
  13391. * @param loop defines if you want animation to loop (off by default)
  13392. * @param speedRatio defines the speed ratio to apply to all animations
  13393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13394. * @param onAnimationLoop defines the callback to call when an animation loops
  13395. * @returns the list of animatables created for all nodes
  13396. */
  13397. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13398. /**
  13399. * Gets the animatable associated with a specific target
  13400. * @param target defines the target of the animatable
  13401. * @returns the required animatable if found
  13402. */
  13403. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13404. /**
  13405. * Gets all animatables associated with a given target
  13406. * @param target defines the target to look animatables for
  13407. * @returns an array of Animatables
  13408. */
  13409. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13410. /**
  13411. * Stops and removes all animations that have been applied to the scene
  13412. */
  13413. stopAllAnimations(): void;
  13414. /**
  13415. * Gets the current delta time used by animation engine
  13416. */
  13417. deltaTime: number;
  13418. }
  13419. }
  13420. module "babylonjs/Bones/bone" {
  13421. interface Bone {
  13422. /**
  13423. * Copy an animation range from another bone
  13424. * @param source defines the source bone
  13425. * @param rangeName defines the range name to copy
  13426. * @param frameOffset defines the frame offset
  13427. * @param rescaleAsRequired defines if rescaling must be applied if required
  13428. * @param skelDimensionsRatio defines the scaling ratio
  13429. * @returns true if operation was successful
  13430. */
  13431. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13432. }
  13433. }
  13434. }
  13435. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13436. /**
  13437. * Class used to override all child animations of a given target
  13438. */
  13439. export class AnimationPropertiesOverride {
  13440. /**
  13441. * Gets or sets a value indicating if animation blending must be used
  13442. */
  13443. enableBlending: boolean;
  13444. /**
  13445. * Gets or sets the blending speed to use when enableBlending is true
  13446. */
  13447. blendingSpeed: number;
  13448. /**
  13449. * Gets or sets the default loop mode to use
  13450. */
  13451. loopMode: number;
  13452. }
  13453. }
  13454. declare module "babylonjs/Bones/skeleton" {
  13455. import { Bone } from "babylonjs/Bones/bone";
  13456. import { Observable } from "babylonjs/Misc/observable";
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Scene } from "babylonjs/scene";
  13459. import { Nullable } from "babylonjs/types";
  13460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13461. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13462. import { Animatable } from "babylonjs/Animations/animatable";
  13463. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13464. import { Animation } from "babylonjs/Animations/animation";
  13465. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13466. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13468. /**
  13469. * Class used to handle skinning animations
  13470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13471. */
  13472. export class Skeleton implements IAnimatable {
  13473. /** defines the skeleton name */
  13474. name: string;
  13475. /** defines the skeleton Id */
  13476. id: string;
  13477. /**
  13478. * Defines the list of child bones
  13479. */
  13480. bones: Bone[];
  13481. /**
  13482. * Defines an estimate of the dimension of the skeleton at rest
  13483. */
  13484. dimensionsAtRest: Vector3;
  13485. /**
  13486. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13487. */
  13488. needInitialSkinMatrix: boolean;
  13489. /**
  13490. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13491. */
  13492. overrideMesh: Nullable<AbstractMesh>;
  13493. /**
  13494. * Gets the list of animations attached to this skeleton
  13495. */
  13496. animations: Array<Animation>;
  13497. private _scene;
  13498. private _isDirty;
  13499. private _transformMatrices;
  13500. private _transformMatrixTexture;
  13501. private _meshesWithPoseMatrix;
  13502. private _animatables;
  13503. private _identity;
  13504. private _synchronizedWithMesh;
  13505. private _ranges;
  13506. private _lastAbsoluteTransformsUpdateId;
  13507. private _canUseTextureForBones;
  13508. private _uniqueId;
  13509. /** @hidden */
  13510. _numBonesWithLinkedTransformNode: number;
  13511. /** @hidden */
  13512. _hasWaitingData: Nullable<boolean>;
  13513. /**
  13514. * Specifies if the skeleton should be serialized
  13515. */
  13516. doNotSerialize: boolean;
  13517. private _useTextureToStoreBoneMatrices;
  13518. /**
  13519. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13520. * Please note that this option is not available if the hardware does not support it
  13521. */
  13522. useTextureToStoreBoneMatrices: boolean;
  13523. private _animationPropertiesOverride;
  13524. /**
  13525. * Gets or sets the animation properties override
  13526. */
  13527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13528. /**
  13529. * List of inspectable custom properties (used by the Inspector)
  13530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13531. */
  13532. inspectableCustomProperties: IInspectable[];
  13533. /**
  13534. * An observable triggered before computing the skeleton's matrices
  13535. */
  13536. onBeforeComputeObservable: Observable<Skeleton>;
  13537. /**
  13538. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13539. */
  13540. readonly isUsingTextureForMatrices: boolean;
  13541. /**
  13542. * Gets the unique ID of this skeleton
  13543. */
  13544. readonly uniqueId: number;
  13545. /**
  13546. * Creates a new skeleton
  13547. * @param name defines the skeleton name
  13548. * @param id defines the skeleton Id
  13549. * @param scene defines the hosting scene
  13550. */
  13551. constructor(
  13552. /** defines the skeleton name */
  13553. name: string,
  13554. /** defines the skeleton Id */
  13555. id: string, scene: Scene);
  13556. /**
  13557. * Gets the current object class name.
  13558. * @return the class name
  13559. */
  13560. getClassName(): string;
  13561. /**
  13562. * Returns an array containing the root bones
  13563. * @returns an array containing the root bones
  13564. */
  13565. getChildren(): Array<Bone>;
  13566. /**
  13567. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13568. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13569. * @returns a Float32Array containing matrices data
  13570. */
  13571. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13572. /**
  13573. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13574. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13575. * @returns a raw texture containing the data
  13576. */
  13577. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13578. /**
  13579. * Gets the current hosting scene
  13580. * @returns a scene object
  13581. */
  13582. getScene(): Scene;
  13583. /**
  13584. * Gets a string representing the current skeleton data
  13585. * @param fullDetails defines a boolean indicating if we want a verbose version
  13586. * @returns a string representing the current skeleton data
  13587. */
  13588. toString(fullDetails?: boolean): string;
  13589. /**
  13590. * Get bone's index searching by name
  13591. * @param name defines bone's name to search for
  13592. * @return the indice of the bone. Returns -1 if not found
  13593. */
  13594. getBoneIndexByName(name: string): number;
  13595. /**
  13596. * Creater a new animation range
  13597. * @param name defines the name of the range
  13598. * @param from defines the start key
  13599. * @param to defines the end key
  13600. */
  13601. createAnimationRange(name: string, from: number, to: number): void;
  13602. /**
  13603. * Delete a specific animation range
  13604. * @param name defines the name of the range
  13605. * @param deleteFrames defines if frames must be removed as well
  13606. */
  13607. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13608. /**
  13609. * Gets a specific animation range
  13610. * @param name defines the name of the range to look for
  13611. * @returns the requested animation range or null if not found
  13612. */
  13613. getAnimationRange(name: string): Nullable<AnimationRange>;
  13614. /**
  13615. * Gets the list of all animation ranges defined on this skeleton
  13616. * @returns an array
  13617. */
  13618. getAnimationRanges(): Nullable<AnimationRange>[];
  13619. /**
  13620. * Copy animation range from a source skeleton.
  13621. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13622. * @param source defines the source skeleton
  13623. * @param name defines the name of the range to copy
  13624. * @param rescaleAsRequired defines if rescaling must be applied if required
  13625. * @returns true if operation was successful
  13626. */
  13627. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13628. /**
  13629. * Forces the skeleton to go to rest pose
  13630. */
  13631. returnToRest(): void;
  13632. private _getHighestAnimationFrame;
  13633. /**
  13634. * Begin a specific animation range
  13635. * @param name defines the name of the range to start
  13636. * @param loop defines if looping must be turned on (false by default)
  13637. * @param speedRatio defines the speed ratio to apply (1 by default)
  13638. * @param onAnimationEnd defines a callback which will be called when animation will end
  13639. * @returns a new animatable
  13640. */
  13641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13642. /** @hidden */
  13643. _markAsDirty(): void;
  13644. /** @hidden */
  13645. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13646. /** @hidden */
  13647. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13648. private _computeTransformMatrices;
  13649. /**
  13650. * Build all resources required to render a skeleton
  13651. */
  13652. prepare(): void;
  13653. /**
  13654. * Gets the list of animatables currently running for this skeleton
  13655. * @returns an array of animatables
  13656. */
  13657. getAnimatables(): IAnimatable[];
  13658. /**
  13659. * Clone the current skeleton
  13660. * @param name defines the name of the new skeleton
  13661. * @param id defines the id of the new skeleton
  13662. * @returns the new skeleton
  13663. */
  13664. clone(name: string, id?: string): Skeleton;
  13665. /**
  13666. * Enable animation blending for this skeleton
  13667. * @param blendingSpeed defines the blending speed to apply
  13668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13669. */
  13670. enableBlending(blendingSpeed?: number): void;
  13671. /**
  13672. * Releases all resources associated with the current skeleton
  13673. */
  13674. dispose(): void;
  13675. /**
  13676. * Serialize the skeleton in a JSON object
  13677. * @returns a JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Creates a new skeleton from serialized data
  13682. * @param parsedSkeleton defines the serialized data
  13683. * @param scene defines the hosting scene
  13684. * @returns a new skeleton
  13685. */
  13686. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13687. /**
  13688. * Compute all node absolute transforms
  13689. * @param forceUpdate defines if computation must be done even if cache is up to date
  13690. */
  13691. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13692. /**
  13693. * Gets the root pose matrix
  13694. * @returns a matrix
  13695. */
  13696. getPoseMatrix(): Nullable<Matrix>;
  13697. /**
  13698. * Sorts bones per internal index
  13699. */
  13700. sortBones(): void;
  13701. private _sortBones;
  13702. }
  13703. }
  13704. declare module "babylonjs/Bones/bone" {
  13705. import { Skeleton } from "babylonjs/Bones/skeleton";
  13706. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13710. import { Node } from "babylonjs/node";
  13711. import { Space } from "babylonjs/Maths/math.axis";
  13712. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13713. /**
  13714. * Class used to store bone information
  13715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13716. */
  13717. export class Bone extends Node {
  13718. /**
  13719. * defines the bone name
  13720. */
  13721. name: string;
  13722. private static _tmpVecs;
  13723. private static _tmpQuat;
  13724. private static _tmpMats;
  13725. /**
  13726. * Gets the list of child bones
  13727. */
  13728. children: Bone[];
  13729. /** Gets the animations associated with this bone */
  13730. animations: import("babylonjs/Animations/animation").Animation[];
  13731. /**
  13732. * Gets or sets bone length
  13733. */
  13734. length: number;
  13735. /**
  13736. * @hidden Internal only
  13737. * Set this value to map this bone to a different index in the transform matrices
  13738. * Set this value to -1 to exclude the bone from the transform matrices
  13739. */
  13740. _index: Nullable<number>;
  13741. private _skeleton;
  13742. private _localMatrix;
  13743. private _restPose;
  13744. private _baseMatrix;
  13745. private _absoluteTransform;
  13746. private _invertedAbsoluteTransform;
  13747. private _parent;
  13748. private _scalingDeterminant;
  13749. private _worldTransform;
  13750. private _localScaling;
  13751. private _localRotation;
  13752. private _localPosition;
  13753. private _needToDecompose;
  13754. private _needToCompose;
  13755. /** @hidden */
  13756. _linkedTransformNode: Nullable<TransformNode>;
  13757. /** @hidden */
  13758. _waitingTransformNodeId: Nullable<string>;
  13759. /** @hidden */
  13760. /** @hidden */
  13761. _matrix: Matrix;
  13762. /**
  13763. * Create a new bone
  13764. * @param name defines the bone name
  13765. * @param skeleton defines the parent skeleton
  13766. * @param parentBone defines the parent (can be null if the bone is the root)
  13767. * @param localMatrix defines the local matrix
  13768. * @param restPose defines the rest pose matrix
  13769. * @param baseMatrix defines the base matrix
  13770. * @param index defines index of the bone in the hiearchy
  13771. */
  13772. constructor(
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13777. /**
  13778. * Gets the current object class name.
  13779. * @return the class name
  13780. */
  13781. getClassName(): string;
  13782. /**
  13783. * Gets the parent skeleton
  13784. * @returns a skeleton
  13785. */
  13786. getSkeleton(): Skeleton;
  13787. /**
  13788. * Gets parent bone
  13789. * @returns a bone or null if the bone is the root of the bone hierarchy
  13790. */
  13791. getParent(): Nullable<Bone>;
  13792. /**
  13793. * Returns an array containing the root bones
  13794. * @returns an array containing the root bones
  13795. */
  13796. getChildren(): Array<Bone>;
  13797. /**
  13798. * Gets the node index in matrix array generated for rendering
  13799. * @returns the node index
  13800. */
  13801. getIndex(): number;
  13802. /**
  13803. * Sets the parent bone
  13804. * @param parent defines the parent (can be null if the bone is the root)
  13805. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13806. */
  13807. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13808. /**
  13809. * Gets the local matrix
  13810. * @returns a matrix
  13811. */
  13812. getLocalMatrix(): Matrix;
  13813. /**
  13814. * Gets the base matrix (initial matrix which remains unchanged)
  13815. * @returns a matrix
  13816. */
  13817. getBaseMatrix(): Matrix;
  13818. /**
  13819. * Gets the rest pose matrix
  13820. * @returns a matrix
  13821. */
  13822. getRestPose(): Matrix;
  13823. /**
  13824. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13825. */
  13826. getWorldMatrix(): Matrix;
  13827. /**
  13828. * Sets the local matrix to rest pose matrix
  13829. */
  13830. returnToRest(): void;
  13831. /**
  13832. * Gets the inverse of the absolute transform matrix.
  13833. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13834. * @returns a matrix
  13835. */
  13836. getInvertedAbsoluteTransform(): Matrix;
  13837. /**
  13838. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13839. * @returns a matrix
  13840. */
  13841. getAbsoluteTransform(): Matrix;
  13842. /**
  13843. * Links with the given transform node.
  13844. * The local matrix of this bone is copied from the transform node every frame.
  13845. * @param transformNode defines the transform node to link to
  13846. */
  13847. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13848. /**
  13849. * Gets the node used to drive the bone's transformation
  13850. * @returns a transform node or null
  13851. */
  13852. getTransformNode(): Nullable<TransformNode>;
  13853. /** Gets or sets current position (in local space) */
  13854. position: Vector3;
  13855. /** Gets or sets current rotation (in local space) */
  13856. rotation: Vector3;
  13857. /** Gets or sets current rotation quaternion (in local space) */
  13858. rotationQuaternion: Quaternion;
  13859. /** Gets or sets current scaling (in local space) */
  13860. scaling: Vector3;
  13861. /**
  13862. * Gets the animation properties override
  13863. */
  13864. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13865. private _decompose;
  13866. private _compose;
  13867. /**
  13868. * Update the base and local matrices
  13869. * @param matrix defines the new base or local matrix
  13870. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13871. * @param updateLocalMatrix defines if the local matrix should be updated
  13872. */
  13873. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13874. /** @hidden */
  13875. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13876. /**
  13877. * Flag the bone as dirty (Forcing it to update everything)
  13878. */
  13879. markAsDirty(): void;
  13880. /** @hidden */
  13881. _markAsDirtyAndCompose(): void;
  13882. private _markAsDirtyAndDecompose;
  13883. /**
  13884. * Translate the bone in local or world space
  13885. * @param vec The amount to translate the bone
  13886. * @param space The space that the translation is in
  13887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13888. */
  13889. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13890. /**
  13891. * Set the postion of the bone in local or world space
  13892. * @param position The position to set the bone
  13893. * @param space The space that the position is in
  13894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13895. */
  13896. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13897. /**
  13898. * Set the absolute position of the bone (world space)
  13899. * @param position The position to set the bone
  13900. * @param mesh The mesh that this bone is attached to
  13901. */
  13902. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Scale the bone on the x, y and z axes (in local space)
  13905. * @param x The amount to scale the bone on the x axis
  13906. * @param y The amount to scale the bone on the y axis
  13907. * @param z The amount to scale the bone on the z axis
  13908. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13909. */
  13910. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13911. /**
  13912. * Set the bone scaling in local space
  13913. * @param scale defines the scaling vector
  13914. */
  13915. setScale(scale: Vector3): void;
  13916. /**
  13917. * Gets the current scaling in local space
  13918. * @returns the current scaling vector
  13919. */
  13920. getScale(): Vector3;
  13921. /**
  13922. * Gets the current scaling in local space and stores it in a target vector
  13923. * @param result defines the target vector
  13924. */
  13925. getScaleToRef(result: Vector3): void;
  13926. /**
  13927. * Set the yaw, pitch, and roll of the bone in local or world space
  13928. * @param yaw The rotation of the bone on the y axis
  13929. * @param pitch The rotation of the bone on the x axis
  13930. * @param roll The rotation of the bone on the z axis
  13931. * @param space The space that the axes of rotation are in
  13932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13933. */
  13934. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13935. /**
  13936. * Add a rotation to the bone on an axis in local or world space
  13937. * @param axis The axis to rotate the bone on
  13938. * @param amount The amount to rotate the bone
  13939. * @param space The space that the axis is in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. */
  13942. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13943. /**
  13944. * Set the rotation of the bone to a particular axis angle in local or world space
  13945. * @param axis The axis to rotate the bone on
  13946. * @param angle The angle that the bone should be rotated to
  13947. * @param space The space that the axis is in
  13948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13949. */
  13950. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13951. /**
  13952. * Set the euler rotation of the bone in local of world space
  13953. * @param rotation The euler rotation that the bone should be set to
  13954. * @param space The space that the rotation is in
  13955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13956. */
  13957. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13958. /**
  13959. * Set the quaternion rotation of the bone in local of world space
  13960. * @param quat The quaternion rotation that the bone should be set to
  13961. * @param space The space that the rotation is in
  13962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13963. */
  13964. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13965. /**
  13966. * Set the rotation matrix of the bone in local of world space
  13967. * @param rotMat The rotation matrix that the bone should be set to
  13968. * @param space The space that the rotation is in
  13969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13970. */
  13971. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13972. private _rotateWithMatrix;
  13973. private _getNegativeRotationToRef;
  13974. /**
  13975. * Get the position of the bone in local or world space
  13976. * @param space The space that the returned position is in
  13977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13978. * @returns The position of the bone
  13979. */
  13980. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13981. /**
  13982. * Copy the position of the bone to a vector3 in local or world space
  13983. * @param space The space that the returned position is in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. * @param result The vector3 to copy the position to
  13986. */
  13987. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13988. /**
  13989. * Get the absolute position of the bone (world space)
  13990. * @param mesh The mesh that this bone is attached to
  13991. * @returns The absolute position of the bone
  13992. */
  13993. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13994. /**
  13995. * Copy the absolute position of the bone (world space) to the result param
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @param result The vector3 to copy the absolute position to
  13998. */
  13999. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14000. /**
  14001. * Compute the absolute transforms of this bone and its children
  14002. */
  14003. computeAbsoluteTransforms(): void;
  14004. /**
  14005. * Get the world direction from an axis that is in the local space of the bone
  14006. * @param localAxis The local direction that is used to compute the world direction
  14007. * @param mesh The mesh that this bone is attached to
  14008. * @returns The world direction
  14009. */
  14010. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14011. /**
  14012. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14013. * @param localAxis The local direction that is used to compute the world direction
  14014. * @param mesh The mesh that this bone is attached to
  14015. * @param result The vector3 that the world direction will be copied to
  14016. */
  14017. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14018. /**
  14019. * Get the euler rotation of the bone in local or world space
  14020. * @param space The space that the rotation should be in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. * @returns The euler rotation
  14023. */
  14024. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14025. /**
  14026. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14027. * @param space The space that the rotation should be in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @param result The vector3 that the rotation should be copied to
  14030. */
  14031. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14032. /**
  14033. * Get the quaternion rotation of the bone in either local or world space
  14034. * @param space The space that the rotation should be in
  14035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14036. * @returns The quaternion rotation
  14037. */
  14038. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14039. /**
  14040. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14041. * @param space The space that the rotation should be in
  14042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14043. * @param result The quaternion that the rotation should be copied to
  14044. */
  14045. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14046. /**
  14047. * Get the rotation matrix of the bone in local or world space
  14048. * @param space The space that the rotation should be in
  14049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14050. * @returns The rotation matrix
  14051. */
  14052. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14053. /**
  14054. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14055. * @param space The space that the rotation should be in
  14056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14057. * @param result The quaternion that the rotation should be copied to
  14058. */
  14059. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14060. /**
  14061. * Get the world position of a point that is in the local space of the bone
  14062. * @param position The local position
  14063. * @param mesh The mesh that this bone is attached to
  14064. * @returns The world position
  14065. */
  14066. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14067. /**
  14068. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14069. * @param position The local position
  14070. * @param mesh The mesh that this bone is attached to
  14071. * @param result The vector3 that the world position should be copied to
  14072. */
  14073. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14074. /**
  14075. * Get the local position of a point that is in world space
  14076. * @param position The world position
  14077. * @param mesh The mesh that this bone is attached to
  14078. * @returns The local position
  14079. */
  14080. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14081. /**
  14082. * Get the local position of a point that is in world space and copy it to the result param
  14083. * @param position The world position
  14084. * @param mesh The mesh that this bone is attached to
  14085. * @param result The vector3 that the local position should be copied to
  14086. */
  14087. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14088. }
  14089. }
  14090. declare module "babylonjs/Meshes/transformNode" {
  14091. import { DeepImmutable } from "babylonjs/types";
  14092. import { Observable } from "babylonjs/Misc/observable";
  14093. import { Nullable } from "babylonjs/types";
  14094. import { Camera } from "babylonjs/Cameras/camera";
  14095. import { Scene } from "babylonjs/scene";
  14096. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14097. import { Node } from "babylonjs/node";
  14098. import { Bone } from "babylonjs/Bones/bone";
  14099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14100. import { Space } from "babylonjs/Maths/math.axis";
  14101. /**
  14102. * 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.
  14103. * @see https://doc.babylonjs.com/how_to/transformnode
  14104. */
  14105. export class TransformNode extends Node {
  14106. /**
  14107. * Object will not rotate to face the camera
  14108. */
  14109. static BILLBOARDMODE_NONE: number;
  14110. /**
  14111. * Object will rotate to face the camera but only on the x axis
  14112. */
  14113. static BILLBOARDMODE_X: number;
  14114. /**
  14115. * Object will rotate to face the camera but only on the y axis
  14116. */
  14117. static BILLBOARDMODE_Y: number;
  14118. /**
  14119. * Object will rotate to face the camera but only on the z axis
  14120. */
  14121. static BILLBOARDMODE_Z: number;
  14122. /**
  14123. * Object will rotate to face the camera
  14124. */
  14125. static BILLBOARDMODE_ALL: number;
  14126. /**
  14127. * Object will rotate to face the camera's position instead of orientation
  14128. */
  14129. static BILLBOARDMODE_USE_POSITION: number;
  14130. private _forward;
  14131. private _forwardInverted;
  14132. private _up;
  14133. private _right;
  14134. private _rightInverted;
  14135. private _position;
  14136. private _rotation;
  14137. private _rotationQuaternion;
  14138. protected _scaling: Vector3;
  14139. protected _isDirty: boolean;
  14140. private _transformToBoneReferal;
  14141. private _isAbsoluteSynced;
  14142. private _billboardMode;
  14143. /**
  14144. * Gets or sets the billboard mode. Default is 0.
  14145. *
  14146. * | Value | Type | Description |
  14147. * | --- | --- | --- |
  14148. * | 0 | BILLBOARDMODE_NONE | |
  14149. * | 1 | BILLBOARDMODE_X | |
  14150. * | 2 | BILLBOARDMODE_Y | |
  14151. * | 4 | BILLBOARDMODE_Z | |
  14152. * | 7 | BILLBOARDMODE_ALL | |
  14153. *
  14154. */
  14155. billboardMode: number;
  14156. private _preserveParentRotationForBillboard;
  14157. /**
  14158. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14159. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14160. */
  14161. preserveParentRotationForBillboard: boolean;
  14162. /**
  14163. * 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
  14164. */
  14165. scalingDeterminant: number;
  14166. private _infiniteDistance;
  14167. /**
  14168. * Gets or sets the distance of the object to max, often used by skybox
  14169. */
  14170. infiniteDistance: boolean;
  14171. /**
  14172. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14173. * By default the system will update normals to compensate
  14174. */
  14175. ignoreNonUniformScaling: boolean;
  14176. /**
  14177. * 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
  14178. */
  14179. reIntegrateRotationIntoRotationQuaternion: boolean;
  14180. /** @hidden */
  14181. _poseMatrix: Nullable<Matrix>;
  14182. /** @hidden */
  14183. _localMatrix: Matrix;
  14184. private _usePivotMatrix;
  14185. private _absolutePosition;
  14186. private _absoluteScaling;
  14187. private _absoluteRotationQuaternion;
  14188. private _pivotMatrix;
  14189. private _pivotMatrixInverse;
  14190. protected _postMultiplyPivotMatrix: boolean;
  14191. protected _isWorldMatrixFrozen: boolean;
  14192. /** @hidden */
  14193. _indexInSceneTransformNodesArray: number;
  14194. /**
  14195. * An event triggered after the world matrix is updated
  14196. */
  14197. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14198. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14199. /**
  14200. * Gets a string identifying the name of the class
  14201. * @returns "TransformNode" string
  14202. */
  14203. getClassName(): string;
  14204. /**
  14205. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14206. */
  14207. position: Vector3;
  14208. /**
  14209. * 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)).
  14210. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14211. */
  14212. rotation: Vector3;
  14213. /**
  14214. * 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)).
  14215. */
  14216. scaling: Vector3;
  14217. /**
  14218. * 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).
  14219. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14220. */
  14221. rotationQuaternion: Nullable<Quaternion>;
  14222. /**
  14223. * The forward direction of that transform in world space.
  14224. */
  14225. readonly forward: Vector3;
  14226. /**
  14227. * The up direction of that transform in world space.
  14228. */
  14229. readonly up: Vector3;
  14230. /**
  14231. * The right direction of that transform in world space.
  14232. */
  14233. readonly right: Vector3;
  14234. /**
  14235. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14236. * @param matrix the matrix to copy the pose from
  14237. * @returns this TransformNode.
  14238. */
  14239. updatePoseMatrix(matrix: Matrix): TransformNode;
  14240. /**
  14241. * Returns the mesh Pose matrix.
  14242. * @returns the pose matrix
  14243. */
  14244. getPoseMatrix(): Matrix;
  14245. /** @hidden */
  14246. _isSynchronized(): boolean;
  14247. /** @hidden */
  14248. _initCache(): void;
  14249. /**
  14250. * Flag the transform node as dirty (Forcing it to update everything)
  14251. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14252. * @returns this transform node
  14253. */
  14254. markAsDirty(property: string): TransformNode;
  14255. /**
  14256. * Returns the current mesh absolute position.
  14257. * Returns a Vector3.
  14258. */
  14259. readonly absolutePosition: Vector3;
  14260. /**
  14261. * Returns the current mesh absolute scaling.
  14262. * Returns a Vector3.
  14263. */
  14264. readonly absoluteScaling: Vector3;
  14265. /**
  14266. * Returns the current mesh absolute rotation.
  14267. * Returns a Quaternion.
  14268. */
  14269. readonly absoluteRotationQuaternion: Quaternion;
  14270. /**
  14271. * Sets a new matrix to apply before all other transformation
  14272. * @param matrix defines the transform matrix
  14273. * @returns the current TransformNode
  14274. */
  14275. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14276. /**
  14277. * Sets a new pivot matrix to the current node
  14278. * @param matrix defines the new pivot matrix to use
  14279. * @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
  14280. * @returns the current TransformNode
  14281. */
  14282. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14283. /**
  14284. * Returns the mesh pivot matrix.
  14285. * Default : Identity.
  14286. * @returns the matrix
  14287. */
  14288. getPivotMatrix(): Matrix;
  14289. /**
  14290. * Instantiate (when possible) or clone that node with its hierarchy
  14291. * @param newParent defines the new parent to use for the instance (or clone)
  14292. * @param options defines options to configure how copy is done
  14293. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14294. * @returns an instance (or a clone) of the current node with its hiearchy
  14295. */
  14296. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14297. doNotInstantiate: boolean;
  14298. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14299. /**
  14300. * Prevents the World matrix to be computed any longer
  14301. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14302. * @returns the TransformNode.
  14303. */
  14304. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14305. /**
  14306. * Allows back the World matrix computation.
  14307. * @returns the TransformNode.
  14308. */
  14309. unfreezeWorldMatrix(): this;
  14310. /**
  14311. * True if the World matrix has been frozen.
  14312. */
  14313. readonly isWorldMatrixFrozen: boolean;
  14314. /**
  14315. * Retuns the mesh absolute position in the World.
  14316. * @returns a Vector3.
  14317. */
  14318. getAbsolutePosition(): Vector3;
  14319. /**
  14320. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14321. * @param absolutePosition the absolute position to set
  14322. * @returns the TransformNode.
  14323. */
  14324. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14325. /**
  14326. * Sets the mesh position in its local space.
  14327. * @param vector3 the position to set in localspace
  14328. * @returns the TransformNode.
  14329. */
  14330. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14331. /**
  14332. * Returns the mesh position in the local space from the current World matrix values.
  14333. * @returns a new Vector3.
  14334. */
  14335. getPositionExpressedInLocalSpace(): Vector3;
  14336. /**
  14337. * Translates the mesh along the passed Vector3 in its local space.
  14338. * @param vector3 the distance to translate in localspace
  14339. * @returns the TransformNode.
  14340. */
  14341. locallyTranslate(vector3: Vector3): TransformNode;
  14342. private static _lookAtVectorCache;
  14343. /**
  14344. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14345. * @param targetPoint the position (must be in same space as current mesh) to look at
  14346. * @param yawCor optional yaw (y-axis) correction in radians
  14347. * @param pitchCor optional pitch (x-axis) correction in radians
  14348. * @param rollCor optional roll (z-axis) correction in radians
  14349. * @param space the choosen space of the target
  14350. * @returns the TransformNode.
  14351. */
  14352. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14355. * This Vector3 is expressed in the World space.
  14356. * @param localAxis axis to rotate
  14357. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14358. */
  14359. getDirection(localAxis: Vector3): Vector3;
  14360. /**
  14361. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14362. * localAxis is expressed in the mesh local space.
  14363. * result is computed in the Wordl space from the mesh World matrix.
  14364. * @param localAxis axis to rotate
  14365. * @param result the resulting transformnode
  14366. * @returns this TransformNode.
  14367. */
  14368. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14369. /**
  14370. * Sets this transform node rotation to the given local axis.
  14371. * @param localAxis the axis in local space
  14372. * @param yawCor optional yaw (y-axis) correction in radians
  14373. * @param pitchCor optional pitch (x-axis) correction in radians
  14374. * @param rollCor optional roll (z-axis) correction in radians
  14375. * @returns this TransformNode
  14376. */
  14377. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14378. /**
  14379. * Sets a new pivot point to the current node
  14380. * @param point defines the new pivot point to use
  14381. * @param space defines if the point is in world or local space (local by default)
  14382. * @returns the current TransformNode
  14383. */
  14384. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14385. /**
  14386. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14387. * @returns the pivot point
  14388. */
  14389. getPivotPoint(): Vector3;
  14390. /**
  14391. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14392. * @param result the vector3 to store the result
  14393. * @returns this TransformNode.
  14394. */
  14395. getPivotPointToRef(result: Vector3): TransformNode;
  14396. /**
  14397. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14398. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14399. */
  14400. getAbsolutePivotPoint(): Vector3;
  14401. /**
  14402. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14403. * @param result vector3 to store the result
  14404. * @returns this TransformNode.
  14405. */
  14406. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14407. /**
  14408. * Defines the passed node as the parent of the current node.
  14409. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14410. * @see https://doc.babylonjs.com/how_to/parenting
  14411. * @param node the node ot set as the parent
  14412. * @returns this TransformNode.
  14413. */
  14414. setParent(node: Nullable<Node>): TransformNode;
  14415. private _nonUniformScaling;
  14416. /**
  14417. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14418. */
  14419. readonly nonUniformScaling: boolean;
  14420. /** @hidden */
  14421. _updateNonUniformScalingState(value: boolean): boolean;
  14422. /**
  14423. * Attach the current TransformNode to another TransformNode associated with a bone
  14424. * @param bone Bone affecting the TransformNode
  14425. * @param affectedTransformNode TransformNode associated with the bone
  14426. * @returns this object
  14427. */
  14428. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14429. /**
  14430. * Detach the transform node if its associated with a bone
  14431. * @returns this object
  14432. */
  14433. detachFromBone(): TransformNode;
  14434. private static _rotationAxisCache;
  14435. /**
  14436. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14437. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14438. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14439. * The passed axis is also normalized.
  14440. * @param axis the axis to rotate around
  14441. * @param amount the amount to rotate in radians
  14442. * @param space Space to rotate in (Default: local)
  14443. * @returns the TransformNode.
  14444. */
  14445. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14446. /**
  14447. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14448. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14449. * The passed axis is also normalized. .
  14450. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14451. * @param point the point to rotate around
  14452. * @param axis the axis to rotate around
  14453. * @param amount the amount to rotate in radians
  14454. * @returns the TransformNode
  14455. */
  14456. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14457. /**
  14458. * Translates the mesh along the axis vector for the passed distance in the given space.
  14459. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14460. * @param axis the axis to translate in
  14461. * @param distance the distance to translate
  14462. * @param space Space to rotate in (Default: local)
  14463. * @returns the TransformNode.
  14464. */
  14465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14466. /**
  14467. * Adds a rotation step to the mesh current rotation.
  14468. * x, y, z are Euler angles expressed in radians.
  14469. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14470. * This means this rotation is made in the mesh local space only.
  14471. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14472. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14473. * ```javascript
  14474. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14475. * ```
  14476. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14477. * 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.
  14478. * @param x Rotation to add
  14479. * @param y Rotation to add
  14480. * @param z Rotation to add
  14481. * @returns the TransformNode.
  14482. */
  14483. addRotation(x: number, y: number, z: number): TransformNode;
  14484. /**
  14485. * @hidden
  14486. */
  14487. protected _getEffectiveParent(): Nullable<Node>;
  14488. /**
  14489. * Computes the world matrix of the node
  14490. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14491. * @returns the world matrix
  14492. */
  14493. computeWorldMatrix(force?: boolean): Matrix;
  14494. protected _afterComputeWorldMatrix(): void;
  14495. /**
  14496. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14497. * @param func callback function to add
  14498. *
  14499. * @returns the TransformNode.
  14500. */
  14501. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14502. /**
  14503. * Removes a registered callback function.
  14504. * @param func callback function to remove
  14505. * @returns the TransformNode.
  14506. */
  14507. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14508. /**
  14509. * Gets the position of the current mesh in camera space
  14510. * @param camera defines the camera to use
  14511. * @returns a position
  14512. */
  14513. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14514. /**
  14515. * Returns the distance from the mesh to the active camera
  14516. * @param camera defines the camera to use
  14517. * @returns the distance
  14518. */
  14519. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14520. /**
  14521. * Clone the current transform node
  14522. * @param name Name of the new clone
  14523. * @param newParent New parent for the clone
  14524. * @param doNotCloneChildren Do not clone children hierarchy
  14525. * @returns the new transform node
  14526. */
  14527. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14528. /**
  14529. * Serializes the objects information.
  14530. * @param currentSerializationObject defines the object to serialize in
  14531. * @returns the serialized object
  14532. */
  14533. serialize(currentSerializationObject?: any): any;
  14534. /**
  14535. * Returns a new TransformNode object parsed from the source provided.
  14536. * @param parsedTransformNode is the source.
  14537. * @param scene the scne the object belongs to
  14538. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14539. * @returns a new TransformNode object parsed from the source provided.
  14540. */
  14541. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14542. /**
  14543. * Get all child-transformNodes of this node
  14544. * @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
  14545. * @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
  14546. * @returns an array of TransformNode
  14547. */
  14548. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14549. /**
  14550. * Releases resources associated with this transform node.
  14551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14553. */
  14554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14555. /**
  14556. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14557. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14558. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14559. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14560. * @returns the current mesh
  14561. */
  14562. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14563. private _syncAbsoluteScalingAndRotation;
  14564. }
  14565. }
  14566. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14567. import { Observable } from "babylonjs/Misc/observable";
  14568. import { Nullable } from "babylonjs/types";
  14569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14572. import { Ray } from "babylonjs/Culling/ray";
  14573. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14574. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14575. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14576. /**
  14577. * Defines the types of pose enabled controllers that are supported
  14578. */
  14579. export enum PoseEnabledControllerType {
  14580. /**
  14581. * HTC Vive
  14582. */
  14583. VIVE = 0,
  14584. /**
  14585. * Oculus Rift
  14586. */
  14587. OCULUS = 1,
  14588. /**
  14589. * Windows mixed reality
  14590. */
  14591. WINDOWS = 2,
  14592. /**
  14593. * Samsung gear VR
  14594. */
  14595. GEAR_VR = 3,
  14596. /**
  14597. * Google Daydream
  14598. */
  14599. DAYDREAM = 4,
  14600. /**
  14601. * Generic
  14602. */
  14603. GENERIC = 5
  14604. }
  14605. /**
  14606. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14607. */
  14608. export interface MutableGamepadButton {
  14609. /**
  14610. * Value of the button/trigger
  14611. */
  14612. value: number;
  14613. /**
  14614. * If the button/trigger is currently touched
  14615. */
  14616. touched: boolean;
  14617. /**
  14618. * If the button/trigger is currently pressed
  14619. */
  14620. pressed: boolean;
  14621. }
  14622. /**
  14623. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14624. * @hidden
  14625. */
  14626. export interface ExtendedGamepadButton extends GamepadButton {
  14627. /**
  14628. * If the button/trigger is currently pressed
  14629. */
  14630. readonly pressed: boolean;
  14631. /**
  14632. * If the button/trigger is currently touched
  14633. */
  14634. readonly touched: boolean;
  14635. /**
  14636. * Value of the button/trigger
  14637. */
  14638. readonly value: number;
  14639. }
  14640. /** @hidden */
  14641. export interface _GamePadFactory {
  14642. /**
  14643. * Returns wether or not the current gamepad can be created for this type of controller.
  14644. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14645. * @returns true if it can be created, otherwise false
  14646. */
  14647. canCreate(gamepadInfo: any): boolean;
  14648. /**
  14649. * Creates a new instance of the Gamepad.
  14650. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14651. * @returns the new gamepad instance
  14652. */
  14653. create(gamepadInfo: any): Gamepad;
  14654. }
  14655. /**
  14656. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14657. */
  14658. export class PoseEnabledControllerHelper {
  14659. /** @hidden */
  14660. static _ControllerFactories: _GamePadFactory[];
  14661. /** @hidden */
  14662. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14663. /**
  14664. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14665. * @param vrGamepad the gamepad to initialized
  14666. * @returns a vr controller of the type the gamepad identified as
  14667. */
  14668. static InitiateController(vrGamepad: any): Gamepad;
  14669. }
  14670. /**
  14671. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14672. */
  14673. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14674. /**
  14675. * If the controller is used in a webXR session
  14676. */
  14677. isXR: boolean;
  14678. private _deviceRoomPosition;
  14679. private _deviceRoomRotationQuaternion;
  14680. /**
  14681. * The device position in babylon space
  14682. */
  14683. devicePosition: Vector3;
  14684. /**
  14685. * The device rotation in babylon space
  14686. */
  14687. deviceRotationQuaternion: Quaternion;
  14688. /**
  14689. * The scale factor of the device in babylon space
  14690. */
  14691. deviceScaleFactor: number;
  14692. /**
  14693. * (Likely devicePosition should be used instead) The device position in its room space
  14694. */
  14695. position: Vector3;
  14696. /**
  14697. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14698. */
  14699. rotationQuaternion: Quaternion;
  14700. /**
  14701. * The type of controller (Eg. Windows mixed reality)
  14702. */
  14703. controllerType: PoseEnabledControllerType;
  14704. protected _calculatedPosition: Vector3;
  14705. private _calculatedRotation;
  14706. /**
  14707. * The raw pose from the device
  14708. */
  14709. rawPose: DevicePose;
  14710. private _trackPosition;
  14711. private _maxRotationDistFromHeadset;
  14712. private _draggedRoomRotation;
  14713. /**
  14714. * @hidden
  14715. */
  14716. _disableTrackPosition(fixedPosition: Vector3): void;
  14717. /**
  14718. * Internal, the mesh attached to the controller
  14719. * @hidden
  14720. */
  14721. _mesh: Nullable<AbstractMesh>;
  14722. private _poseControlledCamera;
  14723. private _leftHandSystemQuaternion;
  14724. /**
  14725. * Internal, matrix used to convert room space to babylon space
  14726. * @hidden
  14727. */
  14728. _deviceToWorld: Matrix;
  14729. /**
  14730. * Node to be used when casting a ray from the controller
  14731. * @hidden
  14732. */
  14733. _pointingPoseNode: Nullable<TransformNode>;
  14734. /**
  14735. * Name of the child mesh that can be used to cast a ray from the controller
  14736. */
  14737. static readonly POINTING_POSE: string;
  14738. /**
  14739. * Creates a new PoseEnabledController from a gamepad
  14740. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14741. */
  14742. constructor(browserGamepad: any);
  14743. private _workingMatrix;
  14744. /**
  14745. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14746. */
  14747. update(): void;
  14748. /**
  14749. * Updates only the pose device and mesh without doing any button event checking
  14750. */
  14751. protected _updatePoseAndMesh(): void;
  14752. /**
  14753. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14754. * @param poseData raw pose fromthe device
  14755. */
  14756. updateFromDevice(poseData: DevicePose): void;
  14757. /**
  14758. * @hidden
  14759. */
  14760. _meshAttachedObservable: Observable<AbstractMesh>;
  14761. /**
  14762. * Attaches a mesh to the controller
  14763. * @param mesh the mesh to be attached
  14764. */
  14765. attachToMesh(mesh: AbstractMesh): void;
  14766. /**
  14767. * Attaches the controllers mesh to a camera
  14768. * @param camera the camera the mesh should be attached to
  14769. */
  14770. attachToPoseControlledCamera(camera: TargetCamera): void;
  14771. /**
  14772. * Disposes of the controller
  14773. */
  14774. dispose(): void;
  14775. /**
  14776. * The mesh that is attached to the controller
  14777. */
  14778. readonly mesh: Nullable<AbstractMesh>;
  14779. /**
  14780. * Gets the ray of the controller in the direction the controller is pointing
  14781. * @param length the length the resulting ray should be
  14782. * @returns a ray in the direction the controller is pointing
  14783. */
  14784. getForwardRay(length?: number): Ray;
  14785. }
  14786. }
  14787. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14788. import { Observable } from "babylonjs/Misc/observable";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14791. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14792. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14793. import { Nullable } from "babylonjs/types";
  14794. /**
  14795. * Defines the WebVRController object that represents controllers tracked in 3D space
  14796. */
  14797. export abstract class WebVRController extends PoseEnabledController {
  14798. /**
  14799. * Internal, the default controller model for the controller
  14800. */
  14801. protected _defaultModel: Nullable<AbstractMesh>;
  14802. /**
  14803. * Fired when the trigger state has changed
  14804. */
  14805. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14806. /**
  14807. * Fired when the main button state has changed
  14808. */
  14809. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14810. /**
  14811. * Fired when the secondary button state has changed
  14812. */
  14813. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14814. /**
  14815. * Fired when the pad state has changed
  14816. */
  14817. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14818. /**
  14819. * Fired when controllers stick values have changed
  14820. */
  14821. onPadValuesChangedObservable: Observable<StickValues>;
  14822. /**
  14823. * Array of button availible on the controller
  14824. */
  14825. protected _buttons: Array<MutableGamepadButton>;
  14826. private _onButtonStateChange;
  14827. /**
  14828. * Fired when a controller button's state has changed
  14829. * @param callback the callback containing the button that was modified
  14830. */
  14831. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14832. /**
  14833. * X and Y axis corresponding to the controllers joystick
  14834. */
  14835. pad: StickValues;
  14836. /**
  14837. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14838. */
  14839. hand: string;
  14840. /**
  14841. * The default controller model for the controller
  14842. */
  14843. readonly defaultModel: Nullable<AbstractMesh>;
  14844. /**
  14845. * Creates a new WebVRController from a gamepad
  14846. * @param vrGamepad the gamepad that the WebVRController should be created from
  14847. */
  14848. constructor(vrGamepad: any);
  14849. /**
  14850. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14851. */
  14852. update(): void;
  14853. /**
  14854. * Function to be called when a button is modified
  14855. */
  14856. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14857. /**
  14858. * Loads a mesh and attaches it to the controller
  14859. * @param scene the scene the mesh should be added to
  14860. * @param meshLoaded callback for when the mesh has been loaded
  14861. */
  14862. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14863. private _setButtonValue;
  14864. private _changes;
  14865. private _checkChanges;
  14866. /**
  14867. * Disposes of th webVRCOntroller
  14868. */
  14869. dispose(): void;
  14870. }
  14871. }
  14872. declare module "babylonjs/Lights/hemisphericLight" {
  14873. import { Nullable } from "babylonjs/types";
  14874. import { Scene } from "babylonjs/scene";
  14875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14876. import { Color3 } from "babylonjs/Maths/math.color";
  14877. import { Effect } from "babylonjs/Materials/effect";
  14878. import { Light } from "babylonjs/Lights/light";
  14879. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14880. /**
  14881. * The HemisphericLight simulates the ambient environment light,
  14882. * so the passed direction is the light reflection direction, not the incoming direction.
  14883. */
  14884. export class HemisphericLight extends Light {
  14885. /**
  14886. * The groundColor is the light in the opposite direction to the one specified during creation.
  14887. * 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.
  14888. */
  14889. groundColor: Color3;
  14890. /**
  14891. * The light reflection direction, not the incoming direction.
  14892. */
  14893. direction: Vector3;
  14894. /**
  14895. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14896. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14897. * The HemisphericLight can't cast shadows.
  14898. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14899. * @param name The friendly name of the light
  14900. * @param direction The direction of the light reflection
  14901. * @param scene The scene the light belongs to
  14902. */
  14903. constructor(name: string, direction: Vector3, scene: Scene);
  14904. protected _buildUniformLayout(): void;
  14905. /**
  14906. * Returns the string "HemisphericLight".
  14907. * @return The class name
  14908. */
  14909. getClassName(): string;
  14910. /**
  14911. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14912. * Returns the updated direction.
  14913. * @param target The target the direction should point to
  14914. * @return The computed direction
  14915. */
  14916. setDirectionToTarget(target: Vector3): Vector3;
  14917. /**
  14918. * Returns the shadow generator associated to the light.
  14919. * @returns Always null for hemispheric lights because it does not support shadows.
  14920. */
  14921. getShadowGenerator(): Nullable<IShadowGenerator>;
  14922. /**
  14923. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14924. * @param effect The effect to update
  14925. * @param lightIndex The index of the light in the effect to update
  14926. * @returns The hemispheric light
  14927. */
  14928. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14929. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14930. /**
  14931. * Computes the world matrix of the node
  14932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14933. * @param useWasUpdatedFlag defines a reserved property
  14934. * @returns the world matrix
  14935. */
  14936. computeWorldMatrix(): Matrix;
  14937. /**
  14938. * Returns the integer 3.
  14939. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14940. */
  14941. getTypeID(): number;
  14942. /**
  14943. * Prepares the list of defines specific to the light type.
  14944. * @param defines the list of defines
  14945. * @param lightIndex defines the index of the light for the effect
  14946. */
  14947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14948. }
  14949. }
  14950. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14951. /** @hidden */
  14952. export var vrMultiviewToSingleviewPixelShader: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14959. import { Scene } from "babylonjs/scene";
  14960. /**
  14961. * Renders to multiple views with a single draw call
  14962. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14963. */
  14964. export class MultiviewRenderTarget extends RenderTargetTexture {
  14965. /**
  14966. * Creates a multiview render target
  14967. * @param scene scene used with the render target
  14968. * @param size the size of the render target (used for each view)
  14969. */
  14970. constructor(scene: Scene, size?: number | {
  14971. width: number;
  14972. height: number;
  14973. } | {
  14974. ratio: number;
  14975. });
  14976. /**
  14977. * @hidden
  14978. * @param faceIndex the face index, if its a cube texture
  14979. */
  14980. _bindFrameBuffer(faceIndex?: number): void;
  14981. /**
  14982. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14983. * @returns the view count
  14984. */
  14985. getViewCount(): number;
  14986. }
  14987. }
  14988. declare module "babylonjs/Maths/math.frustum" {
  14989. import { Matrix } from "babylonjs/Maths/math.vector";
  14990. import { DeepImmutable } from "babylonjs/types";
  14991. import { Plane } from "babylonjs/Maths/math.plane";
  14992. /**
  14993. * Represents a camera frustum
  14994. */
  14995. export class Frustum {
  14996. /**
  14997. * Gets the planes representing the frustum
  14998. * @param transform matrix to be applied to the returned planes
  14999. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15000. */
  15001. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15002. /**
  15003. * Gets the near frustum plane transformed by the transform matrix
  15004. * @param transform transformation matrix to be applied to the resulting frustum plane
  15005. * @param frustumPlane the resuling frustum plane
  15006. */
  15007. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15008. /**
  15009. * Gets the far frustum plane transformed by the transform matrix
  15010. * @param transform transformation matrix to be applied to the resulting frustum plane
  15011. * @param frustumPlane the resuling frustum plane
  15012. */
  15013. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15014. /**
  15015. * Gets the left frustum plane transformed by the transform matrix
  15016. * @param transform transformation matrix to be applied to the resulting frustum plane
  15017. * @param frustumPlane the resuling frustum plane
  15018. */
  15019. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15020. /**
  15021. * Gets the right frustum plane transformed by the transform matrix
  15022. * @param transform transformation matrix to be applied to the resulting frustum plane
  15023. * @param frustumPlane the resuling frustum plane
  15024. */
  15025. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15026. /**
  15027. * Gets the top frustum plane transformed by the transform matrix
  15028. * @param transform transformation matrix to be applied to the resulting frustum plane
  15029. * @param frustumPlane the resuling frustum plane
  15030. */
  15031. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15032. /**
  15033. * Gets the bottom frustum plane transformed by the transform matrix
  15034. * @param transform transformation matrix to be applied to the resulting frustum plane
  15035. * @param frustumPlane the resuling frustum plane
  15036. */
  15037. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15038. /**
  15039. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15040. * @param transform transformation matrix to be applied to the resulting frustum planes
  15041. * @param frustumPlanes the resuling frustum planes
  15042. */
  15043. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15044. }
  15045. }
  15046. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15047. import { Camera } from "babylonjs/Cameras/camera";
  15048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15049. import { Nullable } from "babylonjs/types";
  15050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15051. import { Matrix } from "babylonjs/Maths/math.vector";
  15052. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15053. module "babylonjs/Engines/engine" {
  15054. interface Engine {
  15055. /**
  15056. * Creates a new multiview render target
  15057. * @param width defines the width of the texture
  15058. * @param height defines the height of the texture
  15059. * @returns the created multiview texture
  15060. */
  15061. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15062. /**
  15063. * Binds a multiview framebuffer to be drawn to
  15064. * @param multiviewTexture texture to bind
  15065. */
  15066. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15067. }
  15068. }
  15069. module "babylonjs/Cameras/camera" {
  15070. interface Camera {
  15071. /**
  15072. * @hidden
  15073. * 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)
  15074. */
  15075. _useMultiviewToSingleView: boolean;
  15076. /**
  15077. * @hidden
  15078. * 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)
  15079. */
  15080. _multiviewTexture: Nullable<RenderTargetTexture>;
  15081. /**
  15082. * @hidden
  15083. * ensures the multiview texture of the camera exists and has the specified width/height
  15084. * @param width height to set on the multiview texture
  15085. * @param height width to set on the multiview texture
  15086. */
  15087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15088. }
  15089. }
  15090. module "babylonjs/scene" {
  15091. interface Scene {
  15092. /** @hidden */
  15093. _transformMatrixR: Matrix;
  15094. /** @hidden */
  15095. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15096. /** @hidden */
  15097. _createMultiviewUbo(): void;
  15098. /** @hidden */
  15099. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15100. /** @hidden */
  15101. _renderMultiviewToSingleView(camera: Camera): void;
  15102. }
  15103. }
  15104. }
  15105. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15106. import { Camera } from "babylonjs/Cameras/camera";
  15107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15108. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15109. import "babylonjs/Engines/Extensions/engine.multiview";
  15110. /**
  15111. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15112. * This will not be used for webXR as it supports displaying texture arrays directly
  15113. */
  15114. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15115. /**
  15116. * Initializes a VRMultiviewToSingleview
  15117. * @param name name of the post process
  15118. * @param camera camera to be applied to
  15119. * @param scaleFactor scaling factor to the size of the output texture
  15120. */
  15121. constructor(name: string, camera: Camera, scaleFactor: number);
  15122. }
  15123. }
  15124. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15125. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15126. import { Nullable } from "babylonjs/types";
  15127. import { Size } from "babylonjs/Maths/math.size";
  15128. import { Observable } from "babylonjs/Misc/observable";
  15129. /**
  15130. * Interface used to define additional presentation attributes
  15131. */
  15132. export interface IVRPresentationAttributes {
  15133. /**
  15134. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15135. */
  15136. highRefreshRate: boolean;
  15137. /**
  15138. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15139. */
  15140. foveationLevel: number;
  15141. }
  15142. module "babylonjs/Engines/engine" {
  15143. interface Engine {
  15144. /** @hidden */
  15145. _vrDisplay: any;
  15146. /** @hidden */
  15147. _vrSupported: boolean;
  15148. /** @hidden */
  15149. _oldSize: Size;
  15150. /** @hidden */
  15151. _oldHardwareScaleFactor: number;
  15152. /** @hidden */
  15153. _vrExclusivePointerMode: boolean;
  15154. /** @hidden */
  15155. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15156. /** @hidden */
  15157. _onVRDisplayPointerRestricted: () => void;
  15158. /** @hidden */
  15159. _onVRDisplayPointerUnrestricted: () => void;
  15160. /** @hidden */
  15161. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15162. /** @hidden */
  15163. _onVrDisplayDisconnect: Nullable<() => void>;
  15164. /** @hidden */
  15165. _onVrDisplayPresentChange: Nullable<() => void>;
  15166. /**
  15167. * Observable signaled when VR display mode changes
  15168. */
  15169. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15170. /**
  15171. * Observable signaled when VR request present is complete
  15172. */
  15173. onVRRequestPresentComplete: Observable<boolean>;
  15174. /**
  15175. * Observable signaled when VR request present starts
  15176. */
  15177. onVRRequestPresentStart: Observable<Engine>;
  15178. /**
  15179. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15180. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15181. */
  15182. isInVRExclusivePointerMode: boolean;
  15183. /**
  15184. * Gets a boolean indicating if a webVR device was detected
  15185. * @returns true if a webVR device was detected
  15186. */
  15187. isVRDevicePresent(): boolean;
  15188. /**
  15189. * Gets the current webVR device
  15190. * @returns the current webVR device (or null)
  15191. */
  15192. getVRDevice(): any;
  15193. /**
  15194. * Initializes a webVR display and starts listening to display change events
  15195. * The onVRDisplayChangedObservable will be notified upon these changes
  15196. * @returns A promise containing a VRDisplay and if vr is supported
  15197. */
  15198. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15199. /** @hidden */
  15200. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15201. /**
  15202. * Gets or sets the presentation attributes used to configure VR rendering
  15203. */
  15204. vrPresentationAttributes?: IVRPresentationAttributes;
  15205. /**
  15206. * Call this function to switch to webVR mode
  15207. * Will do nothing if webVR is not supported or if there is no webVR device
  15208. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15209. */
  15210. enableVR(): void;
  15211. /** @hidden */
  15212. _onVRFullScreenTriggered(): void;
  15213. }
  15214. }
  15215. }
  15216. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15217. import { Nullable } from "babylonjs/types";
  15218. import { Observable } from "babylonjs/Misc/observable";
  15219. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15220. import { Scene } from "babylonjs/scene";
  15221. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15222. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15223. import { Node } from "babylonjs/node";
  15224. import { Ray } from "babylonjs/Culling/ray";
  15225. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15226. import "babylonjs/Engines/Extensions/engine.webVR";
  15227. /**
  15228. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15229. * IMPORTANT!! The data is right-hand data.
  15230. * @export
  15231. * @interface DevicePose
  15232. */
  15233. export interface DevicePose {
  15234. /**
  15235. * The position of the device, values in array are [x,y,z].
  15236. */
  15237. readonly position: Nullable<Float32Array>;
  15238. /**
  15239. * The linearVelocity of the device, values in array are [x,y,z].
  15240. */
  15241. readonly linearVelocity: Nullable<Float32Array>;
  15242. /**
  15243. * The linearAcceleration of the device, values in array are [x,y,z].
  15244. */
  15245. readonly linearAcceleration: Nullable<Float32Array>;
  15246. /**
  15247. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15248. */
  15249. readonly orientation: Nullable<Float32Array>;
  15250. /**
  15251. * The angularVelocity of the device, values in array are [x,y,z].
  15252. */
  15253. readonly angularVelocity: Nullable<Float32Array>;
  15254. /**
  15255. * The angularAcceleration of the device, values in array are [x,y,z].
  15256. */
  15257. readonly angularAcceleration: Nullable<Float32Array>;
  15258. }
  15259. /**
  15260. * Interface representing a pose controlled object in Babylon.
  15261. * A pose controlled object has both regular pose values as well as pose values
  15262. * from an external device such as a VR head mounted display
  15263. */
  15264. export interface PoseControlled {
  15265. /**
  15266. * The position of the object in babylon space.
  15267. */
  15268. position: Vector3;
  15269. /**
  15270. * The rotation quaternion of the object in babylon space.
  15271. */
  15272. rotationQuaternion: Quaternion;
  15273. /**
  15274. * The position of the device in babylon space.
  15275. */
  15276. devicePosition?: Vector3;
  15277. /**
  15278. * The rotation quaternion of the device in babylon space.
  15279. */
  15280. deviceRotationQuaternion: Quaternion;
  15281. /**
  15282. * The raw pose coming from the device.
  15283. */
  15284. rawPose: Nullable<DevicePose>;
  15285. /**
  15286. * The scale of the device to be used when translating from device space to babylon space.
  15287. */
  15288. deviceScaleFactor: number;
  15289. /**
  15290. * Updates the poseControlled values based on the input device pose.
  15291. * @param poseData the pose data to update the object with
  15292. */
  15293. updateFromDevice(poseData: DevicePose): void;
  15294. }
  15295. /**
  15296. * Set of options to customize the webVRCamera
  15297. */
  15298. export interface WebVROptions {
  15299. /**
  15300. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15301. */
  15302. trackPosition?: boolean;
  15303. /**
  15304. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15305. */
  15306. positionScale?: number;
  15307. /**
  15308. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15309. */
  15310. displayName?: string;
  15311. /**
  15312. * Should the native controller meshes be initialized. (default: true)
  15313. */
  15314. controllerMeshes?: boolean;
  15315. /**
  15316. * Creating a default HemiLight only on controllers. (default: true)
  15317. */
  15318. defaultLightingOnControllers?: boolean;
  15319. /**
  15320. * If you don't want to use the default VR button of the helper. (default: false)
  15321. */
  15322. useCustomVRButton?: boolean;
  15323. /**
  15324. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15325. */
  15326. customVRButton?: HTMLButtonElement;
  15327. /**
  15328. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15329. */
  15330. rayLength?: number;
  15331. /**
  15332. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15333. */
  15334. defaultHeight?: number;
  15335. /**
  15336. * If multiview should be used if availible (default: false)
  15337. */
  15338. useMultiview?: boolean;
  15339. }
  15340. /**
  15341. * This represents a WebVR camera.
  15342. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15343. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15344. */
  15345. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15346. private webVROptions;
  15347. /**
  15348. * @hidden
  15349. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15350. */
  15351. _vrDevice: any;
  15352. /**
  15353. * The rawPose of the vrDevice.
  15354. */
  15355. rawPose: Nullable<DevicePose>;
  15356. private _onVREnabled;
  15357. private _specsVersion;
  15358. private _attached;
  15359. private _frameData;
  15360. protected _descendants: Array<Node>;
  15361. private _deviceRoomPosition;
  15362. /** @hidden */
  15363. _deviceRoomRotationQuaternion: Quaternion;
  15364. private _standingMatrix;
  15365. /**
  15366. * Represents device position in babylon space.
  15367. */
  15368. devicePosition: Vector3;
  15369. /**
  15370. * Represents device rotation in babylon space.
  15371. */
  15372. deviceRotationQuaternion: Quaternion;
  15373. /**
  15374. * The scale of the device to be used when translating from device space to babylon space.
  15375. */
  15376. deviceScaleFactor: number;
  15377. private _deviceToWorld;
  15378. private _worldToDevice;
  15379. /**
  15380. * References to the webVR controllers for the vrDevice.
  15381. */
  15382. controllers: Array<WebVRController>;
  15383. /**
  15384. * Emits an event when a controller is attached.
  15385. */
  15386. onControllersAttachedObservable: Observable<WebVRController[]>;
  15387. /**
  15388. * Emits an event when a controller's mesh has been loaded;
  15389. */
  15390. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15391. /**
  15392. * Emits an event when the HMD's pose has been updated.
  15393. */
  15394. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15395. private _poseSet;
  15396. /**
  15397. * If the rig cameras be used as parent instead of this camera.
  15398. */
  15399. rigParenting: boolean;
  15400. private _lightOnControllers;
  15401. private _defaultHeight?;
  15402. /**
  15403. * Instantiates a WebVRFreeCamera.
  15404. * @param name The name of the WebVRFreeCamera
  15405. * @param position The starting anchor position for the camera
  15406. * @param scene The scene the camera belongs to
  15407. * @param webVROptions a set of customizable options for the webVRCamera
  15408. */
  15409. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15410. /**
  15411. * Gets the device distance from the ground in meters.
  15412. * @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.
  15413. */
  15414. deviceDistanceToRoomGround(): number;
  15415. /**
  15416. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15417. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15418. */
  15419. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15420. /**
  15421. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15422. * @returns A promise with a boolean set to if the standing matrix is supported.
  15423. */
  15424. useStandingMatrixAsync(): Promise<boolean>;
  15425. /**
  15426. * Disposes the camera
  15427. */
  15428. dispose(): void;
  15429. /**
  15430. * Gets a vrController by name.
  15431. * @param name The name of the controller to retreive
  15432. * @returns the controller matching the name specified or null if not found
  15433. */
  15434. getControllerByName(name: string): Nullable<WebVRController>;
  15435. private _leftController;
  15436. /**
  15437. * The controller corresponding to the users left hand.
  15438. */
  15439. readonly leftController: Nullable<WebVRController>;
  15440. private _rightController;
  15441. /**
  15442. * The controller corresponding to the users right hand.
  15443. */
  15444. readonly rightController: Nullable<WebVRController>;
  15445. /**
  15446. * Casts a ray forward from the vrCamera's gaze.
  15447. * @param length Length of the ray (default: 100)
  15448. * @returns the ray corresponding to the gaze
  15449. */
  15450. getForwardRay(length?: number): Ray;
  15451. /**
  15452. * @hidden
  15453. * Updates the camera based on device's frame data
  15454. */
  15455. _checkInputs(): void;
  15456. /**
  15457. * Updates the poseControlled values based on the input device pose.
  15458. * @param poseData Pose coming from the device
  15459. */
  15460. updateFromDevice(poseData: DevicePose): void;
  15461. private _htmlElementAttached;
  15462. private _detachIfAttached;
  15463. /**
  15464. * WebVR's attach control will start broadcasting frames to the device.
  15465. * Note that in certain browsers (chrome for example) this function must be called
  15466. * within a user-interaction callback. Example:
  15467. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15468. *
  15469. * @param element html element to attach the vrDevice to
  15470. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15471. */
  15472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15473. /**
  15474. * Detaches the camera from the html element and disables VR
  15475. *
  15476. * @param element html element to detach from
  15477. */
  15478. detachControl(element: HTMLElement): void;
  15479. /**
  15480. * @returns the name of this class
  15481. */
  15482. getClassName(): string;
  15483. /**
  15484. * Calls resetPose on the vrDisplay
  15485. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15486. */
  15487. resetToCurrentRotation(): void;
  15488. /**
  15489. * @hidden
  15490. * Updates the rig cameras (left and right eye)
  15491. */
  15492. _updateRigCameras(): void;
  15493. private _workingVector;
  15494. private _oneVector;
  15495. private _workingMatrix;
  15496. private updateCacheCalled;
  15497. private _correctPositionIfNotTrackPosition;
  15498. /**
  15499. * @hidden
  15500. * Updates the cached values of the camera
  15501. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15502. */
  15503. _updateCache(ignoreParentClass?: boolean): void;
  15504. /**
  15505. * @hidden
  15506. * Get current device position in babylon world
  15507. */
  15508. _computeDevicePosition(): void;
  15509. /**
  15510. * Updates the current device position and rotation in the babylon world
  15511. */
  15512. update(): void;
  15513. /**
  15514. * @hidden
  15515. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15516. * @returns an identity matrix
  15517. */
  15518. _getViewMatrix(): Matrix;
  15519. private _tmpMatrix;
  15520. /**
  15521. * This function is called by the two RIG cameras.
  15522. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15523. * @hidden
  15524. */
  15525. _getWebVRViewMatrix(): Matrix;
  15526. /** @hidden */
  15527. _getWebVRProjectionMatrix(): Matrix;
  15528. private _onGamepadConnectedObserver;
  15529. private _onGamepadDisconnectedObserver;
  15530. private _updateCacheWhenTrackingDisabledObserver;
  15531. /**
  15532. * Initializes the controllers and their meshes
  15533. */
  15534. initControllers(): void;
  15535. }
  15536. }
  15537. declare module "babylonjs/PostProcesses/postProcess" {
  15538. import { Nullable } from "babylonjs/types";
  15539. import { SmartArray } from "babylonjs/Misc/smartArray";
  15540. import { Observable } from "babylonjs/Misc/observable";
  15541. import { Vector2 } from "babylonjs/Maths/math.vector";
  15542. import { Camera } from "babylonjs/Cameras/camera";
  15543. import { Effect } from "babylonjs/Materials/effect";
  15544. import "babylonjs/Shaders/postprocess.vertex";
  15545. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15546. import { Engine } from "babylonjs/Engines/engine";
  15547. import { Color4 } from "babylonjs/Maths/math.color";
  15548. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15550. /**
  15551. * Size options for a post process
  15552. */
  15553. export type PostProcessOptions = {
  15554. width: number;
  15555. height: number;
  15556. };
  15557. /**
  15558. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15559. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15560. */
  15561. export class PostProcess {
  15562. /** Name of the PostProcess. */
  15563. name: string;
  15564. /**
  15565. * Gets or sets the unique id of the post process
  15566. */
  15567. uniqueId: number;
  15568. /**
  15569. * Width of the texture to apply the post process on
  15570. */
  15571. width: number;
  15572. /**
  15573. * Height of the texture to apply the post process on
  15574. */
  15575. height: number;
  15576. /**
  15577. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15578. * @hidden
  15579. */
  15580. _outputTexture: Nullable<InternalTexture>;
  15581. /**
  15582. * Sampling mode used by the shader
  15583. * See https://doc.babylonjs.com/classes/3.1/texture
  15584. */
  15585. renderTargetSamplingMode: number;
  15586. /**
  15587. * Clear color to use when screen clearing
  15588. */
  15589. clearColor: Color4;
  15590. /**
  15591. * If the buffer needs to be cleared before applying the post process. (default: true)
  15592. * Should be set to false if shader will overwrite all previous pixels.
  15593. */
  15594. autoClear: boolean;
  15595. /**
  15596. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15597. */
  15598. alphaMode: number;
  15599. /**
  15600. * Sets the setAlphaBlendConstants of the babylon engine
  15601. */
  15602. alphaConstants: Color4;
  15603. /**
  15604. * Animations to be used for the post processing
  15605. */
  15606. animations: import("babylonjs/Animations/animation").Animation[];
  15607. /**
  15608. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15609. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15610. */
  15611. enablePixelPerfectMode: boolean;
  15612. /**
  15613. * Force the postprocess to be applied without taking in account viewport
  15614. */
  15615. forceFullscreenViewport: boolean;
  15616. /**
  15617. * List of inspectable custom properties (used by the Inspector)
  15618. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15619. */
  15620. inspectableCustomProperties: IInspectable[];
  15621. /**
  15622. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15623. *
  15624. * | Value | Type | Description |
  15625. * | ----- | ----------------------------------- | ----------- |
  15626. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15627. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15628. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15629. *
  15630. */
  15631. scaleMode: number;
  15632. /**
  15633. * Force textures to be a power of two (default: false)
  15634. */
  15635. alwaysForcePOT: boolean;
  15636. private _samples;
  15637. /**
  15638. * Number of sample textures (default: 1)
  15639. */
  15640. samples: number;
  15641. /**
  15642. * Modify the scale of the post process to be the same as the viewport (default: false)
  15643. */
  15644. adaptScaleToCurrentViewport: boolean;
  15645. private _camera;
  15646. private _scene;
  15647. private _engine;
  15648. private _options;
  15649. private _reusable;
  15650. private _textureType;
  15651. /**
  15652. * Smart array of input and output textures for the post process.
  15653. * @hidden
  15654. */
  15655. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15656. /**
  15657. * The index in _textures that corresponds to the output texture.
  15658. * @hidden
  15659. */
  15660. _currentRenderTextureInd: number;
  15661. private _effect;
  15662. private _samplers;
  15663. private _fragmentUrl;
  15664. private _vertexUrl;
  15665. private _parameters;
  15666. private _scaleRatio;
  15667. protected _indexParameters: any;
  15668. private _shareOutputWithPostProcess;
  15669. private _texelSize;
  15670. private _forcedOutputTexture;
  15671. /**
  15672. * Returns the fragment url or shader name used in the post process.
  15673. * @returns the fragment url or name in the shader store.
  15674. */
  15675. getEffectName(): string;
  15676. /**
  15677. * An event triggered when the postprocess is activated.
  15678. */
  15679. onActivateObservable: Observable<Camera>;
  15680. private _onActivateObserver;
  15681. /**
  15682. * A function that is added to the onActivateObservable
  15683. */
  15684. onActivate: Nullable<(camera: Camera) => void>;
  15685. /**
  15686. * An event triggered when the postprocess changes its size.
  15687. */
  15688. onSizeChangedObservable: Observable<PostProcess>;
  15689. private _onSizeChangedObserver;
  15690. /**
  15691. * A function that is added to the onSizeChangedObservable
  15692. */
  15693. onSizeChanged: (postProcess: PostProcess) => void;
  15694. /**
  15695. * An event triggered when the postprocess applies its effect.
  15696. */
  15697. onApplyObservable: Observable<Effect>;
  15698. private _onApplyObserver;
  15699. /**
  15700. * A function that is added to the onApplyObservable
  15701. */
  15702. onApply: (effect: Effect) => void;
  15703. /**
  15704. * An event triggered before rendering the postprocess
  15705. */
  15706. onBeforeRenderObservable: Observable<Effect>;
  15707. private _onBeforeRenderObserver;
  15708. /**
  15709. * A function that is added to the onBeforeRenderObservable
  15710. */
  15711. onBeforeRender: (effect: Effect) => void;
  15712. /**
  15713. * An event triggered after rendering the postprocess
  15714. */
  15715. onAfterRenderObservable: Observable<Effect>;
  15716. private _onAfterRenderObserver;
  15717. /**
  15718. * A function that is added to the onAfterRenderObservable
  15719. */
  15720. onAfterRender: (efect: Effect) => void;
  15721. /**
  15722. * 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
  15723. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15724. */
  15725. inputTexture: InternalTexture;
  15726. /**
  15727. * Gets the camera which post process is applied to.
  15728. * @returns The camera the post process is applied to.
  15729. */
  15730. getCamera(): Camera;
  15731. /**
  15732. * Gets the texel size of the postprocess.
  15733. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15734. */
  15735. readonly texelSize: Vector2;
  15736. /**
  15737. * Creates a new instance PostProcess
  15738. * @param name The name of the PostProcess.
  15739. * @param fragmentUrl The url of the fragment shader to be used.
  15740. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15741. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15742. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15743. * @param camera The camera to apply the render pass to.
  15744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15745. * @param engine The engine which the post process will be applied. (default: current engine)
  15746. * @param reusable If the post process can be reused on the same frame. (default: false)
  15747. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15748. * @param textureType Type of textures used when performing the post process. (default: 0)
  15749. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15750. * @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
  15751. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15752. */
  15753. constructor(
  15754. /** Name of the PostProcess. */
  15755. 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);
  15756. /**
  15757. * Gets a string idenfifying the name of the class
  15758. * @returns "PostProcess" string
  15759. */
  15760. getClassName(): string;
  15761. /**
  15762. * Gets the engine which this post process belongs to.
  15763. * @returns The engine the post process was enabled with.
  15764. */
  15765. getEngine(): Engine;
  15766. /**
  15767. * The effect that is created when initializing the post process.
  15768. * @returns The created effect corresponding the the postprocess.
  15769. */
  15770. getEffect(): Effect;
  15771. /**
  15772. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15773. * @param postProcess The post process to share the output with.
  15774. * @returns This post process.
  15775. */
  15776. shareOutputWith(postProcess: PostProcess): PostProcess;
  15777. /**
  15778. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15779. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15780. */
  15781. useOwnOutput(): void;
  15782. /**
  15783. * Updates the effect with the current post process compile time values and recompiles the shader.
  15784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15787. * @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
  15788. * @param onCompiled Called when the shader has been compiled.
  15789. * @param onError Called if there is an error when compiling a shader.
  15790. */
  15791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15792. /**
  15793. * The post process is reusable if it can be used multiple times within one frame.
  15794. * @returns If the post process is reusable
  15795. */
  15796. isReusable(): boolean;
  15797. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15798. markTextureDirty(): void;
  15799. /**
  15800. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15801. * 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.
  15802. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15803. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15804. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15805. * @returns The target texture that was bound to be written to.
  15806. */
  15807. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15808. /**
  15809. * If the post process is supported.
  15810. */
  15811. readonly isSupported: boolean;
  15812. /**
  15813. * The aspect ratio of the output texture.
  15814. */
  15815. readonly aspectRatio: number;
  15816. /**
  15817. * Get a value indicating if the post-process is ready to be used
  15818. * @returns true if the post-process is ready (shader is compiled)
  15819. */
  15820. isReady(): boolean;
  15821. /**
  15822. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15823. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15824. */
  15825. apply(): Nullable<Effect>;
  15826. private _disposeTextures;
  15827. /**
  15828. * Disposes the post process.
  15829. * @param camera The camera to dispose the post process on.
  15830. */
  15831. dispose(camera?: Camera): void;
  15832. }
  15833. }
  15834. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15835. /** @hidden */
  15836. export var kernelBlurVaryingDeclaration: {
  15837. name: string;
  15838. shader: string;
  15839. };
  15840. }
  15841. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15842. /** @hidden */
  15843. export var kernelBlurFragment: {
  15844. name: string;
  15845. shader: string;
  15846. };
  15847. }
  15848. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15849. /** @hidden */
  15850. export var kernelBlurFragment2: {
  15851. name: string;
  15852. shader: string;
  15853. };
  15854. }
  15855. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15856. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15857. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15858. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15859. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15860. /** @hidden */
  15861. export var kernelBlurPixelShader: {
  15862. name: string;
  15863. shader: string;
  15864. };
  15865. }
  15866. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15867. /** @hidden */
  15868. export var kernelBlurVertex: {
  15869. name: string;
  15870. shader: string;
  15871. };
  15872. }
  15873. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15874. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15875. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15876. /** @hidden */
  15877. export var kernelBlurVertexShader: {
  15878. name: string;
  15879. shader: string;
  15880. };
  15881. }
  15882. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15883. import { Vector2 } from "babylonjs/Maths/math.vector";
  15884. import { Nullable } from "babylonjs/types";
  15885. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15886. import { Camera } from "babylonjs/Cameras/camera";
  15887. import { Effect } from "babylonjs/Materials/effect";
  15888. import { Engine } from "babylonjs/Engines/engine";
  15889. import "babylonjs/Shaders/kernelBlur.fragment";
  15890. import "babylonjs/Shaders/kernelBlur.vertex";
  15891. /**
  15892. * The Blur Post Process which blurs an image based on a kernel and direction.
  15893. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15894. */
  15895. export class BlurPostProcess extends PostProcess {
  15896. /** The direction in which to blur the image. */
  15897. direction: Vector2;
  15898. private blockCompilation;
  15899. protected _kernel: number;
  15900. protected _idealKernel: number;
  15901. protected _packedFloat: boolean;
  15902. private _staticDefines;
  15903. /**
  15904. * Sets the length in pixels of the blur sample region
  15905. */
  15906. /**
  15907. * Gets the length in pixels of the blur sample region
  15908. */
  15909. kernel: number;
  15910. /**
  15911. * Sets wether or not the blur needs to unpack/repack floats
  15912. */
  15913. /**
  15914. * Gets wether or not the blur is unpacking/repacking floats
  15915. */
  15916. packedFloat: boolean;
  15917. /**
  15918. * Creates a new instance BlurPostProcess
  15919. * @param name The name of the effect.
  15920. * @param direction The direction in which to blur the image.
  15921. * @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.
  15922. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15923. * @param camera The camera to apply the render pass to.
  15924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15925. * @param engine The engine which the post process will be applied. (default: current engine)
  15926. * @param reusable If the post process can be reused on the same frame. (default: false)
  15927. * @param textureType Type of textures used when performing the post process. (default: 0)
  15928. * @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)
  15929. */
  15930. constructor(name: string,
  15931. /** The direction in which to blur the image. */
  15932. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15933. /**
  15934. * Updates the effect with the current post process compile time values and recompiles the shader.
  15935. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15936. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15937. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15938. * @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
  15939. * @param onCompiled Called when the shader has been compiled.
  15940. * @param onError Called if there is an error when compiling a shader.
  15941. */
  15942. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15943. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15944. /**
  15945. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15946. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15947. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15948. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15949. * The gaps between physical kernels are compensated for in the weighting of the samples
  15950. * @param idealKernel Ideal blur kernel.
  15951. * @return Nearest best kernel.
  15952. */
  15953. protected _nearestBestKernel(idealKernel: number): number;
  15954. /**
  15955. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15956. * @param x The point on the Gaussian distribution to sample.
  15957. * @return the value of the Gaussian function at x.
  15958. */
  15959. protected _gaussianWeight(x: number): number;
  15960. /**
  15961. * Generates a string that can be used as a floating point number in GLSL.
  15962. * @param x Value to print.
  15963. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15964. * @return GLSL float string.
  15965. */
  15966. protected _glslFloat(x: number, decimalFigures?: number): string;
  15967. }
  15968. }
  15969. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15970. import { Scene } from "babylonjs/scene";
  15971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15972. import { Plane } from "babylonjs/Maths/math.plane";
  15973. /**
  15974. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15975. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15976. * You can then easily use it as a reflectionTexture on a flat surface.
  15977. * In case the surface is not a plane, please consider relying on reflection probes.
  15978. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15979. */
  15980. export class MirrorTexture extends RenderTargetTexture {
  15981. private scene;
  15982. /**
  15983. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15984. * 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.
  15985. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15986. */
  15987. mirrorPlane: Plane;
  15988. /**
  15989. * Define the blur ratio used to blur the reflection if needed.
  15990. */
  15991. blurRatio: number;
  15992. /**
  15993. * Define the adaptive blur kernel used to blur the reflection if needed.
  15994. * This will autocompute the closest best match for the `blurKernel`
  15995. */
  15996. adaptiveBlurKernel: number;
  15997. /**
  15998. * Define the blur kernel used to blur the reflection if needed.
  15999. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16000. */
  16001. blurKernel: number;
  16002. /**
  16003. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16004. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16005. */
  16006. blurKernelX: number;
  16007. /**
  16008. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16009. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16010. */
  16011. blurKernelY: number;
  16012. private _autoComputeBlurKernel;
  16013. protected _onRatioRescale(): void;
  16014. private _updateGammaSpace;
  16015. private _imageProcessingConfigChangeObserver;
  16016. private _transformMatrix;
  16017. private _mirrorMatrix;
  16018. private _savedViewMatrix;
  16019. private _blurX;
  16020. private _blurY;
  16021. private _adaptiveBlurKernel;
  16022. private _blurKernelX;
  16023. private _blurKernelY;
  16024. private _blurRatio;
  16025. /**
  16026. * Instantiates a Mirror Texture.
  16027. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16028. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16029. * You can then easily use it as a reflectionTexture on a flat surface.
  16030. * In case the surface is not a plane, please consider relying on reflection probes.
  16031. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16032. * @param name
  16033. * @param size
  16034. * @param scene
  16035. * @param generateMipMaps
  16036. * @param type
  16037. * @param samplingMode
  16038. * @param generateDepthBuffer
  16039. */
  16040. constructor(name: string, size: number | {
  16041. width: number;
  16042. height: number;
  16043. } | {
  16044. ratio: number;
  16045. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16046. private _preparePostProcesses;
  16047. /**
  16048. * Clone the mirror texture.
  16049. * @returns the cloned texture
  16050. */
  16051. clone(): MirrorTexture;
  16052. /**
  16053. * Serialize the texture to a JSON representation you could use in Parse later on
  16054. * @returns the serialized JSON representation
  16055. */
  16056. serialize(): any;
  16057. /**
  16058. * Dispose the texture and release its associated resources.
  16059. */
  16060. dispose(): void;
  16061. }
  16062. }
  16063. declare module "babylonjs/Materials/Textures/texture" {
  16064. import { Observable } from "babylonjs/Misc/observable";
  16065. import { Nullable } from "babylonjs/types";
  16066. import { Matrix } from "babylonjs/Maths/math.vector";
  16067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16068. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16069. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16070. import { Scene } from "babylonjs/scene";
  16071. /**
  16072. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16073. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16074. */
  16075. export class Texture extends BaseTexture {
  16076. /**
  16077. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16078. */
  16079. static SerializeBuffers: boolean;
  16080. /** @hidden */
  16081. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16082. /** @hidden */
  16083. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16084. /** @hidden */
  16085. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16086. /** nearest is mag = nearest and min = nearest and mip = linear */
  16087. static readonly NEAREST_SAMPLINGMODE: number;
  16088. /** nearest is mag = nearest and min = nearest and mip = linear */
  16089. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16091. static readonly BILINEAR_SAMPLINGMODE: number;
  16092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16093. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16094. /** Trilinear is mag = linear and min = linear and mip = linear */
  16095. static readonly TRILINEAR_SAMPLINGMODE: number;
  16096. /** Trilinear is mag = linear and min = linear and mip = linear */
  16097. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16098. /** mag = nearest and min = nearest and mip = nearest */
  16099. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16100. /** mag = nearest and min = linear and mip = nearest */
  16101. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16102. /** mag = nearest and min = linear and mip = linear */
  16103. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16104. /** mag = nearest and min = linear and mip = none */
  16105. static readonly NEAREST_LINEAR: number;
  16106. /** mag = nearest and min = nearest and mip = none */
  16107. static readonly NEAREST_NEAREST: number;
  16108. /** mag = linear and min = nearest and mip = nearest */
  16109. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16110. /** mag = linear and min = nearest and mip = linear */
  16111. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16112. /** mag = linear and min = linear and mip = none */
  16113. static readonly LINEAR_LINEAR: number;
  16114. /** mag = linear and min = nearest and mip = none */
  16115. static readonly LINEAR_NEAREST: number;
  16116. /** Explicit coordinates mode */
  16117. static readonly EXPLICIT_MODE: number;
  16118. /** Spherical coordinates mode */
  16119. static readonly SPHERICAL_MODE: number;
  16120. /** Planar coordinates mode */
  16121. static readonly PLANAR_MODE: number;
  16122. /** Cubic coordinates mode */
  16123. static readonly CUBIC_MODE: number;
  16124. /** Projection coordinates mode */
  16125. static readonly PROJECTION_MODE: number;
  16126. /** Inverse Cubic coordinates mode */
  16127. static readonly SKYBOX_MODE: number;
  16128. /** Inverse Cubic coordinates mode */
  16129. static readonly INVCUBIC_MODE: number;
  16130. /** Equirectangular coordinates mode */
  16131. static readonly EQUIRECTANGULAR_MODE: number;
  16132. /** Equirectangular Fixed coordinates mode */
  16133. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16134. /** Equirectangular Fixed Mirrored coordinates mode */
  16135. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16136. /** Texture is not repeating outside of 0..1 UVs */
  16137. static readonly CLAMP_ADDRESSMODE: number;
  16138. /** Texture is repeating outside of 0..1 UVs */
  16139. static readonly WRAP_ADDRESSMODE: number;
  16140. /** Texture is repeating and mirrored */
  16141. static readonly MIRROR_ADDRESSMODE: number;
  16142. /**
  16143. * 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
  16144. */
  16145. static UseSerializedUrlIfAny: boolean;
  16146. /**
  16147. * Define the url of the texture.
  16148. */
  16149. url: Nullable<string>;
  16150. /**
  16151. * Define an offset on the texture to offset the u coordinates of the UVs
  16152. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16153. */
  16154. uOffset: number;
  16155. /**
  16156. * Define an offset on the texture to offset the v coordinates of the UVs
  16157. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16158. */
  16159. vOffset: number;
  16160. /**
  16161. * Define an offset on the texture to scale the u coordinates of the UVs
  16162. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16163. */
  16164. uScale: number;
  16165. /**
  16166. * Define an offset on the texture to scale the v coordinates of the UVs
  16167. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16168. */
  16169. vScale: number;
  16170. /**
  16171. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16172. * @see http://doc.babylonjs.com/how_to/more_materials
  16173. */
  16174. uAng: number;
  16175. /**
  16176. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16177. * @see http://doc.babylonjs.com/how_to/more_materials
  16178. */
  16179. vAng: number;
  16180. /**
  16181. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16182. * @see http://doc.babylonjs.com/how_to/more_materials
  16183. */
  16184. wAng: number;
  16185. /**
  16186. * Defines the center of rotation (U)
  16187. */
  16188. uRotationCenter: number;
  16189. /**
  16190. * Defines the center of rotation (V)
  16191. */
  16192. vRotationCenter: number;
  16193. /**
  16194. * Defines the center of rotation (W)
  16195. */
  16196. wRotationCenter: number;
  16197. /**
  16198. * Are mip maps generated for this texture or not.
  16199. */
  16200. readonly noMipmap: boolean;
  16201. /**
  16202. * List of inspectable custom properties (used by the Inspector)
  16203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16204. */
  16205. inspectableCustomProperties: Nullable<IInspectable[]>;
  16206. private _noMipmap;
  16207. /** @hidden */
  16208. _invertY: boolean;
  16209. private _rowGenerationMatrix;
  16210. private _cachedTextureMatrix;
  16211. private _projectionModeMatrix;
  16212. private _t0;
  16213. private _t1;
  16214. private _t2;
  16215. private _cachedUOffset;
  16216. private _cachedVOffset;
  16217. private _cachedUScale;
  16218. private _cachedVScale;
  16219. private _cachedUAng;
  16220. private _cachedVAng;
  16221. private _cachedWAng;
  16222. private _cachedProjectionMatrixId;
  16223. private _cachedCoordinatesMode;
  16224. /** @hidden */
  16225. protected _initialSamplingMode: number;
  16226. /** @hidden */
  16227. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16228. private _deleteBuffer;
  16229. protected _format: Nullable<number>;
  16230. private _delayedOnLoad;
  16231. private _delayedOnError;
  16232. private _mimeType?;
  16233. /**
  16234. * Observable triggered once the texture has been loaded.
  16235. */
  16236. onLoadObservable: Observable<Texture>;
  16237. protected _isBlocking: boolean;
  16238. /**
  16239. * Is the texture preventing material to render while loading.
  16240. * If false, a default texture will be used instead of the loading one during the preparation step.
  16241. */
  16242. isBlocking: boolean;
  16243. /**
  16244. * Get the current sampling mode associated with the texture.
  16245. */
  16246. readonly samplingMode: number;
  16247. /**
  16248. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16249. */
  16250. readonly invertY: boolean;
  16251. /**
  16252. * Instantiates a new texture.
  16253. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16254. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16255. * @param url defines the url of the picture to load as a texture
  16256. * @param scene defines the scene or engine the texture will belong to
  16257. * @param noMipmap defines if the texture will require mip maps or not
  16258. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16259. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16260. * @param onLoad defines a callback triggered when the texture has been loaded
  16261. * @param onError defines a callback triggered when an error occurred during the loading session
  16262. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16263. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16264. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16265. * @param mimeType defines an optional mime type information
  16266. */
  16267. 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);
  16268. /**
  16269. * Update the url (and optional buffer) of this texture if url was null during construction.
  16270. * @param url the url of the texture
  16271. * @param buffer the buffer of the texture (defaults to null)
  16272. * @param onLoad callback called when the texture is loaded (defaults to null)
  16273. */
  16274. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16275. /**
  16276. * Finish the loading sequence of a texture flagged as delayed load.
  16277. * @hidden
  16278. */
  16279. delayLoad(): void;
  16280. private _prepareRowForTextureGeneration;
  16281. /**
  16282. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16283. * @returns the transform matrix of the texture.
  16284. */
  16285. getTextureMatrix(): Matrix;
  16286. /**
  16287. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16288. * @returns The reflection texture transform
  16289. */
  16290. getReflectionTextureMatrix(): Matrix;
  16291. /**
  16292. * Clones the texture.
  16293. * @returns the cloned texture
  16294. */
  16295. clone(): Texture;
  16296. /**
  16297. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16298. * @returns The JSON representation of the texture
  16299. */
  16300. serialize(): any;
  16301. /**
  16302. * Get the current class name of the texture useful for serialization or dynamic coding.
  16303. * @returns "Texture"
  16304. */
  16305. getClassName(): string;
  16306. /**
  16307. * Dispose the texture and release its associated resources.
  16308. */
  16309. dispose(): void;
  16310. /**
  16311. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16312. * @param parsedTexture Define the JSON representation of the texture
  16313. * @param scene Define the scene the parsed texture should be instantiated in
  16314. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16315. * @returns The parsed texture if successful
  16316. */
  16317. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16318. /**
  16319. * Creates a texture from its base 64 representation.
  16320. * @param data Define the base64 payload without the data: prefix
  16321. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16322. * @param scene Define the scene the texture should belong to
  16323. * @param noMipmap Forces the texture to not create mip map information if true
  16324. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16325. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16326. * @param onLoad define a callback triggered when the texture has been loaded
  16327. * @param onError define a callback triggered when an error occurred during the loading session
  16328. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16329. * @returns the created texture
  16330. */
  16331. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16332. /**
  16333. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16334. * @param data Define the base64 payload without the data: prefix
  16335. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16336. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16337. * @param scene Define the scene the texture should belong to
  16338. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16339. * @param noMipmap Forces the texture to not create mip map information if true
  16340. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16341. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16342. * @param onLoad define a callback triggered when the texture has been loaded
  16343. * @param onError define a callback triggered when an error occurred during the loading session
  16344. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16345. * @returns the created texture
  16346. */
  16347. 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;
  16348. }
  16349. }
  16350. declare module "babylonjs/PostProcesses/postProcessManager" {
  16351. import { Nullable } from "babylonjs/types";
  16352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16354. import { Scene } from "babylonjs/scene";
  16355. /**
  16356. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16357. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16358. */
  16359. export class PostProcessManager {
  16360. private _scene;
  16361. private _indexBuffer;
  16362. private _vertexBuffers;
  16363. /**
  16364. * Creates a new instance PostProcess
  16365. * @param scene The scene that the post process is associated with.
  16366. */
  16367. constructor(scene: Scene);
  16368. private _prepareBuffers;
  16369. private _buildIndexBuffer;
  16370. /**
  16371. * Rebuilds the vertex buffers of the manager.
  16372. * @hidden
  16373. */
  16374. _rebuild(): void;
  16375. /**
  16376. * Prepares a frame to be run through a post process.
  16377. * @param sourceTexture The input texture to the post procesess. (default: null)
  16378. * @param postProcesses An array of post processes to be run. (default: null)
  16379. * @returns True if the post processes were able to be run.
  16380. * @hidden
  16381. */
  16382. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16383. /**
  16384. * Manually render a set of post processes to a texture.
  16385. * @param postProcesses An array of post processes to be run.
  16386. * @param targetTexture The target texture to render to.
  16387. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16388. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16389. * @param lodLevel defines which lod of the texture to render to
  16390. */
  16391. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16392. /**
  16393. * Finalize the result of the output of the postprocesses.
  16394. * @param doNotPresent If true the result will not be displayed to the screen.
  16395. * @param targetTexture The target texture to render to.
  16396. * @param faceIndex The index of the face to bind the target texture to.
  16397. * @param postProcesses The array of post processes to render.
  16398. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16399. * @hidden
  16400. */
  16401. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16402. /**
  16403. * Disposes of the post process manager.
  16404. */
  16405. dispose(): void;
  16406. }
  16407. }
  16408. declare module "babylonjs/Misc/gradients" {
  16409. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16410. /** Interface used by value gradients (color, factor, ...) */
  16411. export interface IValueGradient {
  16412. /**
  16413. * Gets or sets the gradient value (between 0 and 1)
  16414. */
  16415. gradient: number;
  16416. }
  16417. /** Class used to store color4 gradient */
  16418. export class ColorGradient implements IValueGradient {
  16419. /**
  16420. * Gets or sets the gradient value (between 0 and 1)
  16421. */
  16422. gradient: number;
  16423. /**
  16424. * Gets or sets first associated color
  16425. */
  16426. color1: Color4;
  16427. /**
  16428. * Gets or sets second associated color
  16429. */
  16430. color2?: Color4;
  16431. /**
  16432. * Will get a color picked randomly between color1 and color2.
  16433. * If color2 is undefined then color1 will be used
  16434. * @param result defines the target Color4 to store the result in
  16435. */
  16436. getColorToRef(result: Color4): void;
  16437. }
  16438. /** Class used to store color 3 gradient */
  16439. export class Color3Gradient implements IValueGradient {
  16440. /**
  16441. * Gets or sets the gradient value (between 0 and 1)
  16442. */
  16443. gradient: number;
  16444. /**
  16445. * Gets or sets the associated color
  16446. */
  16447. color: Color3;
  16448. }
  16449. /** Class used to store factor gradient */
  16450. export class FactorGradient implements IValueGradient {
  16451. /**
  16452. * Gets or sets the gradient value (between 0 and 1)
  16453. */
  16454. gradient: number;
  16455. /**
  16456. * Gets or sets first associated factor
  16457. */
  16458. factor1: number;
  16459. /**
  16460. * Gets or sets second associated factor
  16461. */
  16462. factor2?: number;
  16463. /**
  16464. * Will get a number picked randomly between factor1 and factor2.
  16465. * If factor2 is undefined then factor1 will be used
  16466. * @returns the picked number
  16467. */
  16468. getFactor(): number;
  16469. }
  16470. /**
  16471. * Helper used to simplify some generic gradient tasks
  16472. */
  16473. export class GradientHelper {
  16474. /**
  16475. * Gets the current gradient from an array of IValueGradient
  16476. * @param ratio defines the current ratio to get
  16477. * @param gradients defines the array of IValueGradient
  16478. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16479. */
  16480. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16481. }
  16482. }
  16483. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16485. import { Nullable } from "babylonjs/types";
  16486. module "babylonjs/Engines/thinEngine" {
  16487. interface ThinEngine {
  16488. /**
  16489. * Creates a dynamic texture
  16490. * @param width defines the width of the texture
  16491. * @param height defines the height of the texture
  16492. * @param generateMipMaps defines if the engine should generate the mip levels
  16493. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16494. * @returns the dynamic texture inside an InternalTexture
  16495. */
  16496. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16497. /**
  16498. * Update the content of a dynamic texture
  16499. * @param texture defines the texture to update
  16500. * @param canvas defines the canvas containing the source
  16501. * @param invertY defines if data must be stored with Y axis inverted
  16502. * @param premulAlpha defines if alpha is stored as premultiplied
  16503. * @param format defines the format of the data
  16504. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16505. */
  16506. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16507. }
  16508. }
  16509. }
  16510. declare module "babylonjs/Misc/canvasGenerator" {
  16511. /**
  16512. * Helper class used to generate a canvas to manipulate images
  16513. */
  16514. export class CanvasGenerator {
  16515. /**
  16516. * Create a new canvas (or offscreen canvas depending on the context)
  16517. * @param width defines the expected width
  16518. * @param height defines the expected height
  16519. * @return a new canvas or offscreen canvas
  16520. */
  16521. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16522. }
  16523. }
  16524. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16525. import { Scene } from "babylonjs/scene";
  16526. import { Texture } from "babylonjs/Materials/Textures/texture";
  16527. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16528. /**
  16529. * A class extending Texture allowing drawing on a texture
  16530. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16531. */
  16532. export class DynamicTexture extends Texture {
  16533. private _generateMipMaps;
  16534. private _canvas;
  16535. private _context;
  16536. private _engine;
  16537. /**
  16538. * Creates a DynamicTexture
  16539. * @param name defines the name of the texture
  16540. * @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
  16541. * @param scene defines the scene where you want the texture
  16542. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16543. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16544. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16545. */
  16546. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16547. /**
  16548. * Get the current class name of the texture useful for serialization or dynamic coding.
  16549. * @returns "DynamicTexture"
  16550. */
  16551. getClassName(): string;
  16552. /**
  16553. * Gets the current state of canRescale
  16554. */
  16555. readonly canRescale: boolean;
  16556. private _recreate;
  16557. /**
  16558. * Scales the texture
  16559. * @param ratio the scale factor to apply to both width and height
  16560. */
  16561. scale(ratio: number): void;
  16562. /**
  16563. * Resizes the texture
  16564. * @param width the new width
  16565. * @param height the new height
  16566. */
  16567. scaleTo(width: number, height: number): void;
  16568. /**
  16569. * Gets the context of the canvas used by the texture
  16570. * @returns the canvas context of the dynamic texture
  16571. */
  16572. getContext(): CanvasRenderingContext2D;
  16573. /**
  16574. * Clears the texture
  16575. */
  16576. clear(): void;
  16577. /**
  16578. * Updates the texture
  16579. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16580. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16581. */
  16582. update(invertY?: boolean, premulAlpha?: boolean): void;
  16583. /**
  16584. * Draws text onto the texture
  16585. * @param text defines the text to be drawn
  16586. * @param x defines the placement of the text from the left
  16587. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16588. * @param font defines the font to be used with font-style, font-size, font-name
  16589. * @param color defines the color used for the text
  16590. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16591. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16592. * @param update defines whether texture is immediately update (default is true)
  16593. */
  16594. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16595. /**
  16596. * Clones the texture
  16597. * @returns the clone of the texture.
  16598. */
  16599. clone(): DynamicTexture;
  16600. /**
  16601. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16602. * @returns a serialized dynamic texture object
  16603. */
  16604. serialize(): any;
  16605. /** @hidden */
  16606. _rebuild(): void;
  16607. }
  16608. }
  16609. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16610. import { Scene } from "babylonjs/scene";
  16611. import { ISceneComponent } from "babylonjs/sceneComponent";
  16612. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16613. module "babylonjs/abstractScene" {
  16614. interface AbstractScene {
  16615. /**
  16616. * The list of procedural textures added to the scene
  16617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16618. */
  16619. proceduralTextures: Array<ProceduralTexture>;
  16620. }
  16621. }
  16622. /**
  16623. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16624. * in a given scene.
  16625. */
  16626. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16627. /**
  16628. * The component name helpfull to identify the component in the list of scene components.
  16629. */
  16630. readonly name: string;
  16631. /**
  16632. * The scene the component belongs to.
  16633. */
  16634. scene: Scene;
  16635. /**
  16636. * Creates a new instance of the component for the given scene
  16637. * @param scene Defines the scene to register the component in
  16638. */
  16639. constructor(scene: Scene);
  16640. /**
  16641. * Registers the component in a given scene
  16642. */
  16643. register(): void;
  16644. /**
  16645. * Rebuilds the elements related to this component in case of
  16646. * context lost for instance.
  16647. */
  16648. rebuild(): void;
  16649. /**
  16650. * Disposes the component and the associated ressources.
  16651. */
  16652. dispose(): void;
  16653. private _beforeClear;
  16654. }
  16655. }
  16656. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16657. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16658. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16659. module "babylonjs/Engines/thinEngine" {
  16660. interface ThinEngine {
  16661. /**
  16662. * Creates a new render target cube texture
  16663. * @param size defines the size of the texture
  16664. * @param options defines the options used to create the texture
  16665. * @returns a new render target cube texture stored in an InternalTexture
  16666. */
  16667. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16668. }
  16669. }
  16670. }
  16671. declare module "babylonjs/Shaders/procedural.vertex" {
  16672. /** @hidden */
  16673. export var proceduralVertexShader: {
  16674. name: string;
  16675. shader: string;
  16676. };
  16677. }
  16678. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16679. import { Observable } from "babylonjs/Misc/observable";
  16680. import { Nullable } from "babylonjs/types";
  16681. import { Scene } from "babylonjs/scene";
  16682. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16683. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16684. import { Effect } from "babylonjs/Materials/effect";
  16685. import { Texture } from "babylonjs/Materials/Textures/texture";
  16686. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16687. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16688. import "babylonjs/Shaders/procedural.vertex";
  16689. /**
  16690. * 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.
  16691. * This is the base class of any Procedural texture and contains most of the shareable code.
  16692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16693. */
  16694. export class ProceduralTexture extends Texture {
  16695. isCube: boolean;
  16696. /**
  16697. * Define if the texture is enabled or not (disabled texture will not render)
  16698. */
  16699. isEnabled: boolean;
  16700. /**
  16701. * Define if the texture must be cleared before rendering (default is true)
  16702. */
  16703. autoClear: boolean;
  16704. /**
  16705. * Callback called when the texture is generated
  16706. */
  16707. onGenerated: () => void;
  16708. /**
  16709. * Event raised when the texture is generated
  16710. */
  16711. onGeneratedObservable: Observable<ProceduralTexture>;
  16712. /** @hidden */
  16713. _generateMipMaps: boolean;
  16714. /** @hidden **/
  16715. _effect: Effect;
  16716. /** @hidden */
  16717. _textures: {
  16718. [key: string]: Texture;
  16719. };
  16720. private _size;
  16721. private _currentRefreshId;
  16722. private _refreshRate;
  16723. private _vertexBuffers;
  16724. private _indexBuffer;
  16725. private _uniforms;
  16726. private _samplers;
  16727. private _fragment;
  16728. private _floats;
  16729. private _ints;
  16730. private _floatsArrays;
  16731. private _colors3;
  16732. private _colors4;
  16733. private _vectors2;
  16734. private _vectors3;
  16735. private _matrices;
  16736. private _fallbackTexture;
  16737. private _fallbackTextureUsed;
  16738. private _engine;
  16739. private _cachedDefines;
  16740. private _contentUpdateId;
  16741. private _contentData;
  16742. /**
  16743. * Instantiates a new procedural texture.
  16744. * 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.
  16745. * This is the base class of any Procedural texture and contains most of the shareable code.
  16746. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16747. * @param name Define the name of the texture
  16748. * @param size Define the size of the texture to create
  16749. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16750. * @param scene Define the scene the texture belongs to
  16751. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16752. * @param generateMipMaps Define if the texture should creates mip maps or not
  16753. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16754. */
  16755. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16756. /**
  16757. * The effect that is created when initializing the post process.
  16758. * @returns The created effect corresponding the the postprocess.
  16759. */
  16760. getEffect(): Effect;
  16761. /**
  16762. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16763. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16764. */
  16765. getContent(): Nullable<ArrayBufferView>;
  16766. private _createIndexBuffer;
  16767. /** @hidden */
  16768. _rebuild(): void;
  16769. /**
  16770. * Resets the texture in order to recreate its associated resources.
  16771. * This can be called in case of context loss
  16772. */
  16773. reset(): void;
  16774. protected _getDefines(): string;
  16775. /**
  16776. * Is the texture ready to be used ? (rendered at least once)
  16777. * @returns true if ready, otherwise, false.
  16778. */
  16779. isReady(): boolean;
  16780. /**
  16781. * Resets the refresh counter of the texture and start bak from scratch.
  16782. * Could be useful to regenerate the texture if it is setup to render only once.
  16783. */
  16784. resetRefreshCounter(): void;
  16785. /**
  16786. * Set the fragment shader to use in order to render the texture.
  16787. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16788. */
  16789. setFragment(fragment: any): void;
  16790. /**
  16791. * Define the refresh rate of the texture or the rendering frequency.
  16792. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16793. */
  16794. refreshRate: number;
  16795. /** @hidden */
  16796. _shouldRender(): boolean;
  16797. /**
  16798. * Get the size the texture is rendering at.
  16799. * @returns the size (texture is always squared)
  16800. */
  16801. getRenderSize(): number;
  16802. /**
  16803. * Resize the texture to new value.
  16804. * @param size Define the new size the texture should have
  16805. * @param generateMipMaps Define whether the new texture should create mip maps
  16806. */
  16807. resize(size: number, generateMipMaps: boolean): void;
  16808. private _checkUniform;
  16809. /**
  16810. * Set a texture in the shader program used to render.
  16811. * @param name Define the name of the uniform samplers as defined in the shader
  16812. * @param texture Define the texture to bind to this sampler
  16813. * @return the texture itself allowing "fluent" like uniform updates
  16814. */
  16815. setTexture(name: string, texture: Texture): ProceduralTexture;
  16816. /**
  16817. * Set a float in the shader.
  16818. * @param name Define the name of the uniform as defined in the shader
  16819. * @param value Define the value to give to the uniform
  16820. * @return the texture itself allowing "fluent" like uniform updates
  16821. */
  16822. setFloat(name: string, value: number): ProceduralTexture;
  16823. /**
  16824. * Set a int in the shader.
  16825. * @param name Define the name of the uniform as defined in the shader
  16826. * @param value Define the value to give to the uniform
  16827. * @return the texture itself allowing "fluent" like uniform updates
  16828. */
  16829. setInt(name: string, value: number): ProceduralTexture;
  16830. /**
  16831. * Set an array of floats in the shader.
  16832. * @param name Define the name of the uniform as defined in the shader
  16833. * @param value Define the value to give to the uniform
  16834. * @return the texture itself allowing "fluent" like uniform updates
  16835. */
  16836. setFloats(name: string, value: number[]): ProceduralTexture;
  16837. /**
  16838. * Set a vec3 in the shader from a Color3.
  16839. * @param name Define the name of the uniform as defined in the shader
  16840. * @param value Define the value to give to the uniform
  16841. * @return the texture itself allowing "fluent" like uniform updates
  16842. */
  16843. setColor3(name: string, value: Color3): ProceduralTexture;
  16844. /**
  16845. * Set a vec4 in the shader from a Color4.
  16846. * @param name Define the name of the uniform as defined in the shader
  16847. * @param value Define the value to give to the uniform
  16848. * @return the texture itself allowing "fluent" like uniform updates
  16849. */
  16850. setColor4(name: string, value: Color4): ProceduralTexture;
  16851. /**
  16852. * Set a vec2 in the shader from a Vector2.
  16853. * @param name Define the name of the uniform as defined in the shader
  16854. * @param value Define the value to give to the uniform
  16855. * @return the texture itself allowing "fluent" like uniform updates
  16856. */
  16857. setVector2(name: string, value: Vector2): ProceduralTexture;
  16858. /**
  16859. * Set a vec3 in the shader from a Vector3.
  16860. * @param name Define the name of the uniform as defined in the shader
  16861. * @param value Define the value to give to the uniform
  16862. * @return the texture itself allowing "fluent" like uniform updates
  16863. */
  16864. setVector3(name: string, value: Vector3): ProceduralTexture;
  16865. /**
  16866. * Set a mat4 in the shader from a MAtrix.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the texture itself allowing "fluent" like uniform updates
  16870. */
  16871. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16872. /**
  16873. * Render the texture to its associated render target.
  16874. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16875. */
  16876. render(useCameraPostProcess?: boolean): void;
  16877. /**
  16878. * Clone the texture.
  16879. * @returns the cloned texture
  16880. */
  16881. clone(): ProceduralTexture;
  16882. /**
  16883. * Dispose the texture and release its asoociated resources.
  16884. */
  16885. dispose(): void;
  16886. }
  16887. }
  16888. declare module "babylonjs/Particles/baseParticleSystem" {
  16889. import { Nullable } from "babylonjs/types";
  16890. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16892. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16893. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16894. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16895. import { Scene } from "babylonjs/scene";
  16896. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16897. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16898. import { Texture } from "babylonjs/Materials/Textures/texture";
  16899. import { Color4 } from "babylonjs/Maths/math.color";
  16900. import { Animation } from "babylonjs/Animations/animation";
  16901. /**
  16902. * This represents the base class for particle system in Babylon.
  16903. * 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.
  16904. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16905. * @example https://doc.babylonjs.com/babylon101/particles
  16906. */
  16907. export class BaseParticleSystem {
  16908. /**
  16909. * Source color is added to the destination color without alpha affecting the result
  16910. */
  16911. static BLENDMODE_ONEONE: number;
  16912. /**
  16913. * Blend current color and particle color using particle’s alpha
  16914. */
  16915. static BLENDMODE_STANDARD: number;
  16916. /**
  16917. * Add current color and particle color multiplied by particle’s alpha
  16918. */
  16919. static BLENDMODE_ADD: number;
  16920. /**
  16921. * Multiply current color with particle color
  16922. */
  16923. static BLENDMODE_MULTIPLY: number;
  16924. /**
  16925. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16926. */
  16927. static BLENDMODE_MULTIPLYADD: number;
  16928. /**
  16929. * List of animations used by the particle system.
  16930. */
  16931. animations: Animation[];
  16932. /**
  16933. * The id of the Particle system.
  16934. */
  16935. id: string;
  16936. /**
  16937. * The friendly name of the Particle system.
  16938. */
  16939. name: string;
  16940. /**
  16941. * The rendering group used by the Particle system to chose when to render.
  16942. */
  16943. renderingGroupId: number;
  16944. /**
  16945. * The emitter represents the Mesh or position we are attaching the particle system to.
  16946. */
  16947. emitter: Nullable<AbstractMesh | Vector3>;
  16948. /**
  16949. * The maximum number of particles to emit per frame
  16950. */
  16951. emitRate: number;
  16952. /**
  16953. * If you want to launch only a few particles at once, that can be done, as well.
  16954. */
  16955. manualEmitCount: number;
  16956. /**
  16957. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16958. */
  16959. updateSpeed: number;
  16960. /**
  16961. * The amount of time the particle system is running (depends of the overall update speed).
  16962. */
  16963. targetStopDuration: number;
  16964. /**
  16965. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16966. */
  16967. disposeOnStop: boolean;
  16968. /**
  16969. * Minimum power of emitting particles.
  16970. */
  16971. minEmitPower: number;
  16972. /**
  16973. * Maximum power of emitting particles.
  16974. */
  16975. maxEmitPower: number;
  16976. /**
  16977. * Minimum life time of emitting particles.
  16978. */
  16979. minLifeTime: number;
  16980. /**
  16981. * Maximum life time of emitting particles.
  16982. */
  16983. maxLifeTime: number;
  16984. /**
  16985. * Minimum Size of emitting particles.
  16986. */
  16987. minSize: number;
  16988. /**
  16989. * Maximum Size of emitting particles.
  16990. */
  16991. maxSize: number;
  16992. /**
  16993. * Minimum scale of emitting particles on X axis.
  16994. */
  16995. minScaleX: number;
  16996. /**
  16997. * Maximum scale of emitting particles on X axis.
  16998. */
  16999. maxScaleX: number;
  17000. /**
  17001. * Minimum scale of emitting particles on Y axis.
  17002. */
  17003. minScaleY: number;
  17004. /**
  17005. * Maximum scale of emitting particles on Y axis.
  17006. */
  17007. maxScaleY: number;
  17008. /**
  17009. * Gets or sets the minimal initial rotation in radians.
  17010. */
  17011. minInitialRotation: number;
  17012. /**
  17013. * Gets or sets the maximal initial rotation in radians.
  17014. */
  17015. maxInitialRotation: number;
  17016. /**
  17017. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17018. */
  17019. minAngularSpeed: number;
  17020. /**
  17021. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17022. */
  17023. maxAngularSpeed: number;
  17024. /**
  17025. * The texture used to render each particle. (this can be a spritesheet)
  17026. */
  17027. particleTexture: Nullable<Texture>;
  17028. /**
  17029. * The layer mask we are rendering the particles through.
  17030. */
  17031. layerMask: number;
  17032. /**
  17033. * This can help using your own shader to render the particle system.
  17034. * The according effect will be created
  17035. */
  17036. customShader: any;
  17037. /**
  17038. * By default particle system starts as soon as they are created. This prevents the
  17039. * automatic start to happen and let you decide when to start emitting particles.
  17040. */
  17041. preventAutoStart: boolean;
  17042. private _noiseTexture;
  17043. /**
  17044. * Gets or sets a texture used to add random noise to particle positions
  17045. */
  17046. noiseTexture: Nullable<ProceduralTexture>;
  17047. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17048. noiseStrength: Vector3;
  17049. /**
  17050. * Callback triggered when the particle animation is ending.
  17051. */
  17052. onAnimationEnd: Nullable<() => void>;
  17053. /**
  17054. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17055. */
  17056. blendMode: number;
  17057. /**
  17058. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17059. * to override the particles.
  17060. */
  17061. forceDepthWrite: boolean;
  17062. /** 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 */
  17063. preWarmCycles: number;
  17064. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17065. preWarmStepOffset: number;
  17066. /**
  17067. * 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)
  17068. */
  17069. spriteCellChangeSpeed: number;
  17070. /**
  17071. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17072. */
  17073. startSpriteCellID: number;
  17074. /**
  17075. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17076. */
  17077. endSpriteCellID: number;
  17078. /**
  17079. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17080. */
  17081. spriteCellWidth: number;
  17082. /**
  17083. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17084. */
  17085. spriteCellHeight: number;
  17086. /**
  17087. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17088. */
  17089. spriteRandomStartCell: boolean;
  17090. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17091. translationPivot: Vector2;
  17092. /** @hidden */
  17093. protected _isAnimationSheetEnabled: boolean;
  17094. /**
  17095. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17096. */
  17097. beginAnimationOnStart: boolean;
  17098. /**
  17099. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17100. */
  17101. beginAnimationFrom: number;
  17102. /**
  17103. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17104. */
  17105. beginAnimationTo: number;
  17106. /**
  17107. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17108. */
  17109. beginAnimationLoop: boolean;
  17110. /**
  17111. * Gets or sets a world offset applied to all particles
  17112. */
  17113. worldOffset: Vector3;
  17114. /**
  17115. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17116. */
  17117. isAnimationSheetEnabled: boolean;
  17118. /**
  17119. * Get hosting scene
  17120. * @returns the scene
  17121. */
  17122. getScene(): Scene;
  17123. /**
  17124. * You can use gravity if you want to give an orientation to your particles.
  17125. */
  17126. gravity: Vector3;
  17127. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17128. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17129. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17130. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17131. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17132. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17133. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17134. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17135. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17136. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17137. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17138. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17139. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17140. /**
  17141. * Defines the delay in milliseconds before starting the system (0 by default)
  17142. */
  17143. startDelay: number;
  17144. /**
  17145. * Gets the current list of drag gradients.
  17146. * You must use addDragGradient and removeDragGradient to udpate this list
  17147. * @returns the list of drag gradients
  17148. */
  17149. getDragGradients(): Nullable<Array<FactorGradient>>;
  17150. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17151. limitVelocityDamping: number;
  17152. /**
  17153. * Gets the current list of limit velocity gradients.
  17154. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17155. * @returns the list of limit velocity gradients
  17156. */
  17157. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17158. /**
  17159. * Gets the current list of color gradients.
  17160. * You must use addColorGradient and removeColorGradient to udpate this list
  17161. * @returns the list of color gradients
  17162. */
  17163. getColorGradients(): Nullable<Array<ColorGradient>>;
  17164. /**
  17165. * Gets the current list of size gradients.
  17166. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17167. * @returns the list of size gradients
  17168. */
  17169. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17170. /**
  17171. * Gets the current list of color remap gradients.
  17172. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17173. * @returns the list of color remap gradients
  17174. */
  17175. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17176. /**
  17177. * Gets the current list of alpha remap gradients.
  17178. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17179. * @returns the list of alpha remap gradients
  17180. */
  17181. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17182. /**
  17183. * Gets the current list of life time gradients.
  17184. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17185. * @returns the list of life time gradients
  17186. */
  17187. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17188. /**
  17189. * Gets the current list of angular speed gradients.
  17190. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17191. * @returns the list of angular speed gradients
  17192. */
  17193. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17194. /**
  17195. * Gets the current list of velocity gradients.
  17196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17197. * @returns the list of velocity gradients
  17198. */
  17199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17200. /**
  17201. * Gets the current list of start size gradients.
  17202. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17203. * @returns the list of start size gradients
  17204. */
  17205. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17206. /**
  17207. * Gets the current list of emit rate gradients.
  17208. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17209. * @returns the list of emit rate gradients
  17210. */
  17211. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17212. /**
  17213. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17214. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17215. */
  17216. direction1: Vector3;
  17217. /**
  17218. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17219. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17220. */
  17221. direction2: Vector3;
  17222. /**
  17223. * 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.
  17224. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17225. */
  17226. minEmitBox: Vector3;
  17227. /**
  17228. * 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.
  17229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17230. */
  17231. maxEmitBox: Vector3;
  17232. /**
  17233. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17234. */
  17235. color1: Color4;
  17236. /**
  17237. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17238. */
  17239. color2: Color4;
  17240. /**
  17241. * Color the particle will have at the end of its lifetime
  17242. */
  17243. colorDead: Color4;
  17244. /**
  17245. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17246. */
  17247. textureMask: Color4;
  17248. /**
  17249. * The particle emitter type defines the emitter used by the particle system.
  17250. * It can be for example box, sphere, or cone...
  17251. */
  17252. particleEmitterType: IParticleEmitterType;
  17253. /** @hidden */
  17254. _isSubEmitter: boolean;
  17255. /**
  17256. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17257. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17258. */
  17259. billboardMode: number;
  17260. protected _isBillboardBased: boolean;
  17261. /**
  17262. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17263. */
  17264. isBillboardBased: boolean;
  17265. /**
  17266. * The scene the particle system belongs to.
  17267. */
  17268. protected _scene: Scene;
  17269. /**
  17270. * Local cache of defines for image processing.
  17271. */
  17272. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17273. /**
  17274. * Default configuration related to image processing available in the standard Material.
  17275. */
  17276. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17277. /**
  17278. * Gets the image processing configuration used either in this material.
  17279. */
  17280. /**
  17281. * Sets the Default image processing configuration used either in the this material.
  17282. *
  17283. * If sets to null, the scene one is in use.
  17284. */
  17285. imageProcessingConfiguration: ImageProcessingConfiguration;
  17286. /**
  17287. * Attaches a new image processing configuration to the Standard Material.
  17288. * @param configuration
  17289. */
  17290. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17291. /** @hidden */
  17292. protected _reset(): void;
  17293. /** @hidden */
  17294. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17295. /**
  17296. * Instantiates a particle system.
  17297. * 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.
  17298. * @param name The name of the particle system
  17299. */
  17300. constructor(name: string);
  17301. /**
  17302. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17303. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17304. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17305. * @returns the emitter
  17306. */
  17307. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17308. /**
  17309. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17310. * @param radius The radius of the hemisphere to emit from
  17311. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17312. * @returns the emitter
  17313. */
  17314. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17315. /**
  17316. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17317. * @param radius The radius of the sphere to emit from
  17318. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17319. * @returns the emitter
  17320. */
  17321. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17322. /**
  17323. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17324. * @param radius The radius of the sphere to emit from
  17325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17327. * @returns the emitter
  17328. */
  17329. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17330. /**
  17331. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17332. * @param radius The radius of the emission cylinder
  17333. * @param height The height of the emission cylinder
  17334. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17335. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17336. * @returns the emitter
  17337. */
  17338. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17339. /**
  17340. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17341. * @param radius The radius of the cylinder to emit from
  17342. * @param height The height of the emission cylinder
  17343. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17344. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17345. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17346. * @returns the emitter
  17347. */
  17348. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17349. /**
  17350. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17351. * @param radius The radius of the cone to emit from
  17352. * @param angle The base angle of the cone
  17353. * @returns the emitter
  17354. */
  17355. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17356. /**
  17357. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17360. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17361. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17362. * @returns the emitter
  17363. */
  17364. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17365. }
  17366. }
  17367. declare module "babylonjs/Particles/subEmitter" {
  17368. import { Scene } from "babylonjs/scene";
  17369. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17370. /**
  17371. * Type of sub emitter
  17372. */
  17373. export enum SubEmitterType {
  17374. /**
  17375. * Attached to the particle over it's lifetime
  17376. */
  17377. ATTACHED = 0,
  17378. /**
  17379. * Created when the particle dies
  17380. */
  17381. END = 1
  17382. }
  17383. /**
  17384. * Sub emitter class used to emit particles from an existing particle
  17385. */
  17386. export class SubEmitter {
  17387. /**
  17388. * the particle system to be used by the sub emitter
  17389. */
  17390. particleSystem: ParticleSystem;
  17391. /**
  17392. * Type of the submitter (Default: END)
  17393. */
  17394. type: SubEmitterType;
  17395. /**
  17396. * 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)
  17397. * Note: This only is supported when using an emitter of type Mesh
  17398. */
  17399. inheritDirection: boolean;
  17400. /**
  17401. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17402. */
  17403. inheritedVelocityAmount: number;
  17404. /**
  17405. * Creates a sub emitter
  17406. * @param particleSystem the particle system to be used by the sub emitter
  17407. */
  17408. constructor(
  17409. /**
  17410. * the particle system to be used by the sub emitter
  17411. */
  17412. particleSystem: ParticleSystem);
  17413. /**
  17414. * Clones the sub emitter
  17415. * @returns the cloned sub emitter
  17416. */
  17417. clone(): SubEmitter;
  17418. /**
  17419. * Serialize current object to a JSON object
  17420. * @returns the serialized object
  17421. */
  17422. serialize(): any;
  17423. /** @hidden */
  17424. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17425. /**
  17426. * Creates a new SubEmitter from a serialized JSON version
  17427. * @param serializationObject defines the JSON object to read from
  17428. * @param scene defines the hosting scene
  17429. * @param rootUrl defines the rootUrl for data loading
  17430. * @returns a new SubEmitter
  17431. */
  17432. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17433. /** Release associated resources */
  17434. dispose(): void;
  17435. }
  17436. }
  17437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17438. /** @hidden */
  17439. export var clipPlaneFragmentDeclaration: {
  17440. name: string;
  17441. shader: string;
  17442. };
  17443. }
  17444. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17445. /** @hidden */
  17446. export var imageProcessingDeclaration: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17452. /** @hidden */
  17453. export var imageProcessingFunctions: {
  17454. name: string;
  17455. shader: string;
  17456. };
  17457. }
  17458. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17459. /** @hidden */
  17460. export var clipPlaneFragment: {
  17461. name: string;
  17462. shader: string;
  17463. };
  17464. }
  17465. declare module "babylonjs/Shaders/particles.fragment" {
  17466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17467. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17469. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17470. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17471. /** @hidden */
  17472. export var particlesPixelShader: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17478. /** @hidden */
  17479. export var clipPlaneVertexDeclaration: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17485. /** @hidden */
  17486. export var clipPlaneVertex: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/particles.vertex" {
  17492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17493. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17494. /** @hidden */
  17495. export var particlesVertexShader: {
  17496. name: string;
  17497. shader: string;
  17498. };
  17499. }
  17500. declare module "babylonjs/Particles/particleSystem" {
  17501. import { Nullable } from "babylonjs/types";
  17502. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17503. import { Observable } from "babylonjs/Misc/observable";
  17504. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17505. import { Effect } from "babylonjs/Materials/effect";
  17506. import { Scene, IDisposable } from "babylonjs/scene";
  17507. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17508. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17509. import { Particle } from "babylonjs/Particles/particle";
  17510. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17512. import "babylonjs/Shaders/particles.fragment";
  17513. import "babylonjs/Shaders/particles.vertex";
  17514. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17515. /**
  17516. * This represents a particle system in Babylon.
  17517. * 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.
  17518. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17519. * @example https://doc.babylonjs.com/babylon101/particles
  17520. */
  17521. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17522. /**
  17523. * Billboard mode will only apply to Y axis
  17524. */
  17525. static readonly BILLBOARDMODE_Y: number;
  17526. /**
  17527. * Billboard mode will apply to all axes
  17528. */
  17529. static readonly BILLBOARDMODE_ALL: number;
  17530. /**
  17531. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17532. */
  17533. static readonly BILLBOARDMODE_STRETCHED: number;
  17534. /**
  17535. * This function can be defined to provide custom update for active particles.
  17536. * This function will be called instead of regular update (age, position, color, etc.).
  17537. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17538. */
  17539. updateFunction: (particles: Particle[]) => void;
  17540. private _emitterWorldMatrix;
  17541. /**
  17542. * This function can be defined to specify initial direction for every new particle.
  17543. * It by default use the emitterType defined function
  17544. */
  17545. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17546. /**
  17547. * This function can be defined to specify initial position for every new particle.
  17548. * It by default use the emitterType defined function
  17549. */
  17550. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17551. /**
  17552. * @hidden
  17553. */
  17554. _inheritedVelocityOffset: Vector3;
  17555. /**
  17556. * An event triggered when the system is disposed
  17557. */
  17558. onDisposeObservable: Observable<ParticleSystem>;
  17559. private _onDisposeObserver;
  17560. /**
  17561. * Sets a callback that will be triggered when the system is disposed
  17562. */
  17563. onDispose: () => void;
  17564. private _particles;
  17565. private _epsilon;
  17566. private _capacity;
  17567. private _stockParticles;
  17568. private _newPartsExcess;
  17569. private _vertexData;
  17570. private _vertexBuffer;
  17571. private _vertexBuffers;
  17572. private _spriteBuffer;
  17573. private _indexBuffer;
  17574. private _effect;
  17575. private _customEffect;
  17576. private _cachedDefines;
  17577. private _scaledColorStep;
  17578. private _colorDiff;
  17579. private _scaledDirection;
  17580. private _scaledGravity;
  17581. private _currentRenderId;
  17582. private _alive;
  17583. private _useInstancing;
  17584. private _started;
  17585. private _stopped;
  17586. private _actualFrame;
  17587. private _scaledUpdateSpeed;
  17588. private _vertexBufferSize;
  17589. /** @hidden */
  17590. _currentEmitRateGradient: Nullable<FactorGradient>;
  17591. /** @hidden */
  17592. _currentEmitRate1: number;
  17593. /** @hidden */
  17594. _currentEmitRate2: number;
  17595. /** @hidden */
  17596. _currentStartSizeGradient: Nullable<FactorGradient>;
  17597. /** @hidden */
  17598. _currentStartSize1: number;
  17599. /** @hidden */
  17600. _currentStartSize2: number;
  17601. private readonly _rawTextureWidth;
  17602. private _rampGradientsTexture;
  17603. private _useRampGradients;
  17604. /** Gets or sets a boolean indicating that ramp gradients must be used
  17605. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17606. */
  17607. useRampGradients: boolean;
  17608. /**
  17609. * 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.
  17610. * 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: [])
  17611. */
  17612. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17613. private _subEmitters;
  17614. /**
  17615. * @hidden
  17616. * If the particle systems emitter should be disposed when the particle system is disposed
  17617. */
  17618. _disposeEmitterOnDispose: boolean;
  17619. /**
  17620. * The current active Sub-systems, this property is used by the root particle system only.
  17621. */
  17622. activeSubSystems: Array<ParticleSystem>;
  17623. private _rootParticleSystem;
  17624. /**
  17625. * Gets the current list of active particles
  17626. */
  17627. readonly particles: Particle[];
  17628. /**
  17629. * Returns the string "ParticleSystem"
  17630. * @returns a string containing the class name
  17631. */
  17632. getClassName(): string;
  17633. /**
  17634. * Instantiates a particle system.
  17635. * 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.
  17636. * @param name The name of the particle system
  17637. * @param capacity The max number of particles alive at the same time
  17638. * @param scene The scene the particle system belongs to
  17639. * @param customEffect a custom effect used to change the way particles are rendered by default
  17640. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17641. * @param epsilon Offset used to render the particles
  17642. */
  17643. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17644. private _addFactorGradient;
  17645. private _removeFactorGradient;
  17646. /**
  17647. * Adds a new life time gradient
  17648. * @param gradient defines the gradient to use (between 0 and 1)
  17649. * @param factor defines the life time factor to affect to the specified gradient
  17650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17651. * @returns the current particle system
  17652. */
  17653. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17654. /**
  17655. * Remove a specific life time gradient
  17656. * @param gradient defines the gradient to remove
  17657. * @returns the current particle system
  17658. */
  17659. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17660. /**
  17661. * Adds a new size gradient
  17662. * @param gradient defines the gradient to use (between 0 and 1)
  17663. * @param factor defines the size factor to affect to the specified gradient
  17664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17665. * @returns the current particle system
  17666. */
  17667. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17668. /**
  17669. * Remove a specific size gradient
  17670. * @param gradient defines the gradient to remove
  17671. * @returns the current particle system
  17672. */
  17673. removeSizeGradient(gradient: number): IParticleSystem;
  17674. /**
  17675. * Adds a new color remap gradient
  17676. * @param gradient defines the gradient to use (between 0 and 1)
  17677. * @param min defines the color remap minimal range
  17678. * @param max defines the color remap maximal range
  17679. * @returns the current particle system
  17680. */
  17681. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17682. /**
  17683. * Remove a specific color remap gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns the current particle system
  17686. */
  17687. removeColorRemapGradient(gradient: number): IParticleSystem;
  17688. /**
  17689. * Adds a new alpha remap gradient
  17690. * @param gradient defines the gradient to use (between 0 and 1)
  17691. * @param min defines the alpha remap minimal range
  17692. * @param max defines the alpha remap maximal range
  17693. * @returns the current particle system
  17694. */
  17695. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17696. /**
  17697. * Remove a specific alpha remap gradient
  17698. * @param gradient defines the gradient to remove
  17699. * @returns the current particle system
  17700. */
  17701. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17702. /**
  17703. * Adds a new angular speed gradient
  17704. * @param gradient defines the gradient to use (between 0 and 1)
  17705. * @param factor defines the angular speed to affect to the specified gradient
  17706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17707. * @returns the current particle system
  17708. */
  17709. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17710. /**
  17711. * Remove a specific angular speed gradient
  17712. * @param gradient defines the gradient to remove
  17713. * @returns the current particle system
  17714. */
  17715. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17716. /**
  17717. * Adds a new velocity gradient
  17718. * @param gradient defines the gradient to use (between 0 and 1)
  17719. * @param factor defines the velocity to affect to the specified gradient
  17720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17721. * @returns the current particle system
  17722. */
  17723. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17724. /**
  17725. * Remove a specific velocity gradient
  17726. * @param gradient defines the gradient to remove
  17727. * @returns the current particle system
  17728. */
  17729. removeVelocityGradient(gradient: number): IParticleSystem;
  17730. /**
  17731. * Adds a new limit velocity gradient
  17732. * @param gradient defines the gradient to use (between 0 and 1)
  17733. * @param factor defines the limit velocity value to affect to the specified gradient
  17734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17735. * @returns the current particle system
  17736. */
  17737. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17738. /**
  17739. * Remove a specific limit velocity gradient
  17740. * @param gradient defines the gradient to remove
  17741. * @returns the current particle system
  17742. */
  17743. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17744. /**
  17745. * Adds a new drag gradient
  17746. * @param gradient defines the gradient to use (between 0 and 1)
  17747. * @param factor defines the drag value to affect to the specified gradient
  17748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17749. * @returns the current particle system
  17750. */
  17751. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17752. /**
  17753. * Remove a specific drag gradient
  17754. * @param gradient defines the gradient to remove
  17755. * @returns the current particle system
  17756. */
  17757. removeDragGradient(gradient: number): IParticleSystem;
  17758. /**
  17759. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17760. * @param gradient defines the gradient to use (between 0 and 1)
  17761. * @param factor defines the emit rate value to affect to the specified gradient
  17762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17763. * @returns the current particle system
  17764. */
  17765. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17766. /**
  17767. * Remove a specific emit rate gradient
  17768. * @param gradient defines the gradient to remove
  17769. * @returns the current particle system
  17770. */
  17771. removeEmitRateGradient(gradient: number): IParticleSystem;
  17772. /**
  17773. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17774. * @param gradient defines the gradient to use (between 0 and 1)
  17775. * @param factor defines the start size value to affect to the specified gradient
  17776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17777. * @returns the current particle system
  17778. */
  17779. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17780. /**
  17781. * Remove a specific start size gradient
  17782. * @param gradient defines the gradient to remove
  17783. * @returns the current particle system
  17784. */
  17785. removeStartSizeGradient(gradient: number): IParticleSystem;
  17786. private _createRampGradientTexture;
  17787. /**
  17788. * Gets the current list of ramp gradients.
  17789. * You must use addRampGradient and removeRampGradient to udpate this list
  17790. * @returns the list of ramp gradients
  17791. */
  17792. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17793. /**
  17794. * Adds a new ramp gradient used to remap particle colors
  17795. * @param gradient defines the gradient to use (between 0 and 1)
  17796. * @param color defines the color to affect to the specified gradient
  17797. * @returns the current particle system
  17798. */
  17799. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17800. /**
  17801. * Remove a specific ramp gradient
  17802. * @param gradient defines the gradient to remove
  17803. * @returns the current particle system
  17804. */
  17805. removeRampGradient(gradient: number): ParticleSystem;
  17806. /**
  17807. * Adds a new color gradient
  17808. * @param gradient defines the gradient to use (between 0 and 1)
  17809. * @param color1 defines the color to affect to the specified gradient
  17810. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17811. * @returns this particle system
  17812. */
  17813. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17814. /**
  17815. * Remove a specific color gradient
  17816. * @param gradient defines the gradient to remove
  17817. * @returns this particle system
  17818. */
  17819. removeColorGradient(gradient: number): IParticleSystem;
  17820. private _fetchR;
  17821. protected _reset(): void;
  17822. private _resetEffect;
  17823. private _createVertexBuffers;
  17824. private _createIndexBuffer;
  17825. /**
  17826. * Gets the maximum number of particles active at the same time.
  17827. * @returns The max number of active particles.
  17828. */
  17829. getCapacity(): number;
  17830. /**
  17831. * Gets whether there are still active particles in the system.
  17832. * @returns True if it is alive, otherwise false.
  17833. */
  17834. isAlive(): boolean;
  17835. /**
  17836. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17837. * @returns True if it has been started, otherwise false.
  17838. */
  17839. isStarted(): boolean;
  17840. private _prepareSubEmitterInternalArray;
  17841. /**
  17842. * Starts the particle system and begins to emit
  17843. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17844. */
  17845. start(delay?: number): void;
  17846. /**
  17847. * Stops the particle system.
  17848. * @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.
  17849. */
  17850. stop(stopSubEmitters?: boolean): void;
  17851. /**
  17852. * Remove all active particles
  17853. */
  17854. reset(): void;
  17855. /**
  17856. * @hidden (for internal use only)
  17857. */
  17858. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17859. /**
  17860. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17861. * Its lifetime will start back at 0.
  17862. */
  17863. recycleParticle: (particle: Particle) => void;
  17864. private _stopSubEmitters;
  17865. private _createParticle;
  17866. private _removeFromRoot;
  17867. private _emitFromParticle;
  17868. private _update;
  17869. /** @hidden */
  17870. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17871. /** @hidden */
  17872. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17873. /** @hidden */
  17874. private _getEffect;
  17875. /**
  17876. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17877. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17878. */
  17879. animate(preWarmOnly?: boolean): void;
  17880. private _appendParticleVertices;
  17881. /**
  17882. * Rebuilds the particle system.
  17883. */
  17884. rebuild(): void;
  17885. /**
  17886. * Is this system ready to be used/rendered
  17887. * @return true if the system is ready
  17888. */
  17889. isReady(): boolean;
  17890. private _render;
  17891. /**
  17892. * Renders the particle system in its current state.
  17893. * @returns the current number of particles
  17894. */
  17895. render(): number;
  17896. /**
  17897. * Disposes the particle system and free the associated resources
  17898. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17899. */
  17900. dispose(disposeTexture?: boolean): void;
  17901. /**
  17902. * Clones the particle system.
  17903. * @param name The name of the cloned object
  17904. * @param newEmitter The new emitter to use
  17905. * @returns the cloned particle system
  17906. */
  17907. clone(name: string, newEmitter: any): ParticleSystem;
  17908. /**
  17909. * Serializes the particle system to a JSON object.
  17910. * @returns the JSON object
  17911. */
  17912. serialize(): any;
  17913. /** @hidden */
  17914. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17915. /** @hidden */
  17916. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17917. /**
  17918. * Parses a JSON object to create a particle system.
  17919. * @param parsedParticleSystem The JSON object to parse
  17920. * @param scene The scene to create the particle system in
  17921. * @param rootUrl The root url to use to load external dependencies like texture
  17922. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17923. * @returns the Parsed particle system
  17924. */
  17925. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17926. }
  17927. }
  17928. declare module "babylonjs/Particles/particle" {
  17929. import { Nullable } from "babylonjs/types";
  17930. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17931. import { Color4 } from "babylonjs/Maths/math.color";
  17932. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17933. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17934. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17935. /**
  17936. * A particle represents one of the element emitted by a particle system.
  17937. * This is mainly define by its coordinates, direction, velocity and age.
  17938. */
  17939. export class Particle {
  17940. /**
  17941. * The particle system the particle belongs to.
  17942. */
  17943. particleSystem: ParticleSystem;
  17944. private static _Count;
  17945. /**
  17946. * Unique ID of the particle
  17947. */
  17948. id: number;
  17949. /**
  17950. * The world position of the particle in the scene.
  17951. */
  17952. position: Vector3;
  17953. /**
  17954. * The world direction of the particle in the scene.
  17955. */
  17956. direction: Vector3;
  17957. /**
  17958. * The color of the particle.
  17959. */
  17960. color: Color4;
  17961. /**
  17962. * The color change of the particle per step.
  17963. */
  17964. colorStep: Color4;
  17965. /**
  17966. * Defines how long will the life of the particle be.
  17967. */
  17968. lifeTime: number;
  17969. /**
  17970. * The current age of the particle.
  17971. */
  17972. age: number;
  17973. /**
  17974. * The current size of the particle.
  17975. */
  17976. size: number;
  17977. /**
  17978. * The current scale of the particle.
  17979. */
  17980. scale: Vector2;
  17981. /**
  17982. * The current angle of the particle.
  17983. */
  17984. angle: number;
  17985. /**
  17986. * Defines how fast is the angle changing.
  17987. */
  17988. angularSpeed: number;
  17989. /**
  17990. * Defines the cell index used by the particle to be rendered from a sprite.
  17991. */
  17992. cellIndex: number;
  17993. /**
  17994. * The information required to support color remapping
  17995. */
  17996. remapData: Vector4;
  17997. /** @hidden */
  17998. _randomCellOffset?: number;
  17999. /** @hidden */
  18000. _initialDirection: Nullable<Vector3>;
  18001. /** @hidden */
  18002. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18003. /** @hidden */
  18004. _initialStartSpriteCellID: number;
  18005. /** @hidden */
  18006. _initialEndSpriteCellID: number;
  18007. /** @hidden */
  18008. _currentColorGradient: Nullable<ColorGradient>;
  18009. /** @hidden */
  18010. _currentColor1: Color4;
  18011. /** @hidden */
  18012. _currentColor2: Color4;
  18013. /** @hidden */
  18014. _currentSizeGradient: Nullable<FactorGradient>;
  18015. /** @hidden */
  18016. _currentSize1: number;
  18017. /** @hidden */
  18018. _currentSize2: number;
  18019. /** @hidden */
  18020. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18021. /** @hidden */
  18022. _currentAngularSpeed1: number;
  18023. /** @hidden */
  18024. _currentAngularSpeed2: number;
  18025. /** @hidden */
  18026. _currentVelocityGradient: Nullable<FactorGradient>;
  18027. /** @hidden */
  18028. _currentVelocity1: number;
  18029. /** @hidden */
  18030. _currentVelocity2: number;
  18031. /** @hidden */
  18032. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18033. /** @hidden */
  18034. _currentLimitVelocity1: number;
  18035. /** @hidden */
  18036. _currentLimitVelocity2: number;
  18037. /** @hidden */
  18038. _currentDragGradient: Nullable<FactorGradient>;
  18039. /** @hidden */
  18040. _currentDrag1: number;
  18041. /** @hidden */
  18042. _currentDrag2: number;
  18043. /** @hidden */
  18044. _randomNoiseCoordinates1: Vector3;
  18045. /** @hidden */
  18046. _randomNoiseCoordinates2: Vector3;
  18047. /**
  18048. * Creates a new instance Particle
  18049. * @param particleSystem the particle system the particle belongs to
  18050. */
  18051. constructor(
  18052. /**
  18053. * The particle system the particle belongs to.
  18054. */
  18055. particleSystem: ParticleSystem);
  18056. private updateCellInfoFromSystem;
  18057. /**
  18058. * Defines how the sprite cell index is updated for the particle
  18059. */
  18060. updateCellIndex(): void;
  18061. /** @hidden */
  18062. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18063. /** @hidden */
  18064. _inheritParticleInfoToSubEmitters(): void;
  18065. /** @hidden */
  18066. _reset(): void;
  18067. /**
  18068. * Copy the properties of particle to another one.
  18069. * @param other the particle to copy the information to.
  18070. */
  18071. copyTo(other: Particle): void;
  18072. }
  18073. }
  18074. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18075. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18076. import { Effect } from "babylonjs/Materials/effect";
  18077. import { Particle } from "babylonjs/Particles/particle";
  18078. /**
  18079. * Particle emitter represents a volume emitting particles.
  18080. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18081. */
  18082. export interface IParticleEmitterType {
  18083. /**
  18084. * Called by the particle System when the direction is computed for the created particle.
  18085. * @param worldMatrix is the world matrix of the particle system
  18086. * @param directionToUpdate is the direction vector to update with the result
  18087. * @param particle is the particle we are computed the direction for
  18088. */
  18089. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18090. /**
  18091. * Called by the particle System when the position is computed for the created particle.
  18092. * @param worldMatrix is the world matrix of the particle system
  18093. * @param positionToUpdate is the position vector to update with the result
  18094. * @param particle is the particle we are computed the position for
  18095. */
  18096. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18097. /**
  18098. * Clones the current emitter and returns a copy of it
  18099. * @returns the new emitter
  18100. */
  18101. clone(): IParticleEmitterType;
  18102. /**
  18103. * Called by the GPUParticleSystem to setup the update shader
  18104. * @param effect defines the update shader
  18105. */
  18106. applyToShader(effect: Effect): void;
  18107. /**
  18108. * Returns a string to use to update the GPU particles update shader
  18109. * @returns the effect defines string
  18110. */
  18111. getEffectDefines(): string;
  18112. /**
  18113. * Returns a string representing the class name
  18114. * @returns a string containing the class name
  18115. */
  18116. getClassName(): string;
  18117. /**
  18118. * Serializes the particle system to a JSON object.
  18119. * @returns the JSON object
  18120. */
  18121. serialize(): any;
  18122. /**
  18123. * Parse properties from a JSON object
  18124. * @param serializationObject defines the JSON object
  18125. */
  18126. parse(serializationObject: any): void;
  18127. }
  18128. }
  18129. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18130. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18131. import { Effect } from "babylonjs/Materials/effect";
  18132. import { Particle } from "babylonjs/Particles/particle";
  18133. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18134. /**
  18135. * Particle emitter emitting particles from the inside of a box.
  18136. * It emits the particles randomly between 2 given directions.
  18137. */
  18138. export class BoxParticleEmitter implements IParticleEmitterType {
  18139. /**
  18140. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18141. */
  18142. direction1: Vector3;
  18143. /**
  18144. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18145. */
  18146. direction2: Vector3;
  18147. /**
  18148. * 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.
  18149. */
  18150. minEmitBox: Vector3;
  18151. /**
  18152. * 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.
  18153. */
  18154. maxEmitBox: Vector3;
  18155. /**
  18156. * Creates a new instance BoxParticleEmitter
  18157. */
  18158. constructor();
  18159. /**
  18160. * Called by the particle System when the direction is computed for the created particle.
  18161. * @param worldMatrix is the world matrix of the particle system
  18162. * @param directionToUpdate is the direction vector to update with the result
  18163. * @param particle is the particle we are computed the direction for
  18164. */
  18165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18166. /**
  18167. * Called by the particle System when the position is computed for the created particle.
  18168. * @param worldMatrix is the world matrix of the particle system
  18169. * @param positionToUpdate is the position vector to update with the result
  18170. * @param particle is the particle we are computed the position for
  18171. */
  18172. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18173. /**
  18174. * Clones the current emitter and returns a copy of it
  18175. * @returns the new emitter
  18176. */
  18177. clone(): BoxParticleEmitter;
  18178. /**
  18179. * Called by the GPUParticleSystem to setup the update shader
  18180. * @param effect defines the update shader
  18181. */
  18182. applyToShader(effect: Effect): void;
  18183. /**
  18184. * Returns a string to use to update the GPU particles update shader
  18185. * @returns a string containng the defines string
  18186. */
  18187. getEffectDefines(): string;
  18188. /**
  18189. * Returns the string "BoxParticleEmitter"
  18190. * @returns a string containing the class name
  18191. */
  18192. getClassName(): string;
  18193. /**
  18194. * Serializes the particle system to a JSON object.
  18195. * @returns the JSON object
  18196. */
  18197. serialize(): any;
  18198. /**
  18199. * Parse properties from a JSON object
  18200. * @param serializationObject defines the JSON object
  18201. */
  18202. parse(serializationObject: any): void;
  18203. }
  18204. }
  18205. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18206. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18207. import { Effect } from "babylonjs/Materials/effect";
  18208. import { Particle } from "babylonjs/Particles/particle";
  18209. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18210. /**
  18211. * Particle emitter emitting particles from the inside of a cone.
  18212. * It emits the particles alongside the cone volume from the base to the particle.
  18213. * The emission direction might be randomized.
  18214. */
  18215. export class ConeParticleEmitter implements IParticleEmitterType {
  18216. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18217. directionRandomizer: number;
  18218. private _radius;
  18219. private _angle;
  18220. private _height;
  18221. /**
  18222. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18223. */
  18224. radiusRange: number;
  18225. /**
  18226. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18227. */
  18228. heightRange: number;
  18229. /**
  18230. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18231. */
  18232. emitFromSpawnPointOnly: boolean;
  18233. /**
  18234. * Gets or sets the radius of the emission cone
  18235. */
  18236. radius: number;
  18237. /**
  18238. * Gets or sets the angle of the emission cone
  18239. */
  18240. angle: number;
  18241. private _buildHeight;
  18242. /**
  18243. * Creates a new instance ConeParticleEmitter
  18244. * @param radius the radius of the emission cone (1 by default)
  18245. * @param angle the cone base angle (PI by default)
  18246. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18247. */
  18248. constructor(radius?: number, angle?: number,
  18249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18250. directionRandomizer?: number);
  18251. /**
  18252. * Called by the particle System when the direction is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param directionToUpdate is the direction vector to update with the result
  18255. * @param particle is the particle we are computed the direction for
  18256. */
  18257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Called by the particle System when the position is computed for the created particle.
  18260. * @param worldMatrix is the world matrix of the particle system
  18261. * @param positionToUpdate is the position vector to update with the result
  18262. * @param particle is the particle we are computed the position for
  18263. */
  18264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18265. /**
  18266. * Clones the current emitter and returns a copy of it
  18267. * @returns the new emitter
  18268. */
  18269. clone(): ConeParticleEmitter;
  18270. /**
  18271. * Called by the GPUParticleSystem to setup the update shader
  18272. * @param effect defines the update shader
  18273. */
  18274. applyToShader(effect: Effect): void;
  18275. /**
  18276. * Returns a string to use to update the GPU particles update shader
  18277. * @returns a string containng the defines string
  18278. */
  18279. getEffectDefines(): string;
  18280. /**
  18281. * Returns the string "ConeParticleEmitter"
  18282. * @returns a string containing the class name
  18283. */
  18284. getClassName(): string;
  18285. /**
  18286. * Serializes the particle system to a JSON object.
  18287. * @returns the JSON object
  18288. */
  18289. serialize(): any;
  18290. /**
  18291. * Parse properties from a JSON object
  18292. * @param serializationObject defines the JSON object
  18293. */
  18294. parse(serializationObject: any): void;
  18295. }
  18296. }
  18297. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18298. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18299. import { Effect } from "babylonjs/Materials/effect";
  18300. import { Particle } from "babylonjs/Particles/particle";
  18301. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18302. /**
  18303. * Particle emitter emitting particles from the inside of a cylinder.
  18304. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18305. */
  18306. export class CylinderParticleEmitter implements IParticleEmitterType {
  18307. /**
  18308. * The radius of the emission cylinder.
  18309. */
  18310. radius: number;
  18311. /**
  18312. * The height of the emission cylinder.
  18313. */
  18314. height: number;
  18315. /**
  18316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18317. */
  18318. radiusRange: number;
  18319. /**
  18320. * How much to randomize the particle direction [0-1].
  18321. */
  18322. directionRandomizer: number;
  18323. /**
  18324. * Creates a new instance CylinderParticleEmitter
  18325. * @param radius the radius of the emission cylinder (1 by default)
  18326. * @param height the height of the emission cylinder (1 by default)
  18327. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18328. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18329. */
  18330. constructor(
  18331. /**
  18332. * The radius of the emission cylinder.
  18333. */
  18334. radius?: number,
  18335. /**
  18336. * The height of the emission cylinder.
  18337. */
  18338. height?: number,
  18339. /**
  18340. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18341. */
  18342. radiusRange?: number,
  18343. /**
  18344. * How much to randomize the particle direction [0-1].
  18345. */
  18346. directionRandomizer?: number);
  18347. /**
  18348. * Called by the particle System when the direction is computed for the created particle.
  18349. * @param worldMatrix is the world matrix of the particle system
  18350. * @param directionToUpdate is the direction vector to update with the result
  18351. * @param particle is the particle we are computed the direction for
  18352. */
  18353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18354. /**
  18355. * Called by the particle System when the position is computed for the created particle.
  18356. * @param worldMatrix is the world matrix of the particle system
  18357. * @param positionToUpdate is the position vector to update with the result
  18358. * @param particle is the particle we are computed the position for
  18359. */
  18360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18361. /**
  18362. * Clones the current emitter and returns a copy of it
  18363. * @returns the new emitter
  18364. */
  18365. clone(): CylinderParticleEmitter;
  18366. /**
  18367. * Called by the GPUParticleSystem to setup the update shader
  18368. * @param effect defines the update shader
  18369. */
  18370. applyToShader(effect: Effect): void;
  18371. /**
  18372. * Returns a string to use to update the GPU particles update shader
  18373. * @returns a string containng the defines string
  18374. */
  18375. getEffectDefines(): string;
  18376. /**
  18377. * Returns the string "CylinderParticleEmitter"
  18378. * @returns a string containing the class name
  18379. */
  18380. getClassName(): string;
  18381. /**
  18382. * Serializes the particle system to a JSON object.
  18383. * @returns the JSON object
  18384. */
  18385. serialize(): any;
  18386. /**
  18387. * Parse properties from a JSON object
  18388. * @param serializationObject defines the JSON object
  18389. */
  18390. parse(serializationObject: any): void;
  18391. }
  18392. /**
  18393. * Particle emitter emitting particles from the inside of a cylinder.
  18394. * It emits the particles randomly between two vectors.
  18395. */
  18396. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18397. /**
  18398. * The min limit of the emission direction.
  18399. */
  18400. direction1: Vector3;
  18401. /**
  18402. * The max limit of the emission direction.
  18403. */
  18404. direction2: Vector3;
  18405. /**
  18406. * Creates a new instance CylinderDirectedParticleEmitter
  18407. * @param radius the radius of the emission cylinder (1 by default)
  18408. * @param height the height of the emission cylinder (1 by default)
  18409. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18410. * @param direction1 the min limit of the emission direction (up vector by default)
  18411. * @param direction2 the max limit of the emission direction (up vector by default)
  18412. */
  18413. constructor(radius?: number, height?: number, radiusRange?: number,
  18414. /**
  18415. * The min limit of the emission direction.
  18416. */
  18417. direction1?: Vector3,
  18418. /**
  18419. * The max limit of the emission direction.
  18420. */
  18421. direction2?: Vector3);
  18422. /**
  18423. * Called by the particle System when the direction is computed for the created particle.
  18424. * @param worldMatrix is the world matrix of the particle system
  18425. * @param directionToUpdate is the direction vector to update with the result
  18426. * @param particle is the particle we are computed the direction for
  18427. */
  18428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18429. /**
  18430. * Clones the current emitter and returns a copy of it
  18431. * @returns the new emitter
  18432. */
  18433. clone(): CylinderDirectedParticleEmitter;
  18434. /**
  18435. * Called by the GPUParticleSystem to setup the update shader
  18436. * @param effect defines the update shader
  18437. */
  18438. applyToShader(effect: Effect): void;
  18439. /**
  18440. * Returns a string to use to update the GPU particles update shader
  18441. * @returns a string containng the defines string
  18442. */
  18443. getEffectDefines(): string;
  18444. /**
  18445. * Returns the string "CylinderDirectedParticleEmitter"
  18446. * @returns a string containing the class name
  18447. */
  18448. getClassName(): string;
  18449. /**
  18450. * Serializes the particle system to a JSON object.
  18451. * @returns the JSON object
  18452. */
  18453. serialize(): any;
  18454. /**
  18455. * Parse properties from a JSON object
  18456. * @param serializationObject defines the JSON object
  18457. */
  18458. parse(serializationObject: any): void;
  18459. }
  18460. }
  18461. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18463. import { Effect } from "babylonjs/Materials/effect";
  18464. import { Particle } from "babylonjs/Particles/particle";
  18465. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18466. /**
  18467. * Particle emitter emitting particles from the inside of a hemisphere.
  18468. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18469. */
  18470. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18471. /**
  18472. * The radius of the emission hemisphere.
  18473. */
  18474. radius: number;
  18475. /**
  18476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18477. */
  18478. radiusRange: number;
  18479. /**
  18480. * How much to randomize the particle direction [0-1].
  18481. */
  18482. directionRandomizer: number;
  18483. /**
  18484. * Creates a new instance HemisphericParticleEmitter
  18485. * @param radius the radius of the emission hemisphere (1 by default)
  18486. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18487. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18488. */
  18489. constructor(
  18490. /**
  18491. * The radius of the emission hemisphere.
  18492. */
  18493. radius?: number,
  18494. /**
  18495. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18496. */
  18497. radiusRange?: number,
  18498. /**
  18499. * How much to randomize the particle direction [0-1].
  18500. */
  18501. directionRandomizer?: number);
  18502. /**
  18503. * Called by the particle System when the direction is computed for the created particle.
  18504. * @param worldMatrix is the world matrix of the particle system
  18505. * @param directionToUpdate is the direction vector to update with the result
  18506. * @param particle is the particle we are computed the direction for
  18507. */
  18508. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18509. /**
  18510. * Called by the particle System when the position is computed for the created particle.
  18511. * @param worldMatrix is the world matrix of the particle system
  18512. * @param positionToUpdate is the position vector to update with the result
  18513. * @param particle is the particle we are computed the position for
  18514. */
  18515. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18516. /**
  18517. * Clones the current emitter and returns a copy of it
  18518. * @returns the new emitter
  18519. */
  18520. clone(): HemisphericParticleEmitter;
  18521. /**
  18522. * Called by the GPUParticleSystem to setup the update shader
  18523. * @param effect defines the update shader
  18524. */
  18525. applyToShader(effect: Effect): void;
  18526. /**
  18527. * Returns a string to use to update the GPU particles update shader
  18528. * @returns a string containng the defines string
  18529. */
  18530. getEffectDefines(): string;
  18531. /**
  18532. * Returns the string "HemisphericParticleEmitter"
  18533. * @returns a string containing the class name
  18534. */
  18535. getClassName(): string;
  18536. /**
  18537. * Serializes the particle system to a JSON object.
  18538. * @returns the JSON object
  18539. */
  18540. serialize(): any;
  18541. /**
  18542. * Parse properties from a JSON object
  18543. * @param serializationObject defines the JSON object
  18544. */
  18545. parse(serializationObject: any): void;
  18546. }
  18547. }
  18548. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18549. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18550. import { Effect } from "babylonjs/Materials/effect";
  18551. import { Particle } from "babylonjs/Particles/particle";
  18552. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18553. /**
  18554. * Particle emitter emitting particles from a point.
  18555. * It emits the particles randomly between 2 given directions.
  18556. */
  18557. export class PointParticleEmitter implements IParticleEmitterType {
  18558. /**
  18559. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18560. */
  18561. direction1: Vector3;
  18562. /**
  18563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18564. */
  18565. direction2: Vector3;
  18566. /**
  18567. * Creates a new instance PointParticleEmitter
  18568. */
  18569. constructor();
  18570. /**
  18571. * Called by the particle System when the direction is computed for the created particle.
  18572. * @param worldMatrix is the world matrix of the particle system
  18573. * @param directionToUpdate is the direction vector to update with the result
  18574. * @param particle is the particle we are computed the direction for
  18575. */
  18576. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18577. /**
  18578. * Called by the particle System when the position is computed for the created particle.
  18579. * @param worldMatrix is the world matrix of the particle system
  18580. * @param positionToUpdate is the position vector to update with the result
  18581. * @param particle is the particle we are computed the position for
  18582. */
  18583. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18584. /**
  18585. * Clones the current emitter and returns a copy of it
  18586. * @returns the new emitter
  18587. */
  18588. clone(): PointParticleEmitter;
  18589. /**
  18590. * Called by the GPUParticleSystem to setup the update shader
  18591. * @param effect defines the update shader
  18592. */
  18593. applyToShader(effect: Effect): void;
  18594. /**
  18595. * Returns a string to use to update the GPU particles update shader
  18596. * @returns a string containng the defines string
  18597. */
  18598. getEffectDefines(): string;
  18599. /**
  18600. * Returns the string "PointParticleEmitter"
  18601. * @returns a string containing the class name
  18602. */
  18603. getClassName(): string;
  18604. /**
  18605. * Serializes the particle system to a JSON object.
  18606. * @returns the JSON object
  18607. */
  18608. serialize(): any;
  18609. /**
  18610. * Parse properties from a JSON object
  18611. * @param serializationObject defines the JSON object
  18612. */
  18613. parse(serializationObject: any): void;
  18614. }
  18615. }
  18616. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18617. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18618. import { Effect } from "babylonjs/Materials/effect";
  18619. import { Particle } from "babylonjs/Particles/particle";
  18620. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18621. /**
  18622. * Particle emitter emitting particles from the inside of a sphere.
  18623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18624. */
  18625. export class SphereParticleEmitter implements IParticleEmitterType {
  18626. /**
  18627. * The radius of the emission sphere.
  18628. */
  18629. radius: number;
  18630. /**
  18631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18632. */
  18633. radiusRange: number;
  18634. /**
  18635. * How much to randomize the particle direction [0-1].
  18636. */
  18637. directionRandomizer: number;
  18638. /**
  18639. * Creates a new instance SphereParticleEmitter
  18640. * @param radius the radius of the emission sphere (1 by default)
  18641. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18643. */
  18644. constructor(
  18645. /**
  18646. * The radius of the emission sphere.
  18647. */
  18648. radius?: number,
  18649. /**
  18650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18651. */
  18652. radiusRange?: number,
  18653. /**
  18654. * How much to randomize the particle direction [0-1].
  18655. */
  18656. directionRandomizer?: number);
  18657. /**
  18658. * Called by the particle System when the direction is computed for the created particle.
  18659. * @param worldMatrix is the world matrix of the particle system
  18660. * @param directionToUpdate is the direction vector to update with the result
  18661. * @param particle is the particle we are computed the direction for
  18662. */
  18663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18664. /**
  18665. * Called by the particle System when the position is computed for the created particle.
  18666. * @param worldMatrix is the world matrix of the particle system
  18667. * @param positionToUpdate is the position vector to update with the result
  18668. * @param particle is the particle we are computed the position for
  18669. */
  18670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18671. /**
  18672. * Clones the current emitter and returns a copy of it
  18673. * @returns the new emitter
  18674. */
  18675. clone(): SphereParticleEmitter;
  18676. /**
  18677. * Called by the GPUParticleSystem to setup the update shader
  18678. * @param effect defines the update shader
  18679. */
  18680. applyToShader(effect: Effect): void;
  18681. /**
  18682. * Returns a string to use to update the GPU particles update shader
  18683. * @returns a string containng the defines string
  18684. */
  18685. getEffectDefines(): string;
  18686. /**
  18687. * Returns the string "SphereParticleEmitter"
  18688. * @returns a string containing the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Serializes the particle system to a JSON object.
  18693. * @returns the JSON object
  18694. */
  18695. serialize(): any;
  18696. /**
  18697. * Parse properties from a JSON object
  18698. * @param serializationObject defines the JSON object
  18699. */
  18700. parse(serializationObject: any): void;
  18701. }
  18702. /**
  18703. * Particle emitter emitting particles from the inside of a sphere.
  18704. * It emits the particles randomly between two vectors.
  18705. */
  18706. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18707. /**
  18708. * The min limit of the emission direction.
  18709. */
  18710. direction1: Vector3;
  18711. /**
  18712. * The max limit of the emission direction.
  18713. */
  18714. direction2: Vector3;
  18715. /**
  18716. * Creates a new instance SphereDirectedParticleEmitter
  18717. * @param radius the radius of the emission sphere (1 by default)
  18718. * @param direction1 the min limit of the emission direction (up vector by default)
  18719. * @param direction2 the max limit of the emission direction (up vector by default)
  18720. */
  18721. constructor(radius?: number,
  18722. /**
  18723. * The min limit of the emission direction.
  18724. */
  18725. direction1?: Vector3,
  18726. /**
  18727. * The max limit of the emission direction.
  18728. */
  18729. direction2?: Vector3);
  18730. /**
  18731. * Called by the particle System when the direction is computed for the created particle.
  18732. * @param worldMatrix is the world matrix of the particle system
  18733. * @param directionToUpdate is the direction vector to update with the result
  18734. * @param particle is the particle we are computed the direction for
  18735. */
  18736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18737. /**
  18738. * Clones the current emitter and returns a copy of it
  18739. * @returns the new emitter
  18740. */
  18741. clone(): SphereDirectedParticleEmitter;
  18742. /**
  18743. * Called by the GPUParticleSystem to setup the update shader
  18744. * @param effect defines the update shader
  18745. */
  18746. applyToShader(effect: Effect): void;
  18747. /**
  18748. * Returns a string to use to update the GPU particles update shader
  18749. * @returns a string containng the defines string
  18750. */
  18751. getEffectDefines(): string;
  18752. /**
  18753. * Returns the string "SphereDirectedParticleEmitter"
  18754. * @returns a string containing the class name
  18755. */
  18756. getClassName(): string;
  18757. /**
  18758. * Serializes the particle system to a JSON object.
  18759. * @returns the JSON object
  18760. */
  18761. serialize(): any;
  18762. /**
  18763. * Parse properties from a JSON object
  18764. * @param serializationObject defines the JSON object
  18765. */
  18766. parse(serializationObject: any): void;
  18767. }
  18768. }
  18769. declare module "babylonjs/Particles/EmitterTypes/index" {
  18770. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18771. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18772. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18773. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18774. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18775. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18776. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18777. }
  18778. declare module "babylonjs/Particles/IParticleSystem" {
  18779. import { Nullable } from "babylonjs/types";
  18780. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18781. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18784. import { Texture } from "babylonjs/Materials/Textures/texture";
  18785. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18786. import { Scene } from "babylonjs/scene";
  18787. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18788. import { Animation } from "babylonjs/Animations/animation";
  18789. /**
  18790. * Interface representing a particle system in Babylon.js.
  18791. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18792. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18793. */
  18794. export interface IParticleSystem {
  18795. /**
  18796. * List of animations used by the particle system.
  18797. */
  18798. animations: Animation[];
  18799. /**
  18800. * The id of the Particle system.
  18801. */
  18802. id: string;
  18803. /**
  18804. * The name of the Particle system.
  18805. */
  18806. name: string;
  18807. /**
  18808. * The emitter represents the Mesh or position we are attaching the particle system to.
  18809. */
  18810. emitter: Nullable<AbstractMesh | Vector3>;
  18811. /**
  18812. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18813. */
  18814. isBillboardBased: boolean;
  18815. /**
  18816. * The rendering group used by the Particle system to chose when to render.
  18817. */
  18818. renderingGroupId: number;
  18819. /**
  18820. * The layer mask we are rendering the particles through.
  18821. */
  18822. layerMask: number;
  18823. /**
  18824. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18825. */
  18826. updateSpeed: number;
  18827. /**
  18828. * The amount of time the particle system is running (depends of the overall update speed).
  18829. */
  18830. targetStopDuration: number;
  18831. /**
  18832. * The texture used to render each particle. (this can be a spritesheet)
  18833. */
  18834. particleTexture: Nullable<Texture>;
  18835. /**
  18836. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18837. */
  18838. blendMode: number;
  18839. /**
  18840. * Minimum life time of emitting particles.
  18841. */
  18842. minLifeTime: number;
  18843. /**
  18844. * Maximum life time of emitting particles.
  18845. */
  18846. maxLifeTime: number;
  18847. /**
  18848. * Minimum Size of emitting particles.
  18849. */
  18850. minSize: number;
  18851. /**
  18852. * Maximum Size of emitting particles.
  18853. */
  18854. maxSize: number;
  18855. /**
  18856. * Minimum scale of emitting particles on X axis.
  18857. */
  18858. minScaleX: number;
  18859. /**
  18860. * Maximum scale of emitting particles on X axis.
  18861. */
  18862. maxScaleX: number;
  18863. /**
  18864. * Minimum scale of emitting particles on Y axis.
  18865. */
  18866. minScaleY: number;
  18867. /**
  18868. * Maximum scale of emitting particles on Y axis.
  18869. */
  18870. maxScaleY: number;
  18871. /**
  18872. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18873. */
  18874. color1: Color4;
  18875. /**
  18876. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18877. */
  18878. color2: Color4;
  18879. /**
  18880. * Color the particle will have at the end of its lifetime.
  18881. */
  18882. colorDead: Color4;
  18883. /**
  18884. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18885. */
  18886. emitRate: number;
  18887. /**
  18888. * You can use gravity if you want to give an orientation to your particles.
  18889. */
  18890. gravity: Vector3;
  18891. /**
  18892. * Minimum power of emitting particles.
  18893. */
  18894. minEmitPower: number;
  18895. /**
  18896. * Maximum power of emitting particles.
  18897. */
  18898. maxEmitPower: number;
  18899. /**
  18900. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18901. */
  18902. minAngularSpeed: number;
  18903. /**
  18904. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18905. */
  18906. maxAngularSpeed: number;
  18907. /**
  18908. * Gets or sets the minimal initial rotation in radians.
  18909. */
  18910. minInitialRotation: number;
  18911. /**
  18912. * Gets or sets the maximal initial rotation in radians.
  18913. */
  18914. maxInitialRotation: number;
  18915. /**
  18916. * The particle emitter type defines the emitter used by the particle system.
  18917. * It can be for example box, sphere, or cone...
  18918. */
  18919. particleEmitterType: Nullable<IParticleEmitterType>;
  18920. /**
  18921. * Defines the delay in milliseconds before starting the system (0 by default)
  18922. */
  18923. startDelay: number;
  18924. /**
  18925. * 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
  18926. */
  18927. preWarmCycles: number;
  18928. /**
  18929. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18930. */
  18931. preWarmStepOffset: number;
  18932. /**
  18933. * 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)
  18934. */
  18935. spriteCellChangeSpeed: number;
  18936. /**
  18937. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18938. */
  18939. startSpriteCellID: number;
  18940. /**
  18941. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18942. */
  18943. endSpriteCellID: number;
  18944. /**
  18945. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18946. */
  18947. spriteCellWidth: number;
  18948. /**
  18949. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18950. */
  18951. spriteCellHeight: number;
  18952. /**
  18953. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18954. */
  18955. spriteRandomStartCell: boolean;
  18956. /**
  18957. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18958. */
  18959. isAnimationSheetEnabled: boolean;
  18960. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18961. translationPivot: Vector2;
  18962. /**
  18963. * Gets or sets a texture used to add random noise to particle positions
  18964. */
  18965. noiseTexture: Nullable<BaseTexture>;
  18966. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18967. noiseStrength: Vector3;
  18968. /**
  18969. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18970. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18971. */
  18972. billboardMode: number;
  18973. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18974. limitVelocityDamping: number;
  18975. /**
  18976. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18977. */
  18978. beginAnimationOnStart: boolean;
  18979. /**
  18980. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18981. */
  18982. beginAnimationFrom: number;
  18983. /**
  18984. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18985. */
  18986. beginAnimationTo: number;
  18987. /**
  18988. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18989. */
  18990. beginAnimationLoop: boolean;
  18991. /**
  18992. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18993. */
  18994. disposeOnStop: boolean;
  18995. /**
  18996. * Gets the maximum number of particles active at the same time.
  18997. * @returns The max number of active particles.
  18998. */
  18999. getCapacity(): number;
  19000. /**
  19001. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19002. * @returns True if it has been started, otherwise false.
  19003. */
  19004. isStarted(): boolean;
  19005. /**
  19006. * Animates the particle system for this frame.
  19007. */
  19008. animate(): void;
  19009. /**
  19010. * Renders the particle system in its current state.
  19011. * @returns the current number of particles
  19012. */
  19013. render(): number;
  19014. /**
  19015. * Dispose the particle system and frees its associated resources.
  19016. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19017. */
  19018. dispose(disposeTexture?: boolean): void;
  19019. /**
  19020. * Clones the particle system.
  19021. * @param name The name of the cloned object
  19022. * @param newEmitter The new emitter to use
  19023. * @returns the cloned particle system
  19024. */
  19025. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19026. /**
  19027. * Serializes the particle system to a JSON object.
  19028. * @returns the JSON object
  19029. */
  19030. serialize(): any;
  19031. /**
  19032. * Rebuild the particle system
  19033. */
  19034. rebuild(): void;
  19035. /**
  19036. * Starts the particle system and begins to emit
  19037. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19038. */
  19039. start(delay?: number): void;
  19040. /**
  19041. * Stops the particle system.
  19042. */
  19043. stop(): void;
  19044. /**
  19045. * Remove all active particles
  19046. */
  19047. reset(): void;
  19048. /**
  19049. * Is this system ready to be used/rendered
  19050. * @return true if the system is ready
  19051. */
  19052. isReady(): boolean;
  19053. /**
  19054. * Adds a new color gradient
  19055. * @param gradient defines the gradient to use (between 0 and 1)
  19056. * @param color1 defines the color to affect to the specified gradient
  19057. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19058. * @returns the current particle system
  19059. */
  19060. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19061. /**
  19062. * Remove a specific color gradient
  19063. * @param gradient defines the gradient to remove
  19064. * @returns the current particle system
  19065. */
  19066. removeColorGradient(gradient: number): IParticleSystem;
  19067. /**
  19068. * Adds a new size gradient
  19069. * @param gradient defines the gradient to use (between 0 and 1)
  19070. * @param factor defines the size factor to affect to the specified gradient
  19071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19072. * @returns the current particle system
  19073. */
  19074. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19075. /**
  19076. * Remove a specific size gradient
  19077. * @param gradient defines the gradient to remove
  19078. * @returns the current particle system
  19079. */
  19080. removeSizeGradient(gradient: number): IParticleSystem;
  19081. /**
  19082. * Gets the current list of color gradients.
  19083. * You must use addColorGradient and removeColorGradient to udpate this list
  19084. * @returns the list of color gradients
  19085. */
  19086. getColorGradients(): Nullable<Array<ColorGradient>>;
  19087. /**
  19088. * Gets the current list of size gradients.
  19089. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19090. * @returns the list of size gradients
  19091. */
  19092. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19093. /**
  19094. * Gets the current list of angular speed gradients.
  19095. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19096. * @returns the list of angular speed gradients
  19097. */
  19098. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19099. /**
  19100. * Adds a new angular speed gradient
  19101. * @param gradient defines the gradient to use (between 0 and 1)
  19102. * @param factor defines the angular speed to affect to the specified gradient
  19103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19104. * @returns the current particle system
  19105. */
  19106. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19107. /**
  19108. * Remove a specific angular speed gradient
  19109. * @param gradient defines the gradient to remove
  19110. * @returns the current particle system
  19111. */
  19112. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19113. /**
  19114. * Gets the current list of velocity gradients.
  19115. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19116. * @returns the list of velocity gradients
  19117. */
  19118. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19119. /**
  19120. * Adds a new velocity gradient
  19121. * @param gradient defines the gradient to use (between 0 and 1)
  19122. * @param factor defines the velocity to affect to the specified gradient
  19123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19124. * @returns the current particle system
  19125. */
  19126. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19127. /**
  19128. * Remove a specific velocity gradient
  19129. * @param gradient defines the gradient to remove
  19130. * @returns the current particle system
  19131. */
  19132. removeVelocityGradient(gradient: number): IParticleSystem;
  19133. /**
  19134. * Gets the current list of limit velocity gradients.
  19135. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19136. * @returns the list of limit velocity gradients
  19137. */
  19138. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19139. /**
  19140. * Adds a new limit velocity gradient
  19141. * @param gradient defines the gradient to use (between 0 and 1)
  19142. * @param factor defines the limit velocity to affect to the specified gradient
  19143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19144. * @returns the current particle system
  19145. */
  19146. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19147. /**
  19148. * Remove a specific limit velocity gradient
  19149. * @param gradient defines the gradient to remove
  19150. * @returns the current particle system
  19151. */
  19152. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19153. /**
  19154. * Adds a new drag gradient
  19155. * @param gradient defines the gradient to use (between 0 and 1)
  19156. * @param factor defines the drag to affect to the specified gradient
  19157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19158. * @returns the current particle system
  19159. */
  19160. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19161. /**
  19162. * Remove a specific drag gradient
  19163. * @param gradient defines the gradient to remove
  19164. * @returns the current particle system
  19165. */
  19166. removeDragGradient(gradient: number): IParticleSystem;
  19167. /**
  19168. * Gets the current list of drag gradients.
  19169. * You must use addDragGradient and removeDragGradient to udpate this list
  19170. * @returns the list of drag gradients
  19171. */
  19172. getDragGradients(): Nullable<Array<FactorGradient>>;
  19173. /**
  19174. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19175. * @param gradient defines the gradient to use (between 0 and 1)
  19176. * @param factor defines the emit rate to affect to the specified gradient
  19177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19178. * @returns the current particle system
  19179. */
  19180. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19181. /**
  19182. * Remove a specific emit rate gradient
  19183. * @param gradient defines the gradient to remove
  19184. * @returns the current particle system
  19185. */
  19186. removeEmitRateGradient(gradient: number): IParticleSystem;
  19187. /**
  19188. * Gets the current list of emit rate gradients.
  19189. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19190. * @returns the list of emit rate gradients
  19191. */
  19192. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19193. /**
  19194. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19195. * @param gradient defines the gradient to use (between 0 and 1)
  19196. * @param factor defines the start size to affect to the specified gradient
  19197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19198. * @returns the current particle system
  19199. */
  19200. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19201. /**
  19202. * Remove a specific start size gradient
  19203. * @param gradient defines the gradient to remove
  19204. * @returns the current particle system
  19205. */
  19206. removeStartSizeGradient(gradient: number): IParticleSystem;
  19207. /**
  19208. * Gets the current list of start size gradients.
  19209. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19210. * @returns the list of start size gradients
  19211. */
  19212. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19213. /**
  19214. * Adds a new life time gradient
  19215. * @param gradient defines the gradient to use (between 0 and 1)
  19216. * @param factor defines the life time factor to affect to the specified gradient
  19217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19218. * @returns the current particle system
  19219. */
  19220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19221. /**
  19222. * Remove a specific life time gradient
  19223. * @param gradient defines the gradient to remove
  19224. * @returns the current particle system
  19225. */
  19226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19227. /**
  19228. * Gets the current list of life time gradients.
  19229. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19230. * @returns the list of life time gradients
  19231. */
  19232. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19233. /**
  19234. * Gets the current list of color gradients.
  19235. * You must use addColorGradient and removeColorGradient to udpate this list
  19236. * @returns the list of color gradients
  19237. */
  19238. getColorGradients(): Nullable<Array<ColorGradient>>;
  19239. /**
  19240. * Adds a new ramp gradient used to remap particle colors
  19241. * @param gradient defines the gradient to use (between 0 and 1)
  19242. * @param color defines the color to affect to the specified gradient
  19243. * @returns the current particle system
  19244. */
  19245. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19246. /**
  19247. * Gets the current list of ramp gradients.
  19248. * You must use addRampGradient and removeRampGradient to udpate this list
  19249. * @returns the list of ramp gradients
  19250. */
  19251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19252. /** Gets or sets a boolean indicating that ramp gradients must be used
  19253. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19254. */
  19255. useRampGradients: boolean;
  19256. /**
  19257. * Adds a new color remap gradient
  19258. * @param gradient defines the gradient to use (between 0 and 1)
  19259. * @param min defines the color remap minimal range
  19260. * @param max defines the color remap maximal range
  19261. * @returns the current particle system
  19262. */
  19263. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19264. /**
  19265. * Gets the current list of color remap gradients.
  19266. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19267. * @returns the list of color remap gradients
  19268. */
  19269. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19270. /**
  19271. * Adds a new alpha remap gradient
  19272. * @param gradient defines the gradient to use (between 0 and 1)
  19273. * @param min defines the alpha remap minimal range
  19274. * @param max defines the alpha remap maximal range
  19275. * @returns the current particle system
  19276. */
  19277. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19278. /**
  19279. * Gets the current list of alpha remap gradients.
  19280. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19281. * @returns the list of alpha remap gradients
  19282. */
  19283. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19284. /**
  19285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19288. * @returns the emitter
  19289. */
  19290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19291. /**
  19292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19293. * @param radius The radius of the hemisphere to emit from
  19294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19295. * @returns the emitter
  19296. */
  19297. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19298. /**
  19299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19300. * @param radius The radius of the sphere to emit from
  19301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19302. * @returns the emitter
  19303. */
  19304. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19305. /**
  19306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19307. * @param radius The radius of the sphere to emit from
  19308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19310. * @returns the emitter
  19311. */
  19312. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19313. /**
  19314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19315. * @param radius The radius of the emission cylinder
  19316. * @param height The height of the emission cylinder
  19317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19319. * @returns the emitter
  19320. */
  19321. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19322. /**
  19323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19324. * @param radius The radius of the cylinder to emit from
  19325. * @param height The height of the emission cylinder
  19326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19329. * @returns the emitter
  19330. */
  19331. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19332. /**
  19333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19334. * @param radius The radius of the cone to emit from
  19335. * @param angle The base angle of the cone
  19336. * @returns the emitter
  19337. */
  19338. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19339. /**
  19340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19345. * @returns the emitter
  19346. */
  19347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19348. /**
  19349. * Get hosting scene
  19350. * @returns the scene
  19351. */
  19352. getScene(): Scene;
  19353. }
  19354. }
  19355. declare module "babylonjs/Meshes/instancedMesh" {
  19356. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19358. import { Camera } from "babylonjs/Cameras/camera";
  19359. import { Node } from "babylonjs/node";
  19360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19361. import { Mesh } from "babylonjs/Meshes/mesh";
  19362. import { Material } from "babylonjs/Materials/material";
  19363. import { Skeleton } from "babylonjs/Bones/skeleton";
  19364. import { Light } from "babylonjs/Lights/light";
  19365. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19366. /**
  19367. * Creates an instance based on a source mesh.
  19368. */
  19369. export class InstancedMesh extends AbstractMesh {
  19370. private _sourceMesh;
  19371. private _currentLOD;
  19372. /** @hidden */
  19373. _indexInSourceMeshInstanceArray: number;
  19374. constructor(name: string, source: Mesh);
  19375. /**
  19376. * Returns the string "InstancedMesh".
  19377. */
  19378. getClassName(): string;
  19379. /** Gets the list of lights affecting that mesh */
  19380. readonly lightSources: Light[];
  19381. _resyncLightSources(): void;
  19382. _resyncLighSource(light: Light): void;
  19383. _removeLightSource(light: Light, dispose: boolean): void;
  19384. /**
  19385. * If the source mesh receives shadows
  19386. */
  19387. readonly receiveShadows: boolean;
  19388. /**
  19389. * The material of the source mesh
  19390. */
  19391. readonly material: Nullable<Material>;
  19392. /**
  19393. * Visibility of the source mesh
  19394. */
  19395. readonly visibility: number;
  19396. /**
  19397. * Skeleton of the source mesh
  19398. */
  19399. readonly skeleton: Nullable<Skeleton>;
  19400. /**
  19401. * Rendering ground id of the source mesh
  19402. */
  19403. renderingGroupId: number;
  19404. /**
  19405. * Returns the total number of vertices (integer).
  19406. */
  19407. getTotalVertices(): number;
  19408. /**
  19409. * Returns a positive integer : the total number of indices in this mesh geometry.
  19410. * @returns the numner of indices or zero if the mesh has no geometry.
  19411. */
  19412. getTotalIndices(): number;
  19413. /**
  19414. * The source mesh of the instance
  19415. */
  19416. readonly sourceMesh: Mesh;
  19417. /**
  19418. * Is this node ready to be used/rendered
  19419. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19420. * @return {boolean} is it ready
  19421. */
  19422. isReady(completeCheck?: boolean): boolean;
  19423. /**
  19424. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19425. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19426. * @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.
  19427. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19428. */
  19429. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19430. /**
  19431. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19432. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19433. * The `data` are either a numeric array either a Float32Array.
  19434. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19435. * 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).
  19436. * Note that a new underlying VertexBuffer object is created each call.
  19437. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19438. *
  19439. * Possible `kind` values :
  19440. * - VertexBuffer.PositionKind
  19441. * - VertexBuffer.UVKind
  19442. * - VertexBuffer.UV2Kind
  19443. * - VertexBuffer.UV3Kind
  19444. * - VertexBuffer.UV4Kind
  19445. * - VertexBuffer.UV5Kind
  19446. * - VertexBuffer.UV6Kind
  19447. * - VertexBuffer.ColorKind
  19448. * - VertexBuffer.MatricesIndicesKind
  19449. * - VertexBuffer.MatricesIndicesExtraKind
  19450. * - VertexBuffer.MatricesWeightsKind
  19451. * - VertexBuffer.MatricesWeightsExtraKind
  19452. *
  19453. * Returns the Mesh.
  19454. */
  19455. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19456. /**
  19457. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19458. * If the mesh has no geometry, it is simply returned as it is.
  19459. * The `data` are either a numeric array either a Float32Array.
  19460. * No new underlying VertexBuffer object is created.
  19461. * 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.
  19462. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19463. *
  19464. * Possible `kind` values :
  19465. * - VertexBuffer.PositionKind
  19466. * - VertexBuffer.UVKind
  19467. * - VertexBuffer.UV2Kind
  19468. * - VertexBuffer.UV3Kind
  19469. * - VertexBuffer.UV4Kind
  19470. * - VertexBuffer.UV5Kind
  19471. * - VertexBuffer.UV6Kind
  19472. * - VertexBuffer.ColorKind
  19473. * - VertexBuffer.MatricesIndicesKind
  19474. * - VertexBuffer.MatricesIndicesExtraKind
  19475. * - VertexBuffer.MatricesWeightsKind
  19476. * - VertexBuffer.MatricesWeightsExtraKind
  19477. *
  19478. * Returns the Mesh.
  19479. */
  19480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19481. /**
  19482. * Sets the mesh indices.
  19483. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19484. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19485. * This method creates a new index buffer each call.
  19486. * Returns the Mesh.
  19487. */
  19488. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19489. /**
  19490. * Boolean : True if the mesh owns the requested kind of data.
  19491. */
  19492. isVerticesDataPresent(kind: string): boolean;
  19493. /**
  19494. * Returns an array of indices (IndicesArray).
  19495. */
  19496. getIndices(): Nullable<IndicesArray>;
  19497. readonly _positions: Nullable<Vector3[]>;
  19498. /**
  19499. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19500. * This means the mesh underlying bounding box and sphere are recomputed.
  19501. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19502. * @returns the current mesh
  19503. */
  19504. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19505. /** @hidden */
  19506. _preActivate(): InstancedMesh;
  19507. /** @hidden */
  19508. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19509. /** @hidden */
  19510. _postActivate(): void;
  19511. getWorldMatrix(): Matrix;
  19512. readonly isAnInstance: boolean;
  19513. /**
  19514. * Returns the current associated LOD AbstractMesh.
  19515. */
  19516. getLOD(camera: Camera): AbstractMesh;
  19517. /** @hidden */
  19518. _syncSubMeshes(): InstancedMesh;
  19519. /** @hidden */
  19520. _generatePointsArray(): boolean;
  19521. /**
  19522. * Creates a new InstancedMesh from the current mesh.
  19523. * - name (string) : the cloned mesh name
  19524. * - newParent (optional Node) : the optional Node to parent the clone to.
  19525. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19526. *
  19527. * Returns the clone.
  19528. */
  19529. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19530. /**
  19531. * Disposes the InstancedMesh.
  19532. * Returns nothing.
  19533. */
  19534. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19535. }
  19536. module "babylonjs/Meshes/mesh" {
  19537. interface Mesh {
  19538. /**
  19539. * Register a custom buffer that will be instanced
  19540. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19541. * @param kind defines the buffer kind
  19542. * @param stride defines the stride in floats
  19543. */
  19544. registerInstancedBuffer(kind: string, stride: number): void;
  19545. /** @hidden */
  19546. _userInstancedBuffersStorage: {
  19547. data: {
  19548. [key: string]: Float32Array;
  19549. };
  19550. sizes: {
  19551. [key: string]: number;
  19552. };
  19553. vertexBuffers: {
  19554. [key: string]: Nullable<VertexBuffer>;
  19555. };
  19556. strides: {
  19557. [key: string]: number;
  19558. };
  19559. };
  19560. }
  19561. }
  19562. module "babylonjs/Meshes/abstractMesh" {
  19563. interface AbstractMesh {
  19564. /**
  19565. * Object used to store instanced buffers defined by user
  19566. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19567. */
  19568. instancedBuffers: {
  19569. [key: string]: any;
  19570. };
  19571. }
  19572. }
  19573. }
  19574. declare module "babylonjs/Materials/shaderMaterial" {
  19575. import { Scene } from "babylonjs/scene";
  19576. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19578. import { Mesh } from "babylonjs/Meshes/mesh";
  19579. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19580. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19581. import { Texture } from "babylonjs/Materials/Textures/texture";
  19582. import { Material } from "babylonjs/Materials/material";
  19583. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19584. /**
  19585. * Defines the options associated with the creation of a shader material.
  19586. */
  19587. export interface IShaderMaterialOptions {
  19588. /**
  19589. * Does the material work in alpha blend mode
  19590. */
  19591. needAlphaBlending: boolean;
  19592. /**
  19593. * Does the material work in alpha test mode
  19594. */
  19595. needAlphaTesting: boolean;
  19596. /**
  19597. * The list of attribute names used in the shader
  19598. */
  19599. attributes: string[];
  19600. /**
  19601. * The list of unifrom names used in the shader
  19602. */
  19603. uniforms: string[];
  19604. /**
  19605. * The list of UBO names used in the shader
  19606. */
  19607. uniformBuffers: string[];
  19608. /**
  19609. * The list of sampler names used in the shader
  19610. */
  19611. samplers: string[];
  19612. /**
  19613. * The list of defines used in the shader
  19614. */
  19615. defines: string[];
  19616. }
  19617. /**
  19618. * 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.
  19619. *
  19620. * This returned material effects how the mesh will look based on the code in the shaders.
  19621. *
  19622. * @see http://doc.babylonjs.com/how_to/shader_material
  19623. */
  19624. export class ShaderMaterial extends Material {
  19625. private _shaderPath;
  19626. private _options;
  19627. private _textures;
  19628. private _textureArrays;
  19629. private _floats;
  19630. private _ints;
  19631. private _floatsArrays;
  19632. private _colors3;
  19633. private _colors3Arrays;
  19634. private _colors4;
  19635. private _colors4Arrays;
  19636. private _vectors2;
  19637. private _vectors3;
  19638. private _vectors4;
  19639. private _matrices;
  19640. private _matrices3x3;
  19641. private _matrices2x2;
  19642. private _vectors2Arrays;
  19643. private _vectors3Arrays;
  19644. private _vectors4Arrays;
  19645. private _cachedWorldViewMatrix;
  19646. private _cachedWorldViewProjectionMatrix;
  19647. private _renderId;
  19648. /**
  19649. * Instantiate a new shader material.
  19650. * 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.
  19651. * This returned material effects how the mesh will look based on the code in the shaders.
  19652. * @see http://doc.babylonjs.com/how_to/shader_material
  19653. * @param name Define the name of the material in the scene
  19654. * @param scene Define the scene the material belongs to
  19655. * @param shaderPath Defines the route to the shader code in one of three ways:
  19656. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19657. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19658. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19659. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19660. * @param options Define the options used to create the shader
  19661. */
  19662. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19663. /**
  19664. * Gets the options used to compile the shader.
  19665. * They can be modified to trigger a new compilation
  19666. */
  19667. readonly options: IShaderMaterialOptions;
  19668. /**
  19669. * Gets the current class name of the material e.g. "ShaderMaterial"
  19670. * Mainly use in serialization.
  19671. * @returns the class name
  19672. */
  19673. getClassName(): string;
  19674. /**
  19675. * Specifies if the material will require alpha blending
  19676. * @returns a boolean specifying if alpha blending is needed
  19677. */
  19678. needAlphaBlending(): boolean;
  19679. /**
  19680. * Specifies if this material should be rendered in alpha test mode
  19681. * @returns a boolean specifying if an alpha test is needed.
  19682. */
  19683. needAlphaTesting(): boolean;
  19684. private _checkUniform;
  19685. /**
  19686. * Set a texture in the shader.
  19687. * @param name Define the name of the uniform samplers as defined in the shader
  19688. * @param texture Define the texture to bind to this sampler
  19689. * @return the material itself allowing "fluent" like uniform updates
  19690. */
  19691. setTexture(name: string, texture: Texture): ShaderMaterial;
  19692. /**
  19693. * Set a texture array in the shader.
  19694. * @param name Define the name of the uniform sampler array as defined in the shader
  19695. * @param textures Define the list of textures to bind to this sampler
  19696. * @return the material itself allowing "fluent" like uniform updates
  19697. */
  19698. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19699. /**
  19700. * Set a float in the shader.
  19701. * @param name Define the name of the uniform as defined in the shader
  19702. * @param value Define the value to give to the uniform
  19703. * @return the material itself allowing "fluent" like uniform updates
  19704. */
  19705. setFloat(name: string, value: number): ShaderMaterial;
  19706. /**
  19707. * Set a int in the shader.
  19708. * @param name Define the name of the uniform as defined in the shader
  19709. * @param value Define the value to give to the uniform
  19710. * @return the material itself allowing "fluent" like uniform updates
  19711. */
  19712. setInt(name: string, value: number): ShaderMaterial;
  19713. /**
  19714. * Set an array of floats in the shader.
  19715. * @param name Define the name of the uniform as defined in the shader
  19716. * @param value Define the value to give to the uniform
  19717. * @return the material itself allowing "fluent" like uniform updates
  19718. */
  19719. setFloats(name: string, value: number[]): ShaderMaterial;
  19720. /**
  19721. * Set a vec3 in the shader from a Color3.
  19722. * @param name Define the name of the uniform as defined in the shader
  19723. * @param value Define the value to give to the uniform
  19724. * @return the material itself allowing "fluent" like uniform updates
  19725. */
  19726. setColor3(name: string, value: Color3): ShaderMaterial;
  19727. /**
  19728. * Set a vec3 array in the shader from a Color3 array.
  19729. * @param name Define the name of the uniform as defined in the shader
  19730. * @param value Define the value to give to the uniform
  19731. * @return the material itself allowing "fluent" like uniform updates
  19732. */
  19733. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19734. /**
  19735. * Set a vec4 in the shader from a Color4.
  19736. * @param name Define the name of the uniform as defined in the shader
  19737. * @param value Define the value to give to the uniform
  19738. * @return the material itself allowing "fluent" like uniform updates
  19739. */
  19740. setColor4(name: string, value: Color4): ShaderMaterial;
  19741. /**
  19742. * Set a vec4 array in the shader from a Color4 array.
  19743. * @param name Define the name of the uniform as defined in the shader
  19744. * @param value Define the value to give to the uniform
  19745. * @return the material itself allowing "fluent" like uniform updates
  19746. */
  19747. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19748. /**
  19749. * Set a vec2 in the shader from a Vector2.
  19750. * @param name Define the name of the uniform as defined in the shader
  19751. * @param value Define the value to give to the uniform
  19752. * @return the material itself allowing "fluent" like uniform updates
  19753. */
  19754. setVector2(name: string, value: Vector2): ShaderMaterial;
  19755. /**
  19756. * Set a vec3 in the shader from a Vector3.
  19757. * @param name Define the name of the uniform as defined in the shader
  19758. * @param value Define the value to give to the uniform
  19759. * @return the material itself allowing "fluent" like uniform updates
  19760. */
  19761. setVector3(name: string, value: Vector3): ShaderMaterial;
  19762. /**
  19763. * Set a vec4 in the shader from a Vector4.
  19764. * @param name Define the name of the uniform as defined in the shader
  19765. * @param value Define the value to give to the uniform
  19766. * @return the material itself allowing "fluent" like uniform updates
  19767. */
  19768. setVector4(name: string, value: Vector4): ShaderMaterial;
  19769. /**
  19770. * Set a mat4 in the shader from a Matrix.
  19771. * @param name Define the name of the uniform as defined in the shader
  19772. * @param value Define the value to give to the uniform
  19773. * @return the material itself allowing "fluent" like uniform updates
  19774. */
  19775. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19776. /**
  19777. * Set a mat3 in the shader from a Float32Array.
  19778. * @param name Define the name of the uniform as defined in the shader
  19779. * @param value Define the value to give to the uniform
  19780. * @return the material itself allowing "fluent" like uniform updates
  19781. */
  19782. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19783. /**
  19784. * Set a mat2 in the shader from a Float32Array.
  19785. * @param name Define the name of the uniform as defined in the shader
  19786. * @param value Define the value to give to the uniform
  19787. * @return the material itself allowing "fluent" like uniform updates
  19788. */
  19789. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19790. /**
  19791. * Set a vec2 array in the shader from a number array.
  19792. * @param name Define the name of the uniform as defined in the shader
  19793. * @param value Define the value to give to the uniform
  19794. * @return the material itself allowing "fluent" like uniform updates
  19795. */
  19796. setArray2(name: string, value: number[]): ShaderMaterial;
  19797. /**
  19798. * Set a vec3 array in the shader from a number array.
  19799. * @param name Define the name of the uniform as defined in the shader
  19800. * @param value Define the value to give to the uniform
  19801. * @return the material itself allowing "fluent" like uniform updates
  19802. */
  19803. setArray3(name: string, value: number[]): ShaderMaterial;
  19804. /**
  19805. * Set a vec4 array in the shader from a number array.
  19806. * @param name Define the name of the uniform as defined in the shader
  19807. * @param value Define the value to give to the uniform
  19808. * @return the material itself allowing "fluent" like uniform updates
  19809. */
  19810. setArray4(name: string, value: number[]): ShaderMaterial;
  19811. private _checkCache;
  19812. /**
  19813. * Specifies that the submesh is ready to be used
  19814. * @param mesh defines the mesh to check
  19815. * @param subMesh defines which submesh to check
  19816. * @param useInstances specifies that instances should be used
  19817. * @returns a boolean indicating that the submesh is ready or not
  19818. */
  19819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19820. /**
  19821. * Checks if the material is ready to render the requested mesh
  19822. * @param mesh Define the mesh to render
  19823. * @param useInstances Define whether or not the material is used with instances
  19824. * @returns true if ready, otherwise false
  19825. */
  19826. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19827. /**
  19828. * Binds the world matrix to the material
  19829. * @param world defines the world transformation matrix
  19830. */
  19831. bindOnlyWorldMatrix(world: Matrix): void;
  19832. /**
  19833. * Binds the material to the mesh
  19834. * @param world defines the world transformation matrix
  19835. * @param mesh defines the mesh to bind the material to
  19836. */
  19837. bind(world: Matrix, mesh?: Mesh): void;
  19838. /**
  19839. * Gets the active textures from the material
  19840. * @returns an array of textures
  19841. */
  19842. getActiveTextures(): BaseTexture[];
  19843. /**
  19844. * Specifies if the material uses a texture
  19845. * @param texture defines the texture to check against the material
  19846. * @returns a boolean specifying if the material uses the texture
  19847. */
  19848. hasTexture(texture: BaseTexture): boolean;
  19849. /**
  19850. * Makes a duplicate of the material, and gives it a new name
  19851. * @param name defines the new name for the duplicated material
  19852. * @returns the cloned material
  19853. */
  19854. clone(name: string): ShaderMaterial;
  19855. /**
  19856. * Disposes the material
  19857. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19858. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19859. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19860. */
  19861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19862. /**
  19863. * Serializes this material in a JSON representation
  19864. * @returns the serialized material object
  19865. */
  19866. serialize(): any;
  19867. /**
  19868. * Creates a shader material from parsed shader material data
  19869. * @param source defines the JSON represnetation of the material
  19870. * @param scene defines the hosting scene
  19871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19872. * @returns a new material
  19873. */
  19874. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19875. }
  19876. }
  19877. declare module "babylonjs/Shaders/color.fragment" {
  19878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19879. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19880. /** @hidden */
  19881. export var colorPixelShader: {
  19882. name: string;
  19883. shader: string;
  19884. };
  19885. }
  19886. declare module "babylonjs/Shaders/color.vertex" {
  19887. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19888. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19889. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19890. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19891. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19893. /** @hidden */
  19894. export var colorVertexShader: {
  19895. name: string;
  19896. shader: string;
  19897. };
  19898. }
  19899. declare module "babylonjs/Meshes/linesMesh" {
  19900. import { Nullable } from "babylonjs/types";
  19901. import { Scene } from "babylonjs/scene";
  19902. import { Color3 } from "babylonjs/Maths/math.color";
  19903. import { Node } from "babylonjs/node";
  19904. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19905. import { Mesh } from "babylonjs/Meshes/mesh";
  19906. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19907. import { Effect } from "babylonjs/Materials/effect";
  19908. import { Material } from "babylonjs/Materials/material";
  19909. import "babylonjs/Shaders/color.fragment";
  19910. import "babylonjs/Shaders/color.vertex";
  19911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19912. /**
  19913. * Line mesh
  19914. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19915. */
  19916. export class LinesMesh extends Mesh {
  19917. /**
  19918. * If vertex color should be applied to the mesh
  19919. */
  19920. readonly useVertexColor?: boolean | undefined;
  19921. /**
  19922. * If vertex alpha should be applied to the mesh
  19923. */
  19924. readonly useVertexAlpha?: boolean | undefined;
  19925. /**
  19926. * Color of the line (Default: White)
  19927. */
  19928. color: Color3;
  19929. /**
  19930. * Alpha of the line (Default: 1)
  19931. */
  19932. alpha: number;
  19933. /**
  19934. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19935. * This margin is expressed in world space coordinates, so its value may vary.
  19936. * Default value is 0.1
  19937. */
  19938. intersectionThreshold: number;
  19939. private _colorShader;
  19940. private color4;
  19941. /**
  19942. * Creates a new LinesMesh
  19943. * @param name defines the name
  19944. * @param scene defines the hosting scene
  19945. * @param parent defines the parent mesh if any
  19946. * @param source defines the optional source LinesMesh used to clone data from
  19947. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19948. * When false, achieved by calling a clone(), also passing False.
  19949. * This will make creation of children, recursive.
  19950. * @param useVertexColor defines if this LinesMesh supports vertex color
  19951. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19952. */
  19953. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19954. /**
  19955. * If vertex color should be applied to the mesh
  19956. */
  19957. useVertexColor?: boolean | undefined,
  19958. /**
  19959. * If vertex alpha should be applied to the mesh
  19960. */
  19961. useVertexAlpha?: boolean | undefined);
  19962. private _addClipPlaneDefine;
  19963. private _removeClipPlaneDefine;
  19964. isReady(): boolean;
  19965. /**
  19966. * Returns the string "LineMesh"
  19967. */
  19968. getClassName(): string;
  19969. /**
  19970. * @hidden
  19971. */
  19972. /**
  19973. * @hidden
  19974. */
  19975. material: Material;
  19976. /**
  19977. * @hidden
  19978. */
  19979. readonly checkCollisions: boolean;
  19980. /** @hidden */
  19981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19982. /** @hidden */
  19983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19984. /**
  19985. * Disposes of the line mesh
  19986. * @param doNotRecurse If children should be disposed
  19987. */
  19988. dispose(doNotRecurse?: boolean): void;
  19989. /**
  19990. * Returns a new LineMesh object cloned from the current one.
  19991. */
  19992. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19993. /**
  19994. * Creates a new InstancedLinesMesh object from the mesh model.
  19995. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19996. * @param name defines the name of the new instance
  19997. * @returns a new InstancedLinesMesh
  19998. */
  19999. createInstance(name: string): InstancedLinesMesh;
  20000. }
  20001. /**
  20002. * Creates an instance based on a source LinesMesh
  20003. */
  20004. export class InstancedLinesMesh extends InstancedMesh {
  20005. /**
  20006. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20007. * This margin is expressed in world space coordinates, so its value may vary.
  20008. * Initilized with the intersectionThreshold value of the source LinesMesh
  20009. */
  20010. intersectionThreshold: number;
  20011. constructor(name: string, source: LinesMesh);
  20012. /**
  20013. * Returns the string "InstancedLinesMesh".
  20014. */
  20015. getClassName(): string;
  20016. }
  20017. }
  20018. declare module "babylonjs/Shaders/line.fragment" {
  20019. /** @hidden */
  20020. export var linePixelShader: {
  20021. name: string;
  20022. shader: string;
  20023. };
  20024. }
  20025. declare module "babylonjs/Shaders/line.vertex" {
  20026. /** @hidden */
  20027. export var lineVertexShader: {
  20028. name: string;
  20029. shader: string;
  20030. };
  20031. }
  20032. declare module "babylonjs/Rendering/edgesRenderer" {
  20033. import { Nullable } from "babylonjs/types";
  20034. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20036. import { Vector3 } from "babylonjs/Maths/math.vector";
  20037. import { IDisposable } from "babylonjs/scene";
  20038. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20039. import "babylonjs/Shaders/line.fragment";
  20040. import "babylonjs/Shaders/line.vertex";
  20041. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20042. module "babylonjs/Meshes/abstractMesh" {
  20043. interface AbstractMesh {
  20044. /**
  20045. * Gets the edgesRenderer associated with the mesh
  20046. */
  20047. edgesRenderer: Nullable<EdgesRenderer>;
  20048. }
  20049. }
  20050. module "babylonjs/Meshes/linesMesh" {
  20051. interface LinesMesh {
  20052. /**
  20053. * Enables the edge rendering mode on the mesh.
  20054. * This mode makes the mesh edges visible
  20055. * @param epsilon defines the maximal distance between two angles to detect a face
  20056. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20057. * @returns the currentAbstractMesh
  20058. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20059. */
  20060. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20061. }
  20062. }
  20063. module "babylonjs/Meshes/linesMesh" {
  20064. interface InstancedLinesMesh {
  20065. /**
  20066. * Enables the edge rendering mode on the mesh.
  20067. * This mode makes the mesh edges visible
  20068. * @param epsilon defines the maximal distance between two angles to detect a face
  20069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20070. * @returns the current InstancedLinesMesh
  20071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20072. */
  20073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20074. }
  20075. }
  20076. /**
  20077. * Defines the minimum contract an Edges renderer should follow.
  20078. */
  20079. export interface IEdgesRenderer extends IDisposable {
  20080. /**
  20081. * Gets or sets a boolean indicating if the edgesRenderer is active
  20082. */
  20083. isEnabled: boolean;
  20084. /**
  20085. * Renders the edges of the attached mesh,
  20086. */
  20087. render(): void;
  20088. /**
  20089. * Checks wether or not the edges renderer is ready to render.
  20090. * @return true if ready, otherwise false.
  20091. */
  20092. isReady(): boolean;
  20093. }
  20094. /**
  20095. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20096. */
  20097. export class EdgesRenderer implements IEdgesRenderer {
  20098. /**
  20099. * Define the size of the edges with an orthographic camera
  20100. */
  20101. edgesWidthScalerForOrthographic: number;
  20102. /**
  20103. * Define the size of the edges with a perspective camera
  20104. */
  20105. edgesWidthScalerForPerspective: number;
  20106. protected _source: AbstractMesh;
  20107. protected _linesPositions: number[];
  20108. protected _linesNormals: number[];
  20109. protected _linesIndices: number[];
  20110. protected _epsilon: number;
  20111. protected _indicesCount: number;
  20112. protected _lineShader: ShaderMaterial;
  20113. protected _ib: DataBuffer;
  20114. protected _buffers: {
  20115. [key: string]: Nullable<VertexBuffer>;
  20116. };
  20117. protected _checkVerticesInsteadOfIndices: boolean;
  20118. private _meshRebuildObserver;
  20119. private _meshDisposeObserver;
  20120. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20121. isEnabled: boolean;
  20122. /**
  20123. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20124. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20125. * @param source Mesh used to create edges
  20126. * @param epsilon sum of angles in adjacency to check for edge
  20127. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20128. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20129. */
  20130. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20131. protected _prepareRessources(): void;
  20132. /** @hidden */
  20133. _rebuild(): void;
  20134. /**
  20135. * Releases the required resources for the edges renderer
  20136. */
  20137. dispose(): void;
  20138. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20139. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20140. /**
  20141. * Checks if the pair of p0 and p1 is en edge
  20142. * @param faceIndex
  20143. * @param edge
  20144. * @param faceNormals
  20145. * @param p0
  20146. * @param p1
  20147. * @private
  20148. */
  20149. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20150. /**
  20151. * push line into the position, normal and index buffer
  20152. * @protected
  20153. */
  20154. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20155. /**
  20156. * Generates lines edges from adjacencjes
  20157. * @private
  20158. */
  20159. _generateEdgesLines(): void;
  20160. /**
  20161. * Checks wether or not the edges renderer is ready to render.
  20162. * @return true if ready, otherwise false.
  20163. */
  20164. isReady(): boolean;
  20165. /**
  20166. * Renders the edges of the attached mesh,
  20167. */
  20168. render(): void;
  20169. }
  20170. /**
  20171. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20172. */
  20173. export class LineEdgesRenderer extends EdgesRenderer {
  20174. /**
  20175. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20176. * @param source LineMesh used to generate edges
  20177. * @param epsilon not important (specified angle for edge detection)
  20178. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20179. */
  20180. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20181. /**
  20182. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20183. */
  20184. _generateEdgesLines(): void;
  20185. }
  20186. }
  20187. declare module "babylonjs/Rendering/renderingGroup" {
  20188. import { SmartArray } from "babylonjs/Misc/smartArray";
  20189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20191. import { Nullable } from "babylonjs/types";
  20192. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20193. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20194. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20195. import { Material } from "babylonjs/Materials/material";
  20196. import { Scene } from "babylonjs/scene";
  20197. /**
  20198. * This represents the object necessary to create a rendering group.
  20199. * This is exclusively used and created by the rendering manager.
  20200. * To modify the behavior, you use the available helpers in your scene or meshes.
  20201. * @hidden
  20202. */
  20203. export class RenderingGroup {
  20204. index: number;
  20205. private static _zeroVector;
  20206. private _scene;
  20207. private _opaqueSubMeshes;
  20208. private _transparentSubMeshes;
  20209. private _alphaTestSubMeshes;
  20210. private _depthOnlySubMeshes;
  20211. private _particleSystems;
  20212. private _spriteManagers;
  20213. private _opaqueSortCompareFn;
  20214. private _alphaTestSortCompareFn;
  20215. private _transparentSortCompareFn;
  20216. private _renderOpaque;
  20217. private _renderAlphaTest;
  20218. private _renderTransparent;
  20219. /** @hidden */
  20220. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20221. onBeforeTransparentRendering: () => void;
  20222. /**
  20223. * Set the opaque sort comparison function.
  20224. * If null the sub meshes will be render in the order they were created
  20225. */
  20226. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20227. /**
  20228. * Set the alpha test sort comparison function.
  20229. * If null the sub meshes will be render in the order they were created
  20230. */
  20231. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20232. /**
  20233. * Set the transparent sort comparison function.
  20234. * If null the sub meshes will be render in the order they were created
  20235. */
  20236. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20237. /**
  20238. * Creates a new rendering group.
  20239. * @param index The rendering group index
  20240. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20241. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20242. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20243. */
  20244. 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>);
  20245. /**
  20246. * Render all the sub meshes contained in the group.
  20247. * @param customRenderFunction Used to override the default render behaviour of the group.
  20248. * @returns true if rendered some submeshes.
  20249. */
  20250. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20251. /**
  20252. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20253. * @param subMeshes The submeshes to render
  20254. */
  20255. private renderOpaqueSorted;
  20256. /**
  20257. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20258. * @param subMeshes The submeshes to render
  20259. */
  20260. private renderAlphaTestSorted;
  20261. /**
  20262. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20263. * @param subMeshes The submeshes to render
  20264. */
  20265. private renderTransparentSorted;
  20266. /**
  20267. * Renders the submeshes in a specified order.
  20268. * @param subMeshes The submeshes to sort before render
  20269. * @param sortCompareFn The comparison function use to sort
  20270. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20271. * @param transparent Specifies to activate blending if true
  20272. */
  20273. private static renderSorted;
  20274. /**
  20275. * Renders the submeshes in the order they were dispatched (no sort applied).
  20276. * @param subMeshes The submeshes to render
  20277. */
  20278. private static renderUnsorted;
  20279. /**
  20280. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20281. * are rendered back to front if in the same alpha index.
  20282. *
  20283. * @param a The first submesh
  20284. * @param b The second submesh
  20285. * @returns The result of the comparison
  20286. */
  20287. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20288. /**
  20289. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20290. * are rendered back to front.
  20291. *
  20292. * @param a The first submesh
  20293. * @param b The second submesh
  20294. * @returns The result of the comparison
  20295. */
  20296. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20297. /**
  20298. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20299. * are rendered front to back (prevent overdraw).
  20300. *
  20301. * @param a The first submesh
  20302. * @param b The second submesh
  20303. * @returns The result of the comparison
  20304. */
  20305. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20306. /**
  20307. * Resets the different lists of submeshes to prepare a new frame.
  20308. */
  20309. prepare(): void;
  20310. dispose(): void;
  20311. /**
  20312. * Inserts the submesh in its correct queue depending on its material.
  20313. * @param subMesh The submesh to dispatch
  20314. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20315. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20316. */
  20317. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20318. dispatchSprites(spriteManager: ISpriteManager): void;
  20319. dispatchParticles(particleSystem: IParticleSystem): void;
  20320. private _renderParticles;
  20321. private _renderSprites;
  20322. }
  20323. }
  20324. declare module "babylonjs/Rendering/renderingManager" {
  20325. import { Nullable } from "babylonjs/types";
  20326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20327. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20328. import { SmartArray } from "babylonjs/Misc/smartArray";
  20329. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20330. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20331. import { Material } from "babylonjs/Materials/material";
  20332. import { Scene } from "babylonjs/scene";
  20333. import { Camera } from "babylonjs/Cameras/camera";
  20334. /**
  20335. * Interface describing the different options available in the rendering manager
  20336. * regarding Auto Clear between groups.
  20337. */
  20338. export interface IRenderingManagerAutoClearSetup {
  20339. /**
  20340. * Defines whether or not autoclear is enable.
  20341. */
  20342. autoClear: boolean;
  20343. /**
  20344. * Defines whether or not to autoclear the depth buffer.
  20345. */
  20346. depth: boolean;
  20347. /**
  20348. * Defines whether or not to autoclear the stencil buffer.
  20349. */
  20350. stencil: boolean;
  20351. }
  20352. /**
  20353. * This class is used by the onRenderingGroupObservable
  20354. */
  20355. export class RenderingGroupInfo {
  20356. /**
  20357. * The Scene that being rendered
  20358. */
  20359. scene: Scene;
  20360. /**
  20361. * The camera currently used for the rendering pass
  20362. */
  20363. camera: Nullable<Camera>;
  20364. /**
  20365. * The ID of the renderingGroup being processed
  20366. */
  20367. renderingGroupId: number;
  20368. }
  20369. /**
  20370. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20371. * It is enable to manage the different groups as well as the different necessary sort functions.
  20372. * This should not be used directly aside of the few static configurations
  20373. */
  20374. export class RenderingManager {
  20375. /**
  20376. * The max id used for rendering groups (not included)
  20377. */
  20378. static MAX_RENDERINGGROUPS: number;
  20379. /**
  20380. * The min id used for rendering groups (included)
  20381. */
  20382. static MIN_RENDERINGGROUPS: number;
  20383. /**
  20384. * Used to globally prevent autoclearing scenes.
  20385. */
  20386. static AUTOCLEAR: boolean;
  20387. /**
  20388. * @hidden
  20389. */
  20390. _useSceneAutoClearSetup: boolean;
  20391. private _scene;
  20392. private _renderingGroups;
  20393. private _depthStencilBufferAlreadyCleaned;
  20394. private _autoClearDepthStencil;
  20395. private _customOpaqueSortCompareFn;
  20396. private _customAlphaTestSortCompareFn;
  20397. private _customTransparentSortCompareFn;
  20398. private _renderingGroupInfo;
  20399. /**
  20400. * Instantiates a new rendering group for a particular scene
  20401. * @param scene Defines the scene the groups belongs to
  20402. */
  20403. constructor(scene: Scene);
  20404. private _clearDepthStencilBuffer;
  20405. /**
  20406. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20407. * @hidden
  20408. */
  20409. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20410. /**
  20411. * Resets the different information of the group to prepare a new frame
  20412. * @hidden
  20413. */
  20414. reset(): void;
  20415. /**
  20416. * Dispose and release the group and its associated resources.
  20417. * @hidden
  20418. */
  20419. dispose(): void;
  20420. /**
  20421. * Clear the info related to rendering groups preventing retention points during dispose.
  20422. */
  20423. freeRenderingGroups(): void;
  20424. private _prepareRenderingGroup;
  20425. /**
  20426. * Add a sprite manager to the rendering manager in order to render it this frame.
  20427. * @param spriteManager Define the sprite manager to render
  20428. */
  20429. dispatchSprites(spriteManager: ISpriteManager): void;
  20430. /**
  20431. * Add a particle system to the rendering manager in order to render it this frame.
  20432. * @param particleSystem Define the particle system to render
  20433. */
  20434. dispatchParticles(particleSystem: IParticleSystem): void;
  20435. /**
  20436. * Add a submesh to the manager in order to render it this frame
  20437. * @param subMesh The submesh to dispatch
  20438. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20439. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20440. */
  20441. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20442. /**
  20443. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20444. * This allowed control for front to back rendering or reversly depending of the special needs.
  20445. *
  20446. * @param renderingGroupId The rendering group id corresponding to its index
  20447. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20448. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20449. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20450. */
  20451. 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;
  20452. /**
  20453. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20454. *
  20455. * @param renderingGroupId The rendering group id corresponding to its index
  20456. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20457. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20458. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20459. */
  20460. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20461. /**
  20462. * Gets the current auto clear configuration for one rendering group of the rendering
  20463. * manager.
  20464. * @param index the rendering group index to get the information for
  20465. * @returns The auto clear setup for the requested rendering group
  20466. */
  20467. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20468. }
  20469. }
  20470. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20471. import { Observable } from "babylonjs/Misc/observable";
  20472. import { SmartArray } from "babylonjs/Misc/smartArray";
  20473. import { Nullable } from "babylonjs/types";
  20474. import { Camera } from "babylonjs/Cameras/camera";
  20475. import { Scene } from "babylonjs/scene";
  20476. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20477. import { Color4 } from "babylonjs/Maths/math.color";
  20478. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20481. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20482. import { Texture } from "babylonjs/Materials/Textures/texture";
  20483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20484. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20485. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20486. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20487. import { Engine } from "babylonjs/Engines/engine";
  20488. /**
  20489. * This Helps creating a texture that will be created from a camera in your scene.
  20490. * It is basically a dynamic texture that could be used to create special effects for instance.
  20491. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20492. */
  20493. export class RenderTargetTexture extends Texture {
  20494. isCube: boolean;
  20495. /**
  20496. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20497. */
  20498. static readonly REFRESHRATE_RENDER_ONCE: number;
  20499. /**
  20500. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20501. */
  20502. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20503. /**
  20504. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20505. * the central point of your effect and can save a lot of performances.
  20506. */
  20507. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20508. /**
  20509. * Use this predicate to dynamically define the list of mesh you want to render.
  20510. * If set, the renderList property will be overwritten.
  20511. */
  20512. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20513. private _renderList;
  20514. /**
  20515. * Use this list to define the list of mesh you want to render.
  20516. */
  20517. renderList: Nullable<Array<AbstractMesh>>;
  20518. private _hookArray;
  20519. /**
  20520. * Define if particles should be rendered in your texture.
  20521. */
  20522. renderParticles: boolean;
  20523. /**
  20524. * Define if sprites should be rendered in your texture.
  20525. */
  20526. renderSprites: boolean;
  20527. /**
  20528. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20529. */
  20530. coordinatesMode: number;
  20531. /**
  20532. * Define the camera used to render the texture.
  20533. */
  20534. activeCamera: Nullable<Camera>;
  20535. /**
  20536. * Override the render function of the texture with your own one.
  20537. */
  20538. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20539. /**
  20540. * Define if camera post processes should be use while rendering the texture.
  20541. */
  20542. useCameraPostProcesses: boolean;
  20543. /**
  20544. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20545. */
  20546. ignoreCameraViewport: boolean;
  20547. private _postProcessManager;
  20548. private _postProcesses;
  20549. private _resizeObserver;
  20550. /**
  20551. * An event triggered when the texture is unbind.
  20552. */
  20553. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20554. /**
  20555. * An event triggered when the texture is unbind.
  20556. */
  20557. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20558. private _onAfterUnbindObserver;
  20559. /**
  20560. * Set a after unbind callback in the texture.
  20561. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20562. */
  20563. onAfterUnbind: () => void;
  20564. /**
  20565. * An event triggered before rendering the texture
  20566. */
  20567. onBeforeRenderObservable: Observable<number>;
  20568. private _onBeforeRenderObserver;
  20569. /**
  20570. * Set a before render callback in the texture.
  20571. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20572. */
  20573. onBeforeRender: (faceIndex: number) => void;
  20574. /**
  20575. * An event triggered after rendering the texture
  20576. */
  20577. onAfterRenderObservable: Observable<number>;
  20578. private _onAfterRenderObserver;
  20579. /**
  20580. * Set a after render callback in the texture.
  20581. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20582. */
  20583. onAfterRender: (faceIndex: number) => void;
  20584. /**
  20585. * An event triggered after the texture clear
  20586. */
  20587. onClearObservable: Observable<Engine>;
  20588. private _onClearObserver;
  20589. /**
  20590. * Set a clear callback in the texture.
  20591. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20592. */
  20593. onClear: (Engine: Engine) => void;
  20594. /**
  20595. * An event triggered when the texture is resized.
  20596. */
  20597. onResizeObservable: Observable<RenderTargetTexture>;
  20598. /**
  20599. * Define the clear color of the Render Target if it should be different from the scene.
  20600. */
  20601. clearColor: Color4;
  20602. protected _size: number | {
  20603. width: number;
  20604. height: number;
  20605. };
  20606. protected _initialSizeParameter: number | {
  20607. width: number;
  20608. height: number;
  20609. } | {
  20610. ratio: number;
  20611. };
  20612. protected _sizeRatio: Nullable<number>;
  20613. /** @hidden */
  20614. _generateMipMaps: boolean;
  20615. protected _renderingManager: RenderingManager;
  20616. /** @hidden */
  20617. _waitingRenderList: string[];
  20618. protected _doNotChangeAspectRatio: boolean;
  20619. protected _currentRefreshId: number;
  20620. protected _refreshRate: number;
  20621. protected _textureMatrix: Matrix;
  20622. protected _samples: number;
  20623. protected _renderTargetOptions: RenderTargetCreationOptions;
  20624. /**
  20625. * Gets render target creation options that were used.
  20626. */
  20627. readonly renderTargetOptions: RenderTargetCreationOptions;
  20628. protected _engine: Engine;
  20629. protected _onRatioRescale(): void;
  20630. /**
  20631. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20632. * It must define where the camera used to render the texture is set
  20633. */
  20634. boundingBoxPosition: Vector3;
  20635. private _boundingBoxSize;
  20636. /**
  20637. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20638. * When defined, the cubemap will switch to local mode
  20639. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20640. * @example https://www.babylonjs-playground.com/#RNASML
  20641. */
  20642. boundingBoxSize: Vector3;
  20643. /**
  20644. * In case the RTT has been created with a depth texture, get the associated
  20645. * depth texture.
  20646. * Otherwise, return null.
  20647. */
  20648. depthStencilTexture: Nullable<InternalTexture>;
  20649. /**
  20650. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20651. * or used a shadow, depth texture...
  20652. * @param name The friendly name of the texture
  20653. * @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)
  20654. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20655. * @param generateMipMaps True if mip maps need to be generated after render.
  20656. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20657. * @param type The type of the buffer in the RTT (int, half float, float...)
  20658. * @param isCube True if a cube texture needs to be created
  20659. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20660. * @param generateDepthBuffer True to generate a depth buffer
  20661. * @param generateStencilBuffer True to generate a stencil buffer
  20662. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20663. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20665. */
  20666. constructor(name: string, size: number | {
  20667. width: number;
  20668. height: number;
  20669. } | {
  20670. ratio: number;
  20671. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20672. /**
  20673. * Creates a depth stencil texture.
  20674. * This is only available in WebGL 2 or with the depth texture extension available.
  20675. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20676. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20677. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20678. */
  20679. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20680. private _processSizeParameter;
  20681. /**
  20682. * Define the number of samples to use in case of MSAA.
  20683. * It defaults to one meaning no MSAA has been enabled.
  20684. */
  20685. samples: number;
  20686. /**
  20687. * Resets the refresh counter of the texture and start bak from scratch.
  20688. * Could be useful to regenerate the texture if it is setup to render only once.
  20689. */
  20690. resetRefreshCounter(): void;
  20691. /**
  20692. * Define the refresh rate of the texture or the rendering frequency.
  20693. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20694. */
  20695. refreshRate: number;
  20696. /**
  20697. * Adds a post process to the render target rendering passes.
  20698. * @param postProcess define the post process to add
  20699. */
  20700. addPostProcess(postProcess: PostProcess): void;
  20701. /**
  20702. * Clear all the post processes attached to the render target
  20703. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20704. */
  20705. clearPostProcesses(dispose?: boolean): void;
  20706. /**
  20707. * Remove one of the post process from the list of attached post processes to the texture
  20708. * @param postProcess define the post process to remove from the list
  20709. */
  20710. removePostProcess(postProcess: PostProcess): void;
  20711. /** @hidden */
  20712. _shouldRender(): boolean;
  20713. /**
  20714. * Gets the actual render size of the texture.
  20715. * @returns the width of the render size
  20716. */
  20717. getRenderSize(): number;
  20718. /**
  20719. * Gets the actual render width of the texture.
  20720. * @returns the width of the render size
  20721. */
  20722. getRenderWidth(): number;
  20723. /**
  20724. * Gets the actual render height of the texture.
  20725. * @returns the height of the render size
  20726. */
  20727. getRenderHeight(): number;
  20728. /**
  20729. * Get if the texture can be rescaled or not.
  20730. */
  20731. readonly canRescale: boolean;
  20732. /**
  20733. * Resize the texture using a ratio.
  20734. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20735. */
  20736. scale(ratio: number): void;
  20737. /**
  20738. * Get the texture reflection matrix used to rotate/transform the reflection.
  20739. * @returns the reflection matrix
  20740. */
  20741. getReflectionTextureMatrix(): Matrix;
  20742. /**
  20743. * Resize the texture to a new desired size.
  20744. * Be carrefull as it will recreate all the data in the new texture.
  20745. * @param size Define the new size. It can be:
  20746. * - a number for squared texture,
  20747. * - an object containing { width: number, height: number }
  20748. * - or an object containing a ratio { ratio: number }
  20749. */
  20750. resize(size: number | {
  20751. width: number;
  20752. height: number;
  20753. } | {
  20754. ratio: number;
  20755. }): void;
  20756. /**
  20757. * Renders all the objects from the render list into the texture.
  20758. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20759. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20760. */
  20761. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20762. private _bestReflectionRenderTargetDimension;
  20763. /**
  20764. * @hidden
  20765. * @param faceIndex face index to bind to if this is a cubetexture
  20766. */
  20767. _bindFrameBuffer(faceIndex?: number): void;
  20768. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20769. private renderToTarget;
  20770. /**
  20771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20772. * This allowed control for front to back rendering or reversly depending of the special needs.
  20773. *
  20774. * @param renderingGroupId The rendering group id corresponding to its index
  20775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20778. */
  20779. 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;
  20780. /**
  20781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20782. *
  20783. * @param renderingGroupId The rendering group id corresponding to its index
  20784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20785. */
  20786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20787. /**
  20788. * Clones the texture.
  20789. * @returns the cloned texture
  20790. */
  20791. clone(): RenderTargetTexture;
  20792. /**
  20793. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20794. * @returns The JSON representation of the texture
  20795. */
  20796. serialize(): any;
  20797. /**
  20798. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20799. */
  20800. disposeFramebufferObjects(): void;
  20801. /**
  20802. * Dispose the texture and release its associated resources.
  20803. */
  20804. dispose(): void;
  20805. /** @hidden */
  20806. _rebuild(): void;
  20807. /**
  20808. * Clear the info related to rendering groups preventing retention point in material dispose.
  20809. */
  20810. freeRenderingGroups(): void;
  20811. /**
  20812. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20813. * @returns the view count
  20814. */
  20815. getViewCount(): number;
  20816. }
  20817. }
  20818. declare module "babylonjs/Materials/material" {
  20819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20820. import { SmartArray } from "babylonjs/Misc/smartArray";
  20821. import { Observable } from "babylonjs/Misc/observable";
  20822. import { Nullable } from "babylonjs/types";
  20823. import { Scene } from "babylonjs/scene";
  20824. import { Matrix } from "babylonjs/Maths/math.vector";
  20825. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20828. import { Effect } from "babylonjs/Materials/effect";
  20829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20831. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20832. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20833. import { Mesh } from "babylonjs/Meshes/mesh";
  20834. import { Animation } from "babylonjs/Animations/animation";
  20835. /**
  20836. * Options for compiling materials.
  20837. */
  20838. export interface IMaterialCompilationOptions {
  20839. /**
  20840. * Defines whether clip planes are enabled.
  20841. */
  20842. clipPlane: boolean;
  20843. /**
  20844. * Defines whether instances are enabled.
  20845. */
  20846. useInstances: boolean;
  20847. }
  20848. /**
  20849. * Base class for the main features of a material in Babylon.js
  20850. */
  20851. export class Material implements IAnimatable {
  20852. /**
  20853. * Returns the triangle fill mode
  20854. */
  20855. static readonly TriangleFillMode: number;
  20856. /**
  20857. * Returns the wireframe mode
  20858. */
  20859. static readonly WireFrameFillMode: number;
  20860. /**
  20861. * Returns the point fill mode
  20862. */
  20863. static readonly PointFillMode: number;
  20864. /**
  20865. * Returns the point list draw mode
  20866. */
  20867. static readonly PointListDrawMode: number;
  20868. /**
  20869. * Returns the line list draw mode
  20870. */
  20871. static readonly LineListDrawMode: number;
  20872. /**
  20873. * Returns the line loop draw mode
  20874. */
  20875. static readonly LineLoopDrawMode: number;
  20876. /**
  20877. * Returns the line strip draw mode
  20878. */
  20879. static readonly LineStripDrawMode: number;
  20880. /**
  20881. * Returns the triangle strip draw mode
  20882. */
  20883. static readonly TriangleStripDrawMode: number;
  20884. /**
  20885. * Returns the triangle fan draw mode
  20886. */
  20887. static readonly TriangleFanDrawMode: number;
  20888. /**
  20889. * Stores the clock-wise side orientation
  20890. */
  20891. static readonly ClockWiseSideOrientation: number;
  20892. /**
  20893. * Stores the counter clock-wise side orientation
  20894. */
  20895. static readonly CounterClockWiseSideOrientation: number;
  20896. /**
  20897. * The dirty texture flag value
  20898. */
  20899. static readonly TextureDirtyFlag: number;
  20900. /**
  20901. * The dirty light flag value
  20902. */
  20903. static readonly LightDirtyFlag: number;
  20904. /**
  20905. * The dirty fresnel flag value
  20906. */
  20907. static readonly FresnelDirtyFlag: number;
  20908. /**
  20909. * The dirty attribute flag value
  20910. */
  20911. static readonly AttributesDirtyFlag: number;
  20912. /**
  20913. * The dirty misc flag value
  20914. */
  20915. static readonly MiscDirtyFlag: number;
  20916. /**
  20917. * The all dirty flag value
  20918. */
  20919. static readonly AllDirtyFlag: number;
  20920. /**
  20921. * The ID of the material
  20922. */
  20923. id: string;
  20924. /**
  20925. * Gets or sets the unique id of the material
  20926. */
  20927. uniqueId: number;
  20928. /**
  20929. * The name of the material
  20930. */
  20931. name: string;
  20932. /**
  20933. * Gets or sets user defined metadata
  20934. */
  20935. metadata: any;
  20936. /**
  20937. * For internal use only. Please do not use.
  20938. */
  20939. reservedDataStore: any;
  20940. /**
  20941. * Specifies if the ready state should be checked on each call
  20942. */
  20943. checkReadyOnEveryCall: boolean;
  20944. /**
  20945. * Specifies if the ready state should be checked once
  20946. */
  20947. checkReadyOnlyOnce: boolean;
  20948. /**
  20949. * The state of the material
  20950. */
  20951. state: string;
  20952. /**
  20953. * The alpha value of the material
  20954. */
  20955. protected _alpha: number;
  20956. /**
  20957. * List of inspectable custom properties (used by the Inspector)
  20958. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20959. */
  20960. inspectableCustomProperties: IInspectable[];
  20961. /**
  20962. * Sets the alpha value of the material
  20963. */
  20964. /**
  20965. * Gets the alpha value of the material
  20966. */
  20967. alpha: number;
  20968. /**
  20969. * Specifies if back face culling is enabled
  20970. */
  20971. protected _backFaceCulling: boolean;
  20972. /**
  20973. * Sets the back-face culling state
  20974. */
  20975. /**
  20976. * Gets the back-face culling state
  20977. */
  20978. backFaceCulling: boolean;
  20979. /**
  20980. * Stores the value for side orientation
  20981. */
  20982. sideOrientation: number;
  20983. /**
  20984. * Callback triggered when the material is compiled
  20985. */
  20986. onCompiled: Nullable<(effect: Effect) => void>;
  20987. /**
  20988. * Callback triggered when an error occurs
  20989. */
  20990. onError: Nullable<(effect: Effect, errors: string) => void>;
  20991. /**
  20992. * Callback triggered to get the render target textures
  20993. */
  20994. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20995. /**
  20996. * Gets a boolean indicating that current material needs to register RTT
  20997. */
  20998. readonly hasRenderTargetTextures: boolean;
  20999. /**
  21000. * Specifies if the material should be serialized
  21001. */
  21002. doNotSerialize: boolean;
  21003. /**
  21004. * @hidden
  21005. */
  21006. _storeEffectOnSubMeshes: boolean;
  21007. /**
  21008. * Stores the animations for the material
  21009. */
  21010. animations: Nullable<Array<Animation>>;
  21011. /**
  21012. * An event triggered when the material is disposed
  21013. */
  21014. onDisposeObservable: Observable<Material>;
  21015. /**
  21016. * An observer which watches for dispose events
  21017. */
  21018. private _onDisposeObserver;
  21019. private _onUnBindObservable;
  21020. /**
  21021. * Called during a dispose event
  21022. */
  21023. onDispose: () => void;
  21024. private _onBindObservable;
  21025. /**
  21026. * An event triggered when the material is bound
  21027. */
  21028. readonly onBindObservable: Observable<AbstractMesh>;
  21029. /**
  21030. * An observer which watches for bind events
  21031. */
  21032. private _onBindObserver;
  21033. /**
  21034. * Called during a bind event
  21035. */
  21036. onBind: (Mesh: AbstractMesh) => void;
  21037. /**
  21038. * An event triggered when the material is unbound
  21039. */
  21040. readonly onUnBindObservable: Observable<Material>;
  21041. /**
  21042. * Stores the value of the alpha mode
  21043. */
  21044. private _alphaMode;
  21045. /**
  21046. * Sets the value of the alpha mode.
  21047. *
  21048. * | Value | Type | Description |
  21049. * | --- | --- | --- |
  21050. * | 0 | ALPHA_DISABLE | |
  21051. * | 1 | ALPHA_ADD | |
  21052. * | 2 | ALPHA_COMBINE | |
  21053. * | 3 | ALPHA_SUBTRACT | |
  21054. * | 4 | ALPHA_MULTIPLY | |
  21055. * | 5 | ALPHA_MAXIMIZED | |
  21056. * | 6 | ALPHA_ONEONE | |
  21057. * | 7 | ALPHA_PREMULTIPLIED | |
  21058. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21059. * | 9 | ALPHA_INTERPOLATE | |
  21060. * | 10 | ALPHA_SCREENMODE | |
  21061. *
  21062. */
  21063. /**
  21064. * Gets the value of the alpha mode
  21065. */
  21066. alphaMode: number;
  21067. /**
  21068. * Stores the state of the need depth pre-pass value
  21069. */
  21070. private _needDepthPrePass;
  21071. /**
  21072. * Sets the need depth pre-pass value
  21073. */
  21074. /**
  21075. * Gets the depth pre-pass value
  21076. */
  21077. needDepthPrePass: boolean;
  21078. /**
  21079. * Specifies if depth writing should be disabled
  21080. */
  21081. disableDepthWrite: boolean;
  21082. /**
  21083. * Specifies if depth writing should be forced
  21084. */
  21085. forceDepthWrite: boolean;
  21086. /**
  21087. * Specifies if there should be a separate pass for culling
  21088. */
  21089. separateCullingPass: boolean;
  21090. /**
  21091. * Stores the state specifing if fog should be enabled
  21092. */
  21093. private _fogEnabled;
  21094. /**
  21095. * Sets the state for enabling fog
  21096. */
  21097. /**
  21098. * Gets the value of the fog enabled state
  21099. */
  21100. fogEnabled: boolean;
  21101. /**
  21102. * Stores the size of points
  21103. */
  21104. pointSize: number;
  21105. /**
  21106. * Stores the z offset value
  21107. */
  21108. zOffset: number;
  21109. /**
  21110. * Gets a value specifying if wireframe mode is enabled
  21111. */
  21112. /**
  21113. * Sets the state of wireframe mode
  21114. */
  21115. wireframe: boolean;
  21116. /**
  21117. * Gets the value specifying if point clouds are enabled
  21118. */
  21119. /**
  21120. * Sets the state of point cloud mode
  21121. */
  21122. pointsCloud: boolean;
  21123. /**
  21124. * Gets the material fill mode
  21125. */
  21126. /**
  21127. * Sets the material fill mode
  21128. */
  21129. fillMode: number;
  21130. /**
  21131. * @hidden
  21132. * Stores the effects for the material
  21133. */
  21134. _effect: Nullable<Effect>;
  21135. /**
  21136. * @hidden
  21137. * Specifies if the material was previously ready
  21138. */
  21139. _wasPreviouslyReady: boolean;
  21140. /**
  21141. * Specifies if uniform buffers should be used
  21142. */
  21143. private _useUBO;
  21144. /**
  21145. * Stores a reference to the scene
  21146. */
  21147. private _scene;
  21148. /**
  21149. * Stores the fill mode state
  21150. */
  21151. private _fillMode;
  21152. /**
  21153. * Specifies if the depth write state should be cached
  21154. */
  21155. private _cachedDepthWriteState;
  21156. /**
  21157. * Stores the uniform buffer
  21158. */
  21159. protected _uniformBuffer: UniformBuffer;
  21160. /** @hidden */
  21161. _indexInSceneMaterialArray: number;
  21162. /** @hidden */
  21163. meshMap: Nullable<{
  21164. [id: string]: AbstractMesh | undefined;
  21165. }>;
  21166. /**
  21167. * Creates a material instance
  21168. * @param name defines the name of the material
  21169. * @param scene defines the scene to reference
  21170. * @param doNotAdd specifies if the material should be added to the scene
  21171. */
  21172. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21173. /**
  21174. * Returns a string representation of the current material
  21175. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21176. * @returns a string with material information
  21177. */
  21178. toString(fullDetails?: boolean): string;
  21179. /**
  21180. * Gets the class name of the material
  21181. * @returns a string with the class name of the material
  21182. */
  21183. getClassName(): string;
  21184. /**
  21185. * Specifies if updates for the material been locked
  21186. */
  21187. readonly isFrozen: boolean;
  21188. /**
  21189. * Locks updates for the material
  21190. */
  21191. freeze(): void;
  21192. /**
  21193. * Unlocks updates for the material
  21194. */
  21195. unfreeze(): void;
  21196. /**
  21197. * Specifies if the material is ready to be used
  21198. * @param mesh defines the mesh to check
  21199. * @param useInstances specifies if instances should be used
  21200. * @returns a boolean indicating if the material is ready to be used
  21201. */
  21202. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21203. /**
  21204. * Specifies that the submesh is ready to be used
  21205. * @param mesh defines the mesh to check
  21206. * @param subMesh defines which submesh to check
  21207. * @param useInstances specifies that instances should be used
  21208. * @returns a boolean indicating that the submesh is ready or not
  21209. */
  21210. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21211. /**
  21212. * Returns the material effect
  21213. * @returns the effect associated with the material
  21214. */
  21215. getEffect(): Nullable<Effect>;
  21216. /**
  21217. * Returns the current scene
  21218. * @returns a Scene
  21219. */
  21220. getScene(): Scene;
  21221. /**
  21222. * Specifies if the material will require alpha blending
  21223. * @returns a boolean specifying if alpha blending is needed
  21224. */
  21225. needAlphaBlending(): boolean;
  21226. /**
  21227. * Specifies if the mesh will require alpha blending
  21228. * @param mesh defines the mesh to check
  21229. * @returns a boolean specifying if alpha blending is needed for the mesh
  21230. */
  21231. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21232. /**
  21233. * Specifies if this material should be rendered in alpha test mode
  21234. * @returns a boolean specifying if an alpha test is needed.
  21235. */
  21236. needAlphaTesting(): boolean;
  21237. /**
  21238. * Gets the texture used for the alpha test
  21239. * @returns the texture to use for alpha testing
  21240. */
  21241. getAlphaTestTexture(): Nullable<BaseTexture>;
  21242. /**
  21243. * Marks the material to indicate that it needs to be re-calculated
  21244. */
  21245. markDirty(): void;
  21246. /** @hidden */
  21247. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21248. /**
  21249. * Binds the material to the mesh
  21250. * @param world defines the world transformation matrix
  21251. * @param mesh defines the mesh to bind the material to
  21252. */
  21253. bind(world: Matrix, mesh?: Mesh): void;
  21254. /**
  21255. * Binds the submesh to the material
  21256. * @param world defines the world transformation matrix
  21257. * @param mesh defines the mesh containing the submesh
  21258. * @param subMesh defines the submesh to bind the material to
  21259. */
  21260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21261. /**
  21262. * Binds the world matrix to the material
  21263. * @param world defines the world transformation matrix
  21264. */
  21265. bindOnlyWorldMatrix(world: Matrix): void;
  21266. /**
  21267. * Binds the scene's uniform buffer to the effect.
  21268. * @param effect defines the effect to bind to the scene uniform buffer
  21269. * @param sceneUbo defines the uniform buffer storing scene data
  21270. */
  21271. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21272. /**
  21273. * Binds the view matrix to the effect
  21274. * @param effect defines the effect to bind the view matrix to
  21275. */
  21276. bindView(effect: Effect): void;
  21277. /**
  21278. * Binds the view projection matrix to the effect
  21279. * @param effect defines the effect to bind the view projection matrix to
  21280. */
  21281. bindViewProjection(effect: Effect): void;
  21282. /**
  21283. * Specifies if material alpha testing should be turned on for the mesh
  21284. * @param mesh defines the mesh to check
  21285. */
  21286. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21287. /**
  21288. * Processes to execute after binding the material to a mesh
  21289. * @param mesh defines the rendered mesh
  21290. */
  21291. protected _afterBind(mesh?: Mesh): void;
  21292. /**
  21293. * Unbinds the material from the mesh
  21294. */
  21295. unbind(): void;
  21296. /**
  21297. * Gets the active textures from the material
  21298. * @returns an array of textures
  21299. */
  21300. getActiveTextures(): BaseTexture[];
  21301. /**
  21302. * Specifies if the material uses a texture
  21303. * @param texture defines the texture to check against the material
  21304. * @returns a boolean specifying if the material uses the texture
  21305. */
  21306. hasTexture(texture: BaseTexture): boolean;
  21307. /**
  21308. * Makes a duplicate of the material, and gives it a new name
  21309. * @param name defines the new name for the duplicated material
  21310. * @returns the cloned material
  21311. */
  21312. clone(name: string): Nullable<Material>;
  21313. /**
  21314. * Gets the meshes bound to the material
  21315. * @returns an array of meshes bound to the material
  21316. */
  21317. getBindedMeshes(): AbstractMesh[];
  21318. /**
  21319. * Force shader compilation
  21320. * @param mesh defines the mesh associated with this material
  21321. * @param onCompiled defines a function to execute once the material is compiled
  21322. * @param options defines the options to configure the compilation
  21323. * @param onError defines a function to execute if the material fails compiling
  21324. */
  21325. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21326. /**
  21327. * Force shader compilation
  21328. * @param mesh defines the mesh that will use this material
  21329. * @param options defines additional options for compiling the shaders
  21330. * @returns a promise that resolves when the compilation completes
  21331. */
  21332. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21333. private static readonly _AllDirtyCallBack;
  21334. private static readonly _ImageProcessingDirtyCallBack;
  21335. private static readonly _TextureDirtyCallBack;
  21336. private static readonly _FresnelDirtyCallBack;
  21337. private static readonly _MiscDirtyCallBack;
  21338. private static readonly _LightsDirtyCallBack;
  21339. private static readonly _AttributeDirtyCallBack;
  21340. private static _FresnelAndMiscDirtyCallBack;
  21341. private static _TextureAndMiscDirtyCallBack;
  21342. private static readonly _DirtyCallbackArray;
  21343. private static readonly _RunDirtyCallBacks;
  21344. /**
  21345. * Marks a define in the material to indicate that it needs to be re-computed
  21346. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21347. */
  21348. markAsDirty(flag: number): void;
  21349. /**
  21350. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21351. * @param func defines a function which checks material defines against the submeshes
  21352. */
  21353. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21354. /**
  21355. * Indicates that we need to re-calculated for all submeshes
  21356. */
  21357. protected _markAllSubMeshesAsAllDirty(): void;
  21358. /**
  21359. * Indicates that image processing needs to be re-calculated for all submeshes
  21360. */
  21361. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21362. /**
  21363. * Indicates that textures need to be re-calculated for all submeshes
  21364. */
  21365. protected _markAllSubMeshesAsTexturesDirty(): void;
  21366. /**
  21367. * Indicates that fresnel needs to be re-calculated for all submeshes
  21368. */
  21369. protected _markAllSubMeshesAsFresnelDirty(): void;
  21370. /**
  21371. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21372. */
  21373. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21374. /**
  21375. * Indicates that lights need to be re-calculated for all submeshes
  21376. */
  21377. protected _markAllSubMeshesAsLightsDirty(): void;
  21378. /**
  21379. * Indicates that attributes need to be re-calculated for all submeshes
  21380. */
  21381. protected _markAllSubMeshesAsAttributesDirty(): void;
  21382. /**
  21383. * Indicates that misc needs to be re-calculated for all submeshes
  21384. */
  21385. protected _markAllSubMeshesAsMiscDirty(): void;
  21386. /**
  21387. * Indicates that textures and misc need to be re-calculated for all submeshes
  21388. */
  21389. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21390. /**
  21391. * Disposes the material
  21392. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21393. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21394. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21395. */
  21396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21397. /** @hidden */
  21398. private releaseVertexArrayObject;
  21399. /**
  21400. * Serializes this material
  21401. * @returns the serialized material object
  21402. */
  21403. serialize(): any;
  21404. /**
  21405. * Creates a material from parsed material data
  21406. * @param parsedMaterial defines parsed material data
  21407. * @param scene defines the hosting scene
  21408. * @param rootUrl defines the root URL to use to load textures
  21409. * @returns a new material
  21410. */
  21411. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21412. }
  21413. }
  21414. declare module "babylonjs/Materials/multiMaterial" {
  21415. import { Nullable } from "babylonjs/types";
  21416. import { Scene } from "babylonjs/scene";
  21417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21418. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21420. import { Material } from "babylonjs/Materials/material";
  21421. /**
  21422. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21423. * separate meshes. This can be use to improve performances.
  21424. * @see http://doc.babylonjs.com/how_to/multi_materials
  21425. */
  21426. export class MultiMaterial extends Material {
  21427. private _subMaterials;
  21428. /**
  21429. * Gets or Sets the list of Materials used within the multi material.
  21430. * They need to be ordered according to the submeshes order in the associated mesh
  21431. */
  21432. subMaterials: Nullable<Material>[];
  21433. /**
  21434. * Function used to align with Node.getChildren()
  21435. * @returns the list of Materials used within the multi material
  21436. */
  21437. getChildren(): Nullable<Material>[];
  21438. /**
  21439. * Instantiates a new Multi Material
  21440. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21441. * separate meshes. This can be use to improve performances.
  21442. * @see http://doc.babylonjs.com/how_to/multi_materials
  21443. * @param name Define the name in the scene
  21444. * @param scene Define the scene the material belongs to
  21445. */
  21446. constructor(name: string, scene: Scene);
  21447. private _hookArray;
  21448. /**
  21449. * Get one of the submaterial by its index in the submaterials array
  21450. * @param index The index to look the sub material at
  21451. * @returns The Material if the index has been defined
  21452. */
  21453. getSubMaterial(index: number): Nullable<Material>;
  21454. /**
  21455. * Get the list of active textures for the whole sub materials list.
  21456. * @returns All the textures that will be used during the rendering
  21457. */
  21458. getActiveTextures(): BaseTexture[];
  21459. /**
  21460. * Gets the current class name of the material e.g. "MultiMaterial"
  21461. * Mainly use in serialization.
  21462. * @returns the class name
  21463. */
  21464. getClassName(): string;
  21465. /**
  21466. * Checks if the material is ready to render the requested sub mesh
  21467. * @param mesh Define the mesh the submesh belongs to
  21468. * @param subMesh Define the sub mesh to look readyness for
  21469. * @param useInstances Define whether or not the material is used with instances
  21470. * @returns true if ready, otherwise false
  21471. */
  21472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21473. /**
  21474. * Clones the current material and its related sub materials
  21475. * @param name Define the name of the newly cloned material
  21476. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21477. * @returns the cloned material
  21478. */
  21479. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21480. /**
  21481. * Serializes the materials into a JSON representation.
  21482. * @returns the JSON representation
  21483. */
  21484. serialize(): any;
  21485. /**
  21486. * Dispose the material and release its associated resources
  21487. * @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)
  21488. * @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)
  21489. * @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)
  21490. */
  21491. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21492. /**
  21493. * Creates a MultiMaterial from parsed MultiMaterial data.
  21494. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21495. * @param scene defines the hosting scene
  21496. * @returns a new MultiMaterial
  21497. */
  21498. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21499. }
  21500. }
  21501. declare module "babylonjs/Meshes/subMesh" {
  21502. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21503. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21504. import { Engine } from "babylonjs/Engines/engine";
  21505. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21506. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21507. import { Effect } from "babylonjs/Materials/effect";
  21508. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21509. import { Plane } from "babylonjs/Maths/math.plane";
  21510. import { Collider } from "babylonjs/Collisions/collider";
  21511. import { Material } from "babylonjs/Materials/material";
  21512. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21514. import { Mesh } from "babylonjs/Meshes/mesh";
  21515. import { Ray } from "babylonjs/Culling/ray";
  21516. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21517. /**
  21518. * Base class for submeshes
  21519. */
  21520. export class BaseSubMesh {
  21521. /** @hidden */
  21522. _materialDefines: Nullable<MaterialDefines>;
  21523. /** @hidden */
  21524. _materialEffect: Nullable<Effect>;
  21525. /**
  21526. * Gets associated effect
  21527. */
  21528. readonly effect: Nullable<Effect>;
  21529. /**
  21530. * Sets associated effect (effect used to render this submesh)
  21531. * @param effect defines the effect to associate with
  21532. * @param defines defines the set of defines used to compile this effect
  21533. */
  21534. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21535. }
  21536. /**
  21537. * Defines a subdivision inside a mesh
  21538. */
  21539. export class SubMesh extends BaseSubMesh implements ICullable {
  21540. /** the material index to use */
  21541. materialIndex: number;
  21542. /** vertex index start */
  21543. verticesStart: number;
  21544. /** vertices count */
  21545. verticesCount: number;
  21546. /** index start */
  21547. indexStart: number;
  21548. /** indices count */
  21549. indexCount: number;
  21550. /** @hidden */
  21551. _linesIndexCount: number;
  21552. private _mesh;
  21553. private _renderingMesh;
  21554. private _boundingInfo;
  21555. private _linesIndexBuffer;
  21556. /** @hidden */
  21557. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21558. /** @hidden */
  21559. _trianglePlanes: Plane[];
  21560. /** @hidden */
  21561. _lastColliderTransformMatrix: Nullable<Matrix>;
  21562. /** @hidden */
  21563. _renderId: number;
  21564. /** @hidden */
  21565. _alphaIndex: number;
  21566. /** @hidden */
  21567. _distanceToCamera: number;
  21568. /** @hidden */
  21569. _id: number;
  21570. private _currentMaterial;
  21571. /**
  21572. * Add a new submesh to a mesh
  21573. * @param materialIndex defines the material index to use
  21574. * @param verticesStart defines vertex index start
  21575. * @param verticesCount defines vertices count
  21576. * @param indexStart defines index start
  21577. * @param indexCount defines indices count
  21578. * @param mesh defines the parent mesh
  21579. * @param renderingMesh defines an optional rendering mesh
  21580. * @param createBoundingBox defines if bounding box should be created for this submesh
  21581. * @returns the new submesh
  21582. */
  21583. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21584. /**
  21585. * Creates a new submesh
  21586. * @param materialIndex defines the material index to use
  21587. * @param verticesStart defines vertex index start
  21588. * @param verticesCount defines vertices count
  21589. * @param indexStart defines index start
  21590. * @param indexCount defines indices count
  21591. * @param mesh defines the parent mesh
  21592. * @param renderingMesh defines an optional rendering mesh
  21593. * @param createBoundingBox defines if bounding box should be created for this submesh
  21594. */
  21595. constructor(
  21596. /** the material index to use */
  21597. materialIndex: number,
  21598. /** vertex index start */
  21599. verticesStart: number,
  21600. /** vertices count */
  21601. verticesCount: number,
  21602. /** index start */
  21603. indexStart: number,
  21604. /** indices count */
  21605. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21606. /**
  21607. * Returns true if this submesh covers the entire parent mesh
  21608. * @ignorenaming
  21609. */
  21610. readonly IsGlobal: boolean;
  21611. /**
  21612. * Returns the submesh BoudingInfo object
  21613. * @returns current bounding info (or mesh's one if the submesh is global)
  21614. */
  21615. getBoundingInfo(): BoundingInfo;
  21616. /**
  21617. * Sets the submesh BoundingInfo
  21618. * @param boundingInfo defines the new bounding info to use
  21619. * @returns the SubMesh
  21620. */
  21621. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21622. /**
  21623. * Returns the mesh of the current submesh
  21624. * @return the parent mesh
  21625. */
  21626. getMesh(): AbstractMesh;
  21627. /**
  21628. * Returns the rendering mesh of the submesh
  21629. * @returns the rendering mesh (could be different from parent mesh)
  21630. */
  21631. getRenderingMesh(): Mesh;
  21632. /**
  21633. * Returns the submesh material
  21634. * @returns null or the current material
  21635. */
  21636. getMaterial(): Nullable<Material>;
  21637. /**
  21638. * Sets a new updated BoundingInfo object to the submesh
  21639. * @param data defines an optional position array to use to determine the bounding info
  21640. * @returns the SubMesh
  21641. */
  21642. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21643. /** @hidden */
  21644. _checkCollision(collider: Collider): boolean;
  21645. /**
  21646. * Updates the submesh BoundingInfo
  21647. * @param world defines the world matrix to use to update the bounding info
  21648. * @returns the submesh
  21649. */
  21650. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21651. /**
  21652. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21653. * @param frustumPlanes defines the frustum planes
  21654. * @returns true if the submesh is intersecting with the frustum
  21655. */
  21656. isInFrustum(frustumPlanes: Plane[]): boolean;
  21657. /**
  21658. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21659. * @param frustumPlanes defines the frustum planes
  21660. * @returns true if the submesh is inside the frustum
  21661. */
  21662. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21663. /**
  21664. * Renders the submesh
  21665. * @param enableAlphaMode defines if alpha needs to be used
  21666. * @returns the submesh
  21667. */
  21668. render(enableAlphaMode: boolean): SubMesh;
  21669. /**
  21670. * @hidden
  21671. */
  21672. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21673. /**
  21674. * Checks if the submesh intersects with a ray
  21675. * @param ray defines the ray to test
  21676. * @returns true is the passed ray intersects the submesh bounding box
  21677. */
  21678. canIntersects(ray: Ray): boolean;
  21679. /**
  21680. * Intersects current submesh with a ray
  21681. * @param ray defines the ray to test
  21682. * @param positions defines mesh's positions array
  21683. * @param indices defines mesh's indices array
  21684. * @param fastCheck defines if only bounding info should be used
  21685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21686. * @returns intersection info or null if no intersection
  21687. */
  21688. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21689. /** @hidden */
  21690. private _intersectLines;
  21691. /** @hidden */
  21692. private _intersectUnIndexedLines;
  21693. /** @hidden */
  21694. private _intersectTriangles;
  21695. /** @hidden */
  21696. private _intersectUnIndexedTriangles;
  21697. /** @hidden */
  21698. _rebuild(): void;
  21699. /**
  21700. * Creates a new submesh from the passed mesh
  21701. * @param newMesh defines the new hosting mesh
  21702. * @param newRenderingMesh defines an optional rendering mesh
  21703. * @returns the new submesh
  21704. */
  21705. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21706. /**
  21707. * Release associated resources
  21708. */
  21709. dispose(): void;
  21710. /**
  21711. * Gets the class name
  21712. * @returns the string "SubMesh".
  21713. */
  21714. getClassName(): string;
  21715. /**
  21716. * Creates a new submesh from indices data
  21717. * @param materialIndex the index of the main mesh material
  21718. * @param startIndex the index where to start the copy in the mesh indices array
  21719. * @param indexCount the number of indices to copy then from the startIndex
  21720. * @param mesh the main mesh to create the submesh from
  21721. * @param renderingMesh the optional rendering mesh
  21722. * @returns a new submesh
  21723. */
  21724. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21725. }
  21726. }
  21727. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21728. /**
  21729. * Class used to represent data loading progression
  21730. */
  21731. export class SceneLoaderFlags {
  21732. private static _ForceFullSceneLoadingForIncremental;
  21733. private static _ShowLoadingScreen;
  21734. private static _CleanBoneMatrixWeights;
  21735. private static _loggingLevel;
  21736. /**
  21737. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21738. */
  21739. static ForceFullSceneLoadingForIncremental: boolean;
  21740. /**
  21741. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21742. */
  21743. static ShowLoadingScreen: boolean;
  21744. /**
  21745. * Defines the current logging level (while loading the scene)
  21746. * @ignorenaming
  21747. */
  21748. static loggingLevel: number;
  21749. /**
  21750. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21751. */
  21752. static CleanBoneMatrixWeights: boolean;
  21753. }
  21754. }
  21755. declare module "babylonjs/Meshes/geometry" {
  21756. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21757. import { Scene } from "babylonjs/scene";
  21758. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21759. import { Engine } from "babylonjs/Engines/engine";
  21760. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21761. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21762. import { Effect } from "babylonjs/Materials/effect";
  21763. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21765. import { Mesh } from "babylonjs/Meshes/mesh";
  21766. /**
  21767. * Class used to store geometry data (vertex buffers + index buffer)
  21768. */
  21769. export class Geometry implements IGetSetVerticesData {
  21770. /**
  21771. * Gets or sets the ID of the geometry
  21772. */
  21773. id: string;
  21774. /**
  21775. * Gets or sets the unique ID of the geometry
  21776. */
  21777. uniqueId: number;
  21778. /**
  21779. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21780. */
  21781. delayLoadState: number;
  21782. /**
  21783. * Gets the file containing the data to load when running in delay load state
  21784. */
  21785. delayLoadingFile: Nullable<string>;
  21786. /**
  21787. * Callback called when the geometry is updated
  21788. */
  21789. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21790. private _scene;
  21791. private _engine;
  21792. private _meshes;
  21793. private _totalVertices;
  21794. /** @hidden */
  21795. _indices: IndicesArray;
  21796. /** @hidden */
  21797. _vertexBuffers: {
  21798. [key: string]: VertexBuffer;
  21799. };
  21800. private _isDisposed;
  21801. private _extend;
  21802. private _boundingBias;
  21803. /** @hidden */
  21804. _delayInfo: Array<string>;
  21805. private _indexBuffer;
  21806. private _indexBufferIsUpdatable;
  21807. /** @hidden */
  21808. _boundingInfo: Nullable<BoundingInfo>;
  21809. /** @hidden */
  21810. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21811. /** @hidden */
  21812. _softwareSkinningFrameId: number;
  21813. private _vertexArrayObjects;
  21814. private _updatable;
  21815. /** @hidden */
  21816. _positions: Nullable<Vector3[]>;
  21817. /**
  21818. * 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
  21819. */
  21820. /**
  21821. * 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
  21822. */
  21823. boundingBias: Vector2;
  21824. /**
  21825. * Static function used to attach a new empty geometry to a mesh
  21826. * @param mesh defines the mesh to attach the geometry to
  21827. * @returns the new Geometry
  21828. */
  21829. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21830. /**
  21831. * Creates a new geometry
  21832. * @param id defines the unique ID
  21833. * @param scene defines the hosting scene
  21834. * @param vertexData defines the VertexData used to get geometry data
  21835. * @param updatable defines if geometry must be updatable (false by default)
  21836. * @param mesh defines the mesh that will be associated with the geometry
  21837. */
  21838. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21839. /**
  21840. * Gets the current extend of the geometry
  21841. */
  21842. readonly extend: {
  21843. minimum: Vector3;
  21844. maximum: Vector3;
  21845. };
  21846. /**
  21847. * Gets the hosting scene
  21848. * @returns the hosting Scene
  21849. */
  21850. getScene(): Scene;
  21851. /**
  21852. * Gets the hosting engine
  21853. * @returns the hosting Engine
  21854. */
  21855. getEngine(): Engine;
  21856. /**
  21857. * Defines if the geometry is ready to use
  21858. * @returns true if the geometry is ready to be used
  21859. */
  21860. isReady(): boolean;
  21861. /**
  21862. * Gets a value indicating that the geometry should not be serialized
  21863. */
  21864. readonly doNotSerialize: boolean;
  21865. /** @hidden */
  21866. _rebuild(): void;
  21867. /**
  21868. * Affects all geometry data in one call
  21869. * @param vertexData defines the geometry data
  21870. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21871. */
  21872. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21873. /**
  21874. * Set specific vertex data
  21875. * @param kind defines the data kind (Position, normal, etc...)
  21876. * @param data defines the vertex data to use
  21877. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21878. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21879. */
  21880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21881. /**
  21882. * Removes a specific vertex data
  21883. * @param kind defines the data kind (Position, normal, etc...)
  21884. */
  21885. removeVerticesData(kind: string): void;
  21886. /**
  21887. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21888. * @param buffer defines the vertex buffer to use
  21889. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21890. */
  21891. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21892. /**
  21893. * Update a specific vertex buffer
  21894. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21895. * It will do nothing if the buffer is not updatable
  21896. * @param kind defines the data kind (Position, normal, etc...)
  21897. * @param data defines the data to use
  21898. * @param offset defines the offset in the target buffer where to store the data
  21899. * @param useBytes set to true if the offset is in bytes
  21900. */
  21901. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21902. /**
  21903. * Update a specific vertex buffer
  21904. * This function will create a new buffer if the current one is not updatable
  21905. * @param kind defines the data kind (Position, normal, etc...)
  21906. * @param data defines the data to use
  21907. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21908. */
  21909. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21910. private _updateBoundingInfo;
  21911. /** @hidden */
  21912. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21913. /**
  21914. * Gets total number of vertices
  21915. * @returns the total number of vertices
  21916. */
  21917. getTotalVertices(): number;
  21918. /**
  21919. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21920. * @param kind defines the data kind (Position, normal, etc...)
  21921. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21923. * @returns a float array containing vertex data
  21924. */
  21925. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21926. /**
  21927. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21928. * @param kind defines the data kind (Position, normal, etc...)
  21929. * @returns true if the vertex buffer with the specified kind is updatable
  21930. */
  21931. isVertexBufferUpdatable(kind: string): boolean;
  21932. /**
  21933. * Gets a specific vertex buffer
  21934. * @param kind defines the data kind (Position, normal, etc...)
  21935. * @returns a VertexBuffer
  21936. */
  21937. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21938. /**
  21939. * Returns all vertex buffers
  21940. * @return an object holding all vertex buffers indexed by kind
  21941. */
  21942. getVertexBuffers(): Nullable<{
  21943. [key: string]: VertexBuffer;
  21944. }>;
  21945. /**
  21946. * Gets a boolean indicating if specific vertex buffer is present
  21947. * @param kind defines the data kind (Position, normal, etc...)
  21948. * @returns true if data is present
  21949. */
  21950. isVerticesDataPresent(kind: string): boolean;
  21951. /**
  21952. * Gets a list of all attached data kinds (Position, normal, etc...)
  21953. * @returns a list of string containing all kinds
  21954. */
  21955. getVerticesDataKinds(): string[];
  21956. /**
  21957. * Update index buffer
  21958. * @param indices defines the indices to store in the index buffer
  21959. * @param offset defines the offset in the target buffer where to store the data
  21960. * @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)
  21961. */
  21962. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21963. /**
  21964. * Creates a new index buffer
  21965. * @param indices defines the indices to store in the index buffer
  21966. * @param totalVertices defines the total number of vertices (could be null)
  21967. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21968. */
  21969. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21970. /**
  21971. * Return the total number of indices
  21972. * @returns the total number of indices
  21973. */
  21974. getTotalIndices(): number;
  21975. /**
  21976. * Gets the index buffer array
  21977. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21978. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21979. * @returns the index buffer array
  21980. */
  21981. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21982. /**
  21983. * Gets the index buffer
  21984. * @return the index buffer
  21985. */
  21986. getIndexBuffer(): Nullable<DataBuffer>;
  21987. /** @hidden */
  21988. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21989. /**
  21990. * Release the associated resources for a specific mesh
  21991. * @param mesh defines the source mesh
  21992. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21993. */
  21994. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21995. /**
  21996. * Apply current geometry to a given mesh
  21997. * @param mesh defines the mesh to apply geometry to
  21998. */
  21999. applyToMesh(mesh: Mesh): void;
  22000. private _updateExtend;
  22001. private _applyToMesh;
  22002. private notifyUpdate;
  22003. /**
  22004. * Load the geometry if it was flagged as delay loaded
  22005. * @param scene defines the hosting scene
  22006. * @param onLoaded defines a callback called when the geometry is loaded
  22007. */
  22008. load(scene: Scene, onLoaded?: () => void): void;
  22009. private _queueLoad;
  22010. /**
  22011. * Invert the geometry to move from a right handed system to a left handed one.
  22012. */
  22013. toLeftHanded(): void;
  22014. /** @hidden */
  22015. _resetPointsArrayCache(): void;
  22016. /** @hidden */
  22017. _generatePointsArray(): boolean;
  22018. /**
  22019. * Gets a value indicating if the geometry is disposed
  22020. * @returns true if the geometry was disposed
  22021. */
  22022. isDisposed(): boolean;
  22023. private _disposeVertexArrayObjects;
  22024. /**
  22025. * Free all associated resources
  22026. */
  22027. dispose(): void;
  22028. /**
  22029. * Clone the current geometry into a new geometry
  22030. * @param id defines the unique ID of the new geometry
  22031. * @returns a new geometry object
  22032. */
  22033. copy(id: string): Geometry;
  22034. /**
  22035. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22036. * @return a JSON representation of the current geometry data (without the vertices data)
  22037. */
  22038. serialize(): any;
  22039. private toNumberArray;
  22040. /**
  22041. * Serialize all vertices data into a JSON oject
  22042. * @returns a JSON representation of the current geometry data
  22043. */
  22044. serializeVerticeData(): any;
  22045. /**
  22046. * Extracts a clone of a mesh geometry
  22047. * @param mesh defines the source mesh
  22048. * @param id defines the unique ID of the new geometry object
  22049. * @returns the new geometry object
  22050. */
  22051. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22052. /**
  22053. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22054. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22055. * Be aware Math.random() could cause collisions, but:
  22056. * "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"
  22057. * @returns a string containing a new GUID
  22058. */
  22059. static RandomId(): string;
  22060. /** @hidden */
  22061. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22062. private static _CleanMatricesWeights;
  22063. /**
  22064. * Create a new geometry from persisted data (Using .babylon file format)
  22065. * @param parsedVertexData defines the persisted data
  22066. * @param scene defines the hosting scene
  22067. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22068. * @returns the new geometry object
  22069. */
  22070. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22071. }
  22072. }
  22073. declare module "babylonjs/Meshes/mesh.vertexData" {
  22074. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22075. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22076. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22077. import { Geometry } from "babylonjs/Meshes/geometry";
  22078. import { Mesh } from "babylonjs/Meshes/mesh";
  22079. /**
  22080. * Define an interface for all classes that will get and set the data on vertices
  22081. */
  22082. export interface IGetSetVerticesData {
  22083. /**
  22084. * Gets a boolean indicating if specific vertex data is present
  22085. * @param kind defines the vertex data kind to use
  22086. * @returns true is data kind is present
  22087. */
  22088. isVerticesDataPresent(kind: string): boolean;
  22089. /**
  22090. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22091. * @param kind defines the data kind (Position, normal, etc...)
  22092. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22093. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22094. * @returns a float array containing vertex data
  22095. */
  22096. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22097. /**
  22098. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22099. * @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.
  22100. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22101. * @returns the indices array or an empty array if the mesh has no geometry
  22102. */
  22103. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22104. /**
  22105. * Set specific vertex data
  22106. * @param kind defines the data kind (Position, normal, etc...)
  22107. * @param data defines the vertex data to use
  22108. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22109. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22110. */
  22111. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22112. /**
  22113. * Update a specific associated vertex buffer
  22114. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22115. * - VertexBuffer.PositionKind
  22116. * - VertexBuffer.UVKind
  22117. * - VertexBuffer.UV2Kind
  22118. * - VertexBuffer.UV3Kind
  22119. * - VertexBuffer.UV4Kind
  22120. * - VertexBuffer.UV5Kind
  22121. * - VertexBuffer.UV6Kind
  22122. * - VertexBuffer.ColorKind
  22123. * - VertexBuffer.MatricesIndicesKind
  22124. * - VertexBuffer.MatricesIndicesExtraKind
  22125. * - VertexBuffer.MatricesWeightsKind
  22126. * - VertexBuffer.MatricesWeightsExtraKind
  22127. * @param data defines the data source
  22128. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22129. * @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)
  22130. */
  22131. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22132. /**
  22133. * Creates a new index buffer
  22134. * @param indices defines the indices to store in the index buffer
  22135. * @param totalVertices defines the total number of vertices (could be null)
  22136. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22137. */
  22138. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22139. }
  22140. /**
  22141. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22142. */
  22143. export class VertexData {
  22144. /**
  22145. * Mesh side orientation : usually the external or front surface
  22146. */
  22147. static readonly FRONTSIDE: number;
  22148. /**
  22149. * Mesh side orientation : usually the internal or back surface
  22150. */
  22151. static readonly BACKSIDE: number;
  22152. /**
  22153. * Mesh side orientation : both internal and external or front and back surfaces
  22154. */
  22155. static readonly DOUBLESIDE: number;
  22156. /**
  22157. * Mesh side orientation : by default, `FRONTSIDE`
  22158. */
  22159. static readonly DEFAULTSIDE: number;
  22160. /**
  22161. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22162. */
  22163. positions: Nullable<FloatArray>;
  22164. /**
  22165. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22166. */
  22167. normals: Nullable<FloatArray>;
  22168. /**
  22169. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22170. */
  22171. tangents: Nullable<FloatArray>;
  22172. /**
  22173. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22174. */
  22175. uvs: Nullable<FloatArray>;
  22176. /**
  22177. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22178. */
  22179. uvs2: Nullable<FloatArray>;
  22180. /**
  22181. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22182. */
  22183. uvs3: Nullable<FloatArray>;
  22184. /**
  22185. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22186. */
  22187. uvs4: Nullable<FloatArray>;
  22188. /**
  22189. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22190. */
  22191. uvs5: Nullable<FloatArray>;
  22192. /**
  22193. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22194. */
  22195. uvs6: Nullable<FloatArray>;
  22196. /**
  22197. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22198. */
  22199. colors: Nullable<FloatArray>;
  22200. /**
  22201. * 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).
  22202. */
  22203. matricesIndices: Nullable<FloatArray>;
  22204. /**
  22205. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22206. */
  22207. matricesWeights: Nullable<FloatArray>;
  22208. /**
  22209. * An array extending the number of possible indices
  22210. */
  22211. matricesIndicesExtra: Nullable<FloatArray>;
  22212. /**
  22213. * An array extending the number of possible weights when the number of indices is extended
  22214. */
  22215. matricesWeightsExtra: Nullable<FloatArray>;
  22216. /**
  22217. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22218. */
  22219. indices: Nullable<IndicesArray>;
  22220. /**
  22221. * Uses the passed data array to set the set the values for the specified kind of data
  22222. * @param data a linear array of floating numbers
  22223. * @param kind the type of data that is being set, eg positions, colors etc
  22224. */
  22225. set(data: FloatArray, kind: string): void;
  22226. /**
  22227. * Associates the vertexData to the passed Mesh.
  22228. * Sets it as updatable or not (default `false`)
  22229. * @param mesh the mesh the vertexData is applied to
  22230. * @param updatable when used and having the value true allows new data to update the vertexData
  22231. * @returns the VertexData
  22232. */
  22233. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22234. /**
  22235. * Associates the vertexData to the passed Geometry.
  22236. * Sets it as updatable or not (default `false`)
  22237. * @param geometry the geometry the vertexData is applied to
  22238. * @param updatable when used and having the value true allows new data to update the vertexData
  22239. * @returns VertexData
  22240. */
  22241. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22242. /**
  22243. * Updates the associated mesh
  22244. * @param mesh the mesh to be updated
  22245. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22246. * @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
  22247. * @returns VertexData
  22248. */
  22249. updateMesh(mesh: Mesh): VertexData;
  22250. /**
  22251. * Updates the associated geometry
  22252. * @param geometry the geometry to be updated
  22253. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22254. * @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
  22255. * @returns VertexData.
  22256. */
  22257. updateGeometry(geometry: Geometry): VertexData;
  22258. private _applyTo;
  22259. private _update;
  22260. /**
  22261. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22262. * @param matrix the transforming matrix
  22263. * @returns the VertexData
  22264. */
  22265. transform(matrix: Matrix): VertexData;
  22266. /**
  22267. * Merges the passed VertexData into the current one
  22268. * @param other the VertexData to be merged into the current one
  22269. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22270. * @returns the modified VertexData
  22271. */
  22272. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22273. private _mergeElement;
  22274. private _validate;
  22275. /**
  22276. * Serializes the VertexData
  22277. * @returns a serialized object
  22278. */
  22279. serialize(): any;
  22280. /**
  22281. * Extracts the vertexData from a mesh
  22282. * @param mesh the mesh from which to extract the VertexData
  22283. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22284. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22285. * @returns the object VertexData associated to the passed mesh
  22286. */
  22287. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22288. /**
  22289. * Extracts the vertexData from the geometry
  22290. * @param geometry the geometry from which to extract the VertexData
  22291. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22292. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22293. * @returns the object VertexData associated to the passed mesh
  22294. */
  22295. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22296. private static _ExtractFrom;
  22297. /**
  22298. * Creates the VertexData for a Ribbon
  22299. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22300. * * pathArray array of paths, each of which an array of successive Vector3
  22301. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22302. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22303. * * 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
  22304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22305. * * 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)
  22306. * * 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)
  22307. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22308. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22309. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22310. * @returns the VertexData of the ribbon
  22311. */
  22312. static CreateRibbon(options: {
  22313. pathArray: Vector3[][];
  22314. closeArray?: boolean;
  22315. closePath?: boolean;
  22316. offset?: number;
  22317. sideOrientation?: number;
  22318. frontUVs?: Vector4;
  22319. backUVs?: Vector4;
  22320. invertUV?: boolean;
  22321. uvs?: Vector2[];
  22322. colors?: Color4[];
  22323. }): VertexData;
  22324. /**
  22325. * Creates the VertexData for a box
  22326. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22327. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22328. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22329. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22330. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22331. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22332. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22334. * * 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)
  22335. * * 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)
  22336. * @returns the VertexData of the box
  22337. */
  22338. static CreateBox(options: {
  22339. size?: number;
  22340. width?: number;
  22341. height?: number;
  22342. depth?: number;
  22343. faceUV?: Vector4[];
  22344. faceColors?: Color4[];
  22345. sideOrientation?: number;
  22346. frontUVs?: Vector4;
  22347. backUVs?: Vector4;
  22348. }): VertexData;
  22349. /**
  22350. * Creates the VertexData for a tiled box
  22351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22352. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22353. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22354. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22356. * @returns the VertexData of the box
  22357. */
  22358. static CreateTiledBox(options: {
  22359. pattern?: number;
  22360. width?: number;
  22361. height?: number;
  22362. depth?: number;
  22363. tileSize?: number;
  22364. tileWidth?: number;
  22365. tileHeight?: number;
  22366. alignHorizontal?: number;
  22367. alignVertical?: number;
  22368. faceUV?: Vector4[];
  22369. faceColors?: Color4[];
  22370. sideOrientation?: number;
  22371. }): VertexData;
  22372. /**
  22373. * Creates the VertexData for a tiled plane
  22374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22375. * * pattern a limited pattern arrangement depending on the number
  22376. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22377. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22378. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22379. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22380. * * 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)
  22381. * * 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)
  22382. * @returns the VertexData of the tiled plane
  22383. */
  22384. static CreateTiledPlane(options: {
  22385. pattern?: number;
  22386. tileSize?: number;
  22387. tileWidth?: number;
  22388. tileHeight?: number;
  22389. size?: number;
  22390. width?: number;
  22391. height?: number;
  22392. alignHorizontal?: number;
  22393. alignVertical?: number;
  22394. sideOrientation?: number;
  22395. frontUVs?: Vector4;
  22396. backUVs?: Vector4;
  22397. }): VertexData;
  22398. /**
  22399. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22400. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22401. * * segments sets the number of horizontal strips optional, default 32
  22402. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22403. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22404. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22405. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22406. * * 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
  22407. * * 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
  22408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22409. * * 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)
  22410. * * 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)
  22411. * @returns the VertexData of the ellipsoid
  22412. */
  22413. static CreateSphere(options: {
  22414. segments?: number;
  22415. diameter?: number;
  22416. diameterX?: number;
  22417. diameterY?: number;
  22418. diameterZ?: number;
  22419. arc?: number;
  22420. slice?: number;
  22421. sideOrientation?: number;
  22422. frontUVs?: Vector4;
  22423. backUVs?: Vector4;
  22424. }): VertexData;
  22425. /**
  22426. * Creates the VertexData for a cylinder, cone or prism
  22427. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22428. * * height sets the height (y direction) of the cylinder, optional, default 2
  22429. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22430. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22431. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22432. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22433. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22434. * * 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
  22435. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22436. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22437. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22438. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22440. * * 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)
  22441. * * 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)
  22442. * @returns the VertexData of the cylinder, cone or prism
  22443. */
  22444. static CreateCylinder(options: {
  22445. height?: number;
  22446. diameterTop?: number;
  22447. diameterBottom?: number;
  22448. diameter?: number;
  22449. tessellation?: number;
  22450. subdivisions?: number;
  22451. arc?: number;
  22452. faceColors?: Color4[];
  22453. faceUV?: Vector4[];
  22454. hasRings?: boolean;
  22455. enclose?: boolean;
  22456. sideOrientation?: number;
  22457. frontUVs?: Vector4;
  22458. backUVs?: Vector4;
  22459. }): VertexData;
  22460. /**
  22461. * Creates the VertexData for a torus
  22462. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22463. * * diameter the diameter of the torus, optional default 1
  22464. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22465. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the torus
  22470. */
  22471. static CreateTorus(options: {
  22472. diameter?: number;
  22473. thickness?: number;
  22474. tessellation?: number;
  22475. sideOrientation?: number;
  22476. frontUVs?: Vector4;
  22477. backUVs?: Vector4;
  22478. }): VertexData;
  22479. /**
  22480. * Creates the VertexData of the LineSystem
  22481. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22482. * - lines an array of lines, each line being an array of successive Vector3
  22483. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22484. * @returns the VertexData of the LineSystem
  22485. */
  22486. static CreateLineSystem(options: {
  22487. lines: Vector3[][];
  22488. colors?: Nullable<Color4[][]>;
  22489. }): VertexData;
  22490. /**
  22491. * Create the VertexData for a DashedLines
  22492. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22493. * - points an array successive Vector3
  22494. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22495. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22496. * - dashNb the intended total number of dashes, optional, default 200
  22497. * @returns the VertexData for the DashedLines
  22498. */
  22499. static CreateDashedLines(options: {
  22500. points: Vector3[];
  22501. dashSize?: number;
  22502. gapSize?: number;
  22503. dashNb?: number;
  22504. }): VertexData;
  22505. /**
  22506. * Creates the VertexData for a Ground
  22507. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22508. * - width the width (x direction) of the ground, optional, default 1
  22509. * - height the height (z direction) of the ground, optional, default 1
  22510. * - subdivisions the number of subdivisions per side, optional, default 1
  22511. * @returns the VertexData of the Ground
  22512. */
  22513. static CreateGround(options: {
  22514. width?: number;
  22515. height?: number;
  22516. subdivisions?: number;
  22517. subdivisionsX?: number;
  22518. subdivisionsY?: number;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22522. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22523. * * xmin the ground minimum X coordinate, optional, default -1
  22524. * * zmin the ground minimum Z coordinate, optional, default -1
  22525. * * xmax the ground maximum X coordinate, optional, default 1
  22526. * * zmax the ground maximum Z coordinate, optional, default 1
  22527. * * 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}
  22528. * * 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}
  22529. * @returns the VertexData of the TiledGround
  22530. */
  22531. static CreateTiledGround(options: {
  22532. xmin: number;
  22533. zmin: number;
  22534. xmax: number;
  22535. zmax: number;
  22536. subdivisions?: {
  22537. w: number;
  22538. h: number;
  22539. };
  22540. precision?: {
  22541. w: number;
  22542. h: number;
  22543. };
  22544. }): VertexData;
  22545. /**
  22546. * Creates the VertexData of the Ground designed from a heightmap
  22547. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22548. * * width the width (x direction) of the ground
  22549. * * height the height (z direction) of the ground
  22550. * * subdivisions the number of subdivisions per side
  22551. * * minHeight the minimum altitude on the ground, optional, default 0
  22552. * * maxHeight the maximum altitude on the ground, optional default 1
  22553. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22554. * * buffer the array holding the image color data
  22555. * * bufferWidth the width of image
  22556. * * bufferHeight the height of image
  22557. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22558. * @returns the VertexData of the Ground designed from a heightmap
  22559. */
  22560. static CreateGroundFromHeightMap(options: {
  22561. width: number;
  22562. height: number;
  22563. subdivisions: number;
  22564. minHeight: number;
  22565. maxHeight: number;
  22566. colorFilter: Color3;
  22567. buffer: Uint8Array;
  22568. bufferWidth: number;
  22569. bufferHeight: number;
  22570. alphaFilter: number;
  22571. }): VertexData;
  22572. /**
  22573. * Creates the VertexData for a Plane
  22574. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22575. * * size sets the width and height of the plane to the value of size, optional default 1
  22576. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22577. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * 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)
  22580. * * 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)
  22581. * @returns the VertexData of the box
  22582. */
  22583. static CreatePlane(options: {
  22584. size?: number;
  22585. width?: number;
  22586. height?: number;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. }): VertexData;
  22591. /**
  22592. * Creates the VertexData of the Disc or regular Polygon
  22593. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22594. * * radius the radius of the disc, optional default 0.5
  22595. * * tessellation the number of polygon sides, optional, default 64
  22596. * * 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
  22597. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22598. * * 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)
  22599. * * 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)
  22600. * @returns the VertexData of the box
  22601. */
  22602. static CreateDisc(options: {
  22603. radius?: number;
  22604. tessellation?: number;
  22605. arc?: number;
  22606. sideOrientation?: number;
  22607. frontUVs?: Vector4;
  22608. backUVs?: Vector4;
  22609. }): VertexData;
  22610. /**
  22611. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22612. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22613. * @param polygon a mesh built from polygonTriangulation.build()
  22614. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22615. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22616. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22617. * @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)
  22618. * @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)
  22619. * @returns the VertexData of the Polygon
  22620. */
  22621. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22622. /**
  22623. * Creates the VertexData of the IcoSphere
  22624. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22625. * * radius the radius of the IcoSphere, optional default 1
  22626. * * radiusX allows stretching in the x direction, optional, default radius
  22627. * * radiusY allows stretching in the y direction, optional, default radius
  22628. * * radiusZ allows stretching in the z direction, optional, default radius
  22629. * * flat when true creates a flat shaded mesh, optional, default true
  22630. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22632. * * 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)
  22633. * * 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)
  22634. * @returns the VertexData of the IcoSphere
  22635. */
  22636. static CreateIcoSphere(options: {
  22637. radius?: number;
  22638. radiusX?: number;
  22639. radiusY?: number;
  22640. radiusZ?: number;
  22641. flat?: boolean;
  22642. subdivisions?: number;
  22643. sideOrientation?: number;
  22644. frontUVs?: Vector4;
  22645. backUVs?: Vector4;
  22646. }): VertexData;
  22647. /**
  22648. * Creates the VertexData for a Polyhedron
  22649. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22650. * * type provided types are:
  22651. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22652. * * 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)
  22653. * * size the size of the IcoSphere, optional default 1
  22654. * * sizeX allows stretching in the x direction, optional, default size
  22655. * * sizeY allows stretching in the y direction, optional, default size
  22656. * * sizeZ allows stretching in the z direction, optional, default size
  22657. * * 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
  22658. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22659. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22660. * * flat when true creates a flat shaded mesh, optional, default true
  22661. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22663. * * 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)
  22664. * * 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)
  22665. * @returns the VertexData of the Polyhedron
  22666. */
  22667. static CreatePolyhedron(options: {
  22668. type?: number;
  22669. size?: number;
  22670. sizeX?: number;
  22671. sizeY?: number;
  22672. sizeZ?: number;
  22673. custom?: any;
  22674. faceUV?: Vector4[];
  22675. faceColors?: Color4[];
  22676. flat?: boolean;
  22677. sideOrientation?: number;
  22678. frontUVs?: Vector4;
  22679. backUVs?: Vector4;
  22680. }): VertexData;
  22681. /**
  22682. * Creates the VertexData for a TorusKnot
  22683. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22684. * * radius the radius of the torus knot, optional, default 2
  22685. * * tube the thickness of the tube, optional, default 0.5
  22686. * * radialSegments the number of sides on each tube segments, optional, default 32
  22687. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22688. * * p the number of windings around the z axis, optional, default 2
  22689. * * q the number of windings around the x axis, optional, default 3
  22690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22691. * * 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)
  22692. * * 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)
  22693. * @returns the VertexData of the Torus Knot
  22694. */
  22695. static CreateTorusKnot(options: {
  22696. radius?: number;
  22697. tube?: number;
  22698. radialSegments?: number;
  22699. tubularSegments?: number;
  22700. p?: number;
  22701. q?: number;
  22702. sideOrientation?: number;
  22703. frontUVs?: Vector4;
  22704. backUVs?: Vector4;
  22705. }): VertexData;
  22706. /**
  22707. * Compute normals for given positions and indices
  22708. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22709. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22710. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22711. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22712. * * facetNormals : optional array of facet normals (vector3)
  22713. * * facetPositions : optional array of facet positions (vector3)
  22714. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22715. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22716. * * bInfo : optional bounding info, required for facetPartitioning computation
  22717. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22718. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22719. * * useRightHandedSystem: optional boolean to for right handed system computation
  22720. * * depthSort : optional boolean to enable the facet depth sort computation
  22721. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22722. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22723. */
  22724. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22725. facetNormals?: any;
  22726. facetPositions?: any;
  22727. facetPartitioning?: any;
  22728. ratio?: number;
  22729. bInfo?: any;
  22730. bbSize?: Vector3;
  22731. subDiv?: any;
  22732. useRightHandedSystem?: boolean;
  22733. depthSort?: boolean;
  22734. distanceTo?: Vector3;
  22735. depthSortedFacets?: any;
  22736. }): void;
  22737. /** @hidden */
  22738. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22739. /**
  22740. * Applies VertexData created from the imported parameters to the geometry
  22741. * @param parsedVertexData the parsed data from an imported file
  22742. * @param geometry the geometry to apply the VertexData to
  22743. */
  22744. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22745. }
  22746. }
  22747. declare module "babylonjs/Morph/morphTarget" {
  22748. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22749. import { Observable } from "babylonjs/Misc/observable";
  22750. import { Nullable, FloatArray } from "babylonjs/types";
  22751. import { Scene } from "babylonjs/scene";
  22752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22753. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22754. /**
  22755. * Defines a target to use with MorphTargetManager
  22756. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22757. */
  22758. export class MorphTarget implements IAnimatable {
  22759. /** defines the name of the target */
  22760. name: string;
  22761. /**
  22762. * Gets or sets the list of animations
  22763. */
  22764. animations: import("babylonjs/Animations/animation").Animation[];
  22765. private _scene;
  22766. private _positions;
  22767. private _normals;
  22768. private _tangents;
  22769. private _uvs;
  22770. private _influence;
  22771. private _uniqueId;
  22772. /**
  22773. * Observable raised when the influence changes
  22774. */
  22775. onInfluenceChanged: Observable<boolean>;
  22776. /** @hidden */
  22777. _onDataLayoutChanged: Observable<void>;
  22778. /**
  22779. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22780. */
  22781. influence: number;
  22782. /**
  22783. * Gets or sets the id of the morph Target
  22784. */
  22785. id: string;
  22786. private _animationPropertiesOverride;
  22787. /**
  22788. * Gets or sets the animation properties override
  22789. */
  22790. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22791. /**
  22792. * Creates a new MorphTarget
  22793. * @param name defines the name of the target
  22794. * @param influence defines the influence to use
  22795. * @param scene defines the scene the morphtarget belongs to
  22796. */
  22797. constructor(
  22798. /** defines the name of the target */
  22799. name: string, influence?: number, scene?: Nullable<Scene>);
  22800. /**
  22801. * Gets the unique ID of this manager
  22802. */
  22803. readonly uniqueId: number;
  22804. /**
  22805. * Gets a boolean defining if the target contains position data
  22806. */
  22807. readonly hasPositions: boolean;
  22808. /**
  22809. * Gets a boolean defining if the target contains normal data
  22810. */
  22811. readonly hasNormals: boolean;
  22812. /**
  22813. * Gets a boolean defining if the target contains tangent data
  22814. */
  22815. readonly hasTangents: boolean;
  22816. /**
  22817. * Gets a boolean defining if the target contains texture coordinates data
  22818. */
  22819. readonly hasUVs: boolean;
  22820. /**
  22821. * Affects position data to this target
  22822. * @param data defines the position data to use
  22823. */
  22824. setPositions(data: Nullable<FloatArray>): void;
  22825. /**
  22826. * Gets the position data stored in this target
  22827. * @returns a FloatArray containing the position data (or null if not present)
  22828. */
  22829. getPositions(): Nullable<FloatArray>;
  22830. /**
  22831. * Affects normal data to this target
  22832. * @param data defines the normal data to use
  22833. */
  22834. setNormals(data: Nullable<FloatArray>): void;
  22835. /**
  22836. * Gets the normal data stored in this target
  22837. * @returns a FloatArray containing the normal data (or null if not present)
  22838. */
  22839. getNormals(): Nullable<FloatArray>;
  22840. /**
  22841. * Affects tangent data to this target
  22842. * @param data defines the tangent data to use
  22843. */
  22844. setTangents(data: Nullable<FloatArray>): void;
  22845. /**
  22846. * Gets the tangent data stored in this target
  22847. * @returns a FloatArray containing the tangent data (or null if not present)
  22848. */
  22849. getTangents(): Nullable<FloatArray>;
  22850. /**
  22851. * Affects texture coordinates data to this target
  22852. * @param data defines the texture coordinates data to use
  22853. */
  22854. setUVs(data: Nullable<FloatArray>): void;
  22855. /**
  22856. * Gets the texture coordinates data stored in this target
  22857. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22858. */
  22859. getUVs(): Nullable<FloatArray>;
  22860. /**
  22861. * Clone the current target
  22862. * @returns a new MorphTarget
  22863. */
  22864. clone(): MorphTarget;
  22865. /**
  22866. * Serializes the current target into a Serialization object
  22867. * @returns the serialized object
  22868. */
  22869. serialize(): any;
  22870. /**
  22871. * Returns the string "MorphTarget"
  22872. * @returns "MorphTarget"
  22873. */
  22874. getClassName(): string;
  22875. /**
  22876. * Creates a new target from serialized data
  22877. * @param serializationObject defines the serialized data to use
  22878. * @returns a new MorphTarget
  22879. */
  22880. static Parse(serializationObject: any): MorphTarget;
  22881. /**
  22882. * Creates a MorphTarget from mesh data
  22883. * @param mesh defines the source mesh
  22884. * @param name defines the name to use for the new target
  22885. * @param influence defines the influence to attach to the target
  22886. * @returns a new MorphTarget
  22887. */
  22888. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22889. }
  22890. }
  22891. declare module "babylonjs/Morph/morphTargetManager" {
  22892. import { Nullable } from "babylonjs/types";
  22893. import { Scene } from "babylonjs/scene";
  22894. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22895. /**
  22896. * This class is used to deform meshes using morphing between different targets
  22897. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22898. */
  22899. export class MorphTargetManager {
  22900. private _targets;
  22901. private _targetInfluenceChangedObservers;
  22902. private _targetDataLayoutChangedObservers;
  22903. private _activeTargets;
  22904. private _scene;
  22905. private _influences;
  22906. private _supportsNormals;
  22907. private _supportsTangents;
  22908. private _supportsUVs;
  22909. private _vertexCount;
  22910. private _uniqueId;
  22911. private _tempInfluences;
  22912. /**
  22913. * Gets or sets a boolean indicating if normals must be morphed
  22914. */
  22915. enableNormalMorphing: boolean;
  22916. /**
  22917. * Gets or sets a boolean indicating if tangents must be morphed
  22918. */
  22919. enableTangentMorphing: boolean;
  22920. /**
  22921. * Gets or sets a boolean indicating if UV must be morphed
  22922. */
  22923. enableUVMorphing: boolean;
  22924. /**
  22925. * Creates a new MorphTargetManager
  22926. * @param scene defines the current scene
  22927. */
  22928. constructor(scene?: Nullable<Scene>);
  22929. /**
  22930. * Gets the unique ID of this manager
  22931. */
  22932. readonly uniqueId: number;
  22933. /**
  22934. * Gets the number of vertices handled by this manager
  22935. */
  22936. readonly vertexCount: number;
  22937. /**
  22938. * Gets a boolean indicating if this manager supports morphing of normals
  22939. */
  22940. readonly supportsNormals: boolean;
  22941. /**
  22942. * Gets a boolean indicating if this manager supports morphing of tangents
  22943. */
  22944. readonly supportsTangents: boolean;
  22945. /**
  22946. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22947. */
  22948. readonly supportsUVs: boolean;
  22949. /**
  22950. * Gets the number of targets stored in this manager
  22951. */
  22952. readonly numTargets: number;
  22953. /**
  22954. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22955. */
  22956. readonly numInfluencers: number;
  22957. /**
  22958. * Gets the list of influences (one per target)
  22959. */
  22960. readonly influences: Float32Array;
  22961. /**
  22962. * Gets the active target at specified index. An active target is a target with an influence > 0
  22963. * @param index defines the index to check
  22964. * @returns the requested target
  22965. */
  22966. getActiveTarget(index: number): MorphTarget;
  22967. /**
  22968. * Gets the target at specified index
  22969. * @param index defines the index to check
  22970. * @returns the requested target
  22971. */
  22972. getTarget(index: number): MorphTarget;
  22973. /**
  22974. * Add a new target to this manager
  22975. * @param target defines the target to add
  22976. */
  22977. addTarget(target: MorphTarget): void;
  22978. /**
  22979. * Removes a target from the manager
  22980. * @param target defines the target to remove
  22981. */
  22982. removeTarget(target: MorphTarget): void;
  22983. /**
  22984. * Clone the current manager
  22985. * @returns a new MorphTargetManager
  22986. */
  22987. clone(): MorphTargetManager;
  22988. /**
  22989. * Serializes the current manager into a Serialization object
  22990. * @returns the serialized object
  22991. */
  22992. serialize(): any;
  22993. private _syncActiveTargets;
  22994. /**
  22995. * Syncrhonize the targets with all the meshes using this morph target manager
  22996. */
  22997. synchronize(): void;
  22998. /**
  22999. * Creates a new MorphTargetManager from serialized data
  23000. * @param serializationObject defines the serialized data
  23001. * @param scene defines the hosting scene
  23002. * @returns the new MorphTargetManager
  23003. */
  23004. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23005. }
  23006. }
  23007. declare module "babylonjs/Meshes/meshLODLevel" {
  23008. import { Mesh } from "babylonjs/Meshes/mesh";
  23009. import { Nullable } from "babylonjs/types";
  23010. /**
  23011. * Class used to represent a specific level of detail of a mesh
  23012. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23013. */
  23014. export class MeshLODLevel {
  23015. /** Defines the distance where this level should start being displayed */
  23016. distance: number;
  23017. /** Defines the mesh to use to render this level */
  23018. mesh: Nullable<Mesh>;
  23019. /**
  23020. * Creates a new LOD level
  23021. * @param distance defines the distance where this level should star being displayed
  23022. * @param mesh defines the mesh to use to render this level
  23023. */
  23024. constructor(
  23025. /** Defines the distance where this level should start being displayed */
  23026. distance: number,
  23027. /** Defines the mesh to use to render this level */
  23028. mesh: Nullable<Mesh>);
  23029. }
  23030. }
  23031. declare module "babylonjs/Meshes/groundMesh" {
  23032. import { Scene } from "babylonjs/scene";
  23033. import { Vector3 } from "babylonjs/Maths/math.vector";
  23034. import { Mesh } from "babylonjs/Meshes/mesh";
  23035. /**
  23036. * Mesh representing the gorund
  23037. */
  23038. export class GroundMesh extends Mesh {
  23039. /** If octree should be generated */
  23040. generateOctree: boolean;
  23041. private _heightQuads;
  23042. /** @hidden */
  23043. _subdivisionsX: number;
  23044. /** @hidden */
  23045. _subdivisionsY: number;
  23046. /** @hidden */
  23047. _width: number;
  23048. /** @hidden */
  23049. _height: number;
  23050. /** @hidden */
  23051. _minX: number;
  23052. /** @hidden */
  23053. _maxX: number;
  23054. /** @hidden */
  23055. _minZ: number;
  23056. /** @hidden */
  23057. _maxZ: number;
  23058. constructor(name: string, scene: Scene);
  23059. /**
  23060. * "GroundMesh"
  23061. * @returns "GroundMesh"
  23062. */
  23063. getClassName(): string;
  23064. /**
  23065. * The minimum of x and y subdivisions
  23066. */
  23067. readonly subdivisions: number;
  23068. /**
  23069. * X subdivisions
  23070. */
  23071. readonly subdivisionsX: number;
  23072. /**
  23073. * Y subdivisions
  23074. */
  23075. readonly subdivisionsY: number;
  23076. /**
  23077. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23079. * @param chunksCount the number of subdivisions for x and y
  23080. * @param octreeBlocksSize (Default: 32)
  23081. */
  23082. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23083. /**
  23084. * Returns a height (y) value in the Worl system :
  23085. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23086. * @param x x coordinate
  23087. * @param z z coordinate
  23088. * @returns the ground y position if (x, z) are outside the ground surface.
  23089. */
  23090. getHeightAtCoordinates(x: number, z: number): number;
  23091. /**
  23092. * Returns a normalized vector (Vector3) orthogonal to the ground
  23093. * at the ground coordinates (x, z) expressed in the World system.
  23094. * @param x x coordinate
  23095. * @param z z coordinate
  23096. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23097. */
  23098. getNormalAtCoordinates(x: number, z: number): Vector3;
  23099. /**
  23100. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23101. * at the ground coordinates (x, z) expressed in the World system.
  23102. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23103. * @param x x coordinate
  23104. * @param z z coordinate
  23105. * @param ref vector to store the result
  23106. * @returns the GroundMesh.
  23107. */
  23108. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23109. /**
  23110. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23111. * if the ground has been updated.
  23112. * This can be used in the render loop.
  23113. * @returns the GroundMesh.
  23114. */
  23115. updateCoordinateHeights(): GroundMesh;
  23116. private _getFacetAt;
  23117. private _initHeightQuads;
  23118. private _computeHeightQuads;
  23119. /**
  23120. * Serializes this ground mesh
  23121. * @param serializationObject object to write serialization to
  23122. */
  23123. serialize(serializationObject: any): void;
  23124. /**
  23125. * Parses a serialized ground mesh
  23126. * @param parsedMesh the serialized mesh
  23127. * @param scene the scene to create the ground mesh in
  23128. * @returns the created ground mesh
  23129. */
  23130. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23131. }
  23132. }
  23133. declare module "babylonjs/Physics/physicsJoint" {
  23134. import { Vector3 } from "babylonjs/Maths/math.vector";
  23135. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23136. /**
  23137. * Interface for Physics-Joint data
  23138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23139. */
  23140. export interface PhysicsJointData {
  23141. /**
  23142. * The main pivot of the joint
  23143. */
  23144. mainPivot?: Vector3;
  23145. /**
  23146. * The connected pivot of the joint
  23147. */
  23148. connectedPivot?: Vector3;
  23149. /**
  23150. * The main axis of the joint
  23151. */
  23152. mainAxis?: Vector3;
  23153. /**
  23154. * The connected axis of the joint
  23155. */
  23156. connectedAxis?: Vector3;
  23157. /**
  23158. * The collision of the joint
  23159. */
  23160. collision?: boolean;
  23161. /**
  23162. * Native Oimo/Cannon/Energy data
  23163. */
  23164. nativeParams?: any;
  23165. }
  23166. /**
  23167. * This is a holder class for the physics joint created by the physics plugin
  23168. * It holds a set of functions to control the underlying joint
  23169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23170. */
  23171. export class PhysicsJoint {
  23172. /**
  23173. * The type of the physics joint
  23174. */
  23175. type: number;
  23176. /**
  23177. * The data for the physics joint
  23178. */
  23179. jointData: PhysicsJointData;
  23180. private _physicsJoint;
  23181. protected _physicsPlugin: IPhysicsEnginePlugin;
  23182. /**
  23183. * Initializes the physics joint
  23184. * @param type The type of the physics joint
  23185. * @param jointData The data for the physics joint
  23186. */
  23187. constructor(
  23188. /**
  23189. * The type of the physics joint
  23190. */
  23191. type: number,
  23192. /**
  23193. * The data for the physics joint
  23194. */
  23195. jointData: PhysicsJointData);
  23196. /**
  23197. * Gets the physics joint
  23198. */
  23199. /**
  23200. * Sets the physics joint
  23201. */
  23202. physicsJoint: any;
  23203. /**
  23204. * Sets the physics plugin
  23205. */
  23206. physicsPlugin: IPhysicsEnginePlugin;
  23207. /**
  23208. * Execute a function that is physics-plugin specific.
  23209. * @param {Function} func the function that will be executed.
  23210. * It accepts two parameters: the physics world and the physics joint
  23211. */
  23212. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23213. /**
  23214. * Distance-Joint type
  23215. */
  23216. static DistanceJoint: number;
  23217. /**
  23218. * Hinge-Joint type
  23219. */
  23220. static HingeJoint: number;
  23221. /**
  23222. * Ball-and-Socket joint type
  23223. */
  23224. static BallAndSocketJoint: number;
  23225. /**
  23226. * Wheel-Joint type
  23227. */
  23228. static WheelJoint: number;
  23229. /**
  23230. * Slider-Joint type
  23231. */
  23232. static SliderJoint: number;
  23233. /**
  23234. * Prismatic-Joint type
  23235. */
  23236. static PrismaticJoint: number;
  23237. /**
  23238. * Universal-Joint type
  23239. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23240. */
  23241. static UniversalJoint: number;
  23242. /**
  23243. * Hinge-Joint 2 type
  23244. */
  23245. static Hinge2Joint: number;
  23246. /**
  23247. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23248. */
  23249. static PointToPointJoint: number;
  23250. /**
  23251. * Spring-Joint type
  23252. */
  23253. static SpringJoint: number;
  23254. /**
  23255. * Lock-Joint type
  23256. */
  23257. static LockJoint: number;
  23258. }
  23259. /**
  23260. * A class representing a physics distance joint
  23261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23262. */
  23263. export class DistanceJoint extends PhysicsJoint {
  23264. /**
  23265. *
  23266. * @param jointData The data for the Distance-Joint
  23267. */
  23268. constructor(jointData: DistanceJointData);
  23269. /**
  23270. * Update the predefined distance.
  23271. * @param maxDistance The maximum preferred distance
  23272. * @param minDistance The minimum preferred distance
  23273. */
  23274. updateDistance(maxDistance: number, minDistance?: number): void;
  23275. }
  23276. /**
  23277. * Represents a Motor-Enabled Joint
  23278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23279. */
  23280. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23281. /**
  23282. * Initializes the Motor-Enabled Joint
  23283. * @param type The type of the joint
  23284. * @param jointData The physica joint data for the joint
  23285. */
  23286. constructor(type: number, jointData: PhysicsJointData);
  23287. /**
  23288. * Set the motor values.
  23289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23290. * @param force the force to apply
  23291. * @param maxForce max force for this motor.
  23292. */
  23293. setMotor(force?: number, maxForce?: number): void;
  23294. /**
  23295. * Set the motor's limits.
  23296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23297. * @param upperLimit The upper limit of the motor
  23298. * @param lowerLimit The lower limit of the motor
  23299. */
  23300. setLimit(upperLimit: number, lowerLimit?: number): void;
  23301. }
  23302. /**
  23303. * This class represents a single physics Hinge-Joint
  23304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23305. */
  23306. export class HingeJoint extends MotorEnabledJoint {
  23307. /**
  23308. * Initializes the Hinge-Joint
  23309. * @param jointData The joint data for the Hinge-Joint
  23310. */
  23311. constructor(jointData: PhysicsJointData);
  23312. /**
  23313. * Set the motor values.
  23314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23315. * @param {number} force the force to apply
  23316. * @param {number} maxForce max force for this motor.
  23317. */
  23318. setMotor(force?: number, maxForce?: number): void;
  23319. /**
  23320. * Set the motor's limits.
  23321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23322. * @param upperLimit The upper limit of the motor
  23323. * @param lowerLimit The lower limit of the motor
  23324. */
  23325. setLimit(upperLimit: number, lowerLimit?: number): void;
  23326. }
  23327. /**
  23328. * This class represents a dual hinge physics joint (same as wheel joint)
  23329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23330. */
  23331. export class Hinge2Joint extends MotorEnabledJoint {
  23332. /**
  23333. * Initializes the Hinge2-Joint
  23334. * @param jointData The joint data for the Hinge2-Joint
  23335. */
  23336. constructor(jointData: PhysicsJointData);
  23337. /**
  23338. * Set the motor values.
  23339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23340. * @param {number} targetSpeed the speed the motor is to reach
  23341. * @param {number} maxForce max force for this motor.
  23342. * @param {motorIndex} the motor's index, 0 or 1.
  23343. */
  23344. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23345. /**
  23346. * Set the motor limits.
  23347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23348. * @param {number} upperLimit the upper limit
  23349. * @param {number} lowerLimit lower limit
  23350. * @param {motorIndex} the motor's index, 0 or 1.
  23351. */
  23352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23353. }
  23354. /**
  23355. * Interface for a motor enabled joint
  23356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23357. */
  23358. export interface IMotorEnabledJoint {
  23359. /**
  23360. * Physics joint
  23361. */
  23362. physicsJoint: any;
  23363. /**
  23364. * Sets the motor of the motor-enabled joint
  23365. * @param force The force of the motor
  23366. * @param maxForce The maximum force of the motor
  23367. * @param motorIndex The index of the motor
  23368. */
  23369. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23370. /**
  23371. * Sets the limit of the motor
  23372. * @param upperLimit The upper limit of the motor
  23373. * @param lowerLimit The lower limit of the motor
  23374. * @param motorIndex The index of the motor
  23375. */
  23376. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23377. }
  23378. /**
  23379. * Joint data for a Distance-Joint
  23380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23381. */
  23382. export interface DistanceJointData extends PhysicsJointData {
  23383. /**
  23384. * Max distance the 2 joint objects can be apart
  23385. */
  23386. maxDistance: number;
  23387. }
  23388. /**
  23389. * Joint data from a spring joint
  23390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23391. */
  23392. export interface SpringJointData extends PhysicsJointData {
  23393. /**
  23394. * Length of the spring
  23395. */
  23396. length: number;
  23397. /**
  23398. * Stiffness of the spring
  23399. */
  23400. stiffness: number;
  23401. /**
  23402. * Damping of the spring
  23403. */
  23404. damping: number;
  23405. /** this callback will be called when applying the force to the impostors. */
  23406. forceApplicationCallback: () => void;
  23407. }
  23408. }
  23409. declare module "babylonjs/Physics/physicsRaycastResult" {
  23410. import { Vector3 } from "babylonjs/Maths/math.vector";
  23411. /**
  23412. * Holds the data for the raycast result
  23413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23414. */
  23415. export class PhysicsRaycastResult {
  23416. private _hasHit;
  23417. private _hitDistance;
  23418. private _hitNormalWorld;
  23419. private _hitPointWorld;
  23420. private _rayFromWorld;
  23421. private _rayToWorld;
  23422. /**
  23423. * Gets if there was a hit
  23424. */
  23425. readonly hasHit: boolean;
  23426. /**
  23427. * Gets the distance from the hit
  23428. */
  23429. readonly hitDistance: number;
  23430. /**
  23431. * Gets the hit normal/direction in the world
  23432. */
  23433. readonly hitNormalWorld: Vector3;
  23434. /**
  23435. * Gets the hit point in the world
  23436. */
  23437. readonly hitPointWorld: Vector3;
  23438. /**
  23439. * Gets the ray "start point" of the ray in the world
  23440. */
  23441. readonly rayFromWorld: Vector3;
  23442. /**
  23443. * Gets the ray "end point" of the ray in the world
  23444. */
  23445. readonly rayToWorld: Vector3;
  23446. /**
  23447. * Sets the hit data (normal & point in world space)
  23448. * @param hitNormalWorld defines the normal in world space
  23449. * @param hitPointWorld defines the point in world space
  23450. */
  23451. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23452. /**
  23453. * Sets the distance from the start point to the hit point
  23454. * @param distance
  23455. */
  23456. setHitDistance(distance: number): void;
  23457. /**
  23458. * Calculates the distance manually
  23459. */
  23460. calculateHitDistance(): void;
  23461. /**
  23462. * Resets all the values to default
  23463. * @param from The from point on world space
  23464. * @param to The to point on world space
  23465. */
  23466. reset(from?: Vector3, to?: Vector3): void;
  23467. }
  23468. /**
  23469. * Interface for the size containing width and height
  23470. */
  23471. interface IXYZ {
  23472. /**
  23473. * X
  23474. */
  23475. x: number;
  23476. /**
  23477. * Y
  23478. */
  23479. y: number;
  23480. /**
  23481. * Z
  23482. */
  23483. z: number;
  23484. }
  23485. }
  23486. declare module "babylonjs/Physics/IPhysicsEngine" {
  23487. import { Nullable } from "babylonjs/types";
  23488. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23490. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23491. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23492. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23493. /**
  23494. * Interface used to describe a physics joint
  23495. */
  23496. export interface PhysicsImpostorJoint {
  23497. /** Defines the main impostor to which the joint is linked */
  23498. mainImpostor: PhysicsImpostor;
  23499. /** Defines the impostor that is connected to the main impostor using this joint */
  23500. connectedImpostor: PhysicsImpostor;
  23501. /** Defines the joint itself */
  23502. joint: PhysicsJoint;
  23503. }
  23504. /** @hidden */
  23505. export interface IPhysicsEnginePlugin {
  23506. world: any;
  23507. name: string;
  23508. setGravity(gravity: Vector3): void;
  23509. setTimeStep(timeStep: number): void;
  23510. getTimeStep(): number;
  23511. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23512. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23513. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23514. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23515. removePhysicsBody(impostor: PhysicsImpostor): void;
  23516. generateJoint(joint: PhysicsImpostorJoint): void;
  23517. removeJoint(joint: PhysicsImpostorJoint): void;
  23518. isSupported(): boolean;
  23519. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23520. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23521. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23522. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23523. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23524. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23525. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23526. getBodyMass(impostor: PhysicsImpostor): number;
  23527. getBodyFriction(impostor: PhysicsImpostor): number;
  23528. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23529. getBodyRestitution(impostor: PhysicsImpostor): number;
  23530. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23531. getBodyPressure?(impostor: PhysicsImpostor): number;
  23532. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23533. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23534. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23535. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23536. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23537. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23538. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23539. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23540. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23541. sleepBody(impostor: PhysicsImpostor): void;
  23542. wakeUpBody(impostor: PhysicsImpostor): void;
  23543. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23544. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23545. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23546. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. getRadius(impostor: PhysicsImpostor): number;
  23548. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23550. dispose(): void;
  23551. }
  23552. /**
  23553. * Interface used to define a physics engine
  23554. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23555. */
  23556. export interface IPhysicsEngine {
  23557. /**
  23558. * Gets the gravity vector used by the simulation
  23559. */
  23560. gravity: Vector3;
  23561. /**
  23562. * Sets the gravity vector used by the simulation
  23563. * @param gravity defines the gravity vector to use
  23564. */
  23565. setGravity(gravity: Vector3): void;
  23566. /**
  23567. * Set the time step of the physics engine.
  23568. * Default is 1/60.
  23569. * To slow it down, enter 1/600 for example.
  23570. * To speed it up, 1/30
  23571. * @param newTimeStep the new timestep to apply to this world.
  23572. */
  23573. setTimeStep(newTimeStep: number): void;
  23574. /**
  23575. * Get the time step of the physics engine.
  23576. * @returns the current time step
  23577. */
  23578. getTimeStep(): number;
  23579. /**
  23580. * Release all resources
  23581. */
  23582. dispose(): void;
  23583. /**
  23584. * Gets the name of the current physics plugin
  23585. * @returns the name of the plugin
  23586. */
  23587. getPhysicsPluginName(): string;
  23588. /**
  23589. * Adding a new impostor for the impostor tracking.
  23590. * This will be done by the impostor itself.
  23591. * @param impostor the impostor to add
  23592. */
  23593. addImpostor(impostor: PhysicsImpostor): void;
  23594. /**
  23595. * Remove an impostor from the engine.
  23596. * This impostor and its mesh will not longer be updated by the physics engine.
  23597. * @param impostor the impostor to remove
  23598. */
  23599. removeImpostor(impostor: PhysicsImpostor): void;
  23600. /**
  23601. * Add a joint to the physics engine
  23602. * @param mainImpostor defines the main impostor to which the joint is added.
  23603. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23604. * @param joint defines the joint that will connect both impostors.
  23605. */
  23606. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23607. /**
  23608. * Removes a joint from the simulation
  23609. * @param mainImpostor defines the impostor used with the joint
  23610. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23611. * @param joint defines the joint to remove
  23612. */
  23613. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23614. /**
  23615. * Gets the current plugin used to run the simulation
  23616. * @returns current plugin
  23617. */
  23618. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23619. /**
  23620. * Gets the list of physic impostors
  23621. * @returns an array of PhysicsImpostor
  23622. */
  23623. getImpostors(): Array<PhysicsImpostor>;
  23624. /**
  23625. * Gets the impostor for a physics enabled object
  23626. * @param object defines the object impersonated by the impostor
  23627. * @returns the PhysicsImpostor or null if not found
  23628. */
  23629. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23630. /**
  23631. * Gets the impostor for a physics body object
  23632. * @param body defines physics body used by the impostor
  23633. * @returns the PhysicsImpostor or null if not found
  23634. */
  23635. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23636. /**
  23637. * Does a raycast in the physics world
  23638. * @param from when should the ray start?
  23639. * @param to when should the ray end?
  23640. * @returns PhysicsRaycastResult
  23641. */
  23642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23643. /**
  23644. * Called by the scene. No need to call it.
  23645. * @param delta defines the timespam between frames
  23646. */
  23647. _step(delta: number): void;
  23648. }
  23649. }
  23650. declare module "babylonjs/Physics/physicsImpostor" {
  23651. import { Nullable, IndicesArray } from "babylonjs/types";
  23652. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23655. import { Scene } from "babylonjs/scene";
  23656. import { Bone } from "babylonjs/Bones/bone";
  23657. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23658. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23659. import { Space } from "babylonjs/Maths/math.axis";
  23660. /**
  23661. * The interface for the physics imposter parameters
  23662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23663. */
  23664. export interface PhysicsImpostorParameters {
  23665. /**
  23666. * The mass of the physics imposter
  23667. */
  23668. mass: number;
  23669. /**
  23670. * The friction of the physics imposter
  23671. */
  23672. friction?: number;
  23673. /**
  23674. * The coefficient of restitution of the physics imposter
  23675. */
  23676. restitution?: number;
  23677. /**
  23678. * The native options of the physics imposter
  23679. */
  23680. nativeOptions?: any;
  23681. /**
  23682. * Specifies if the parent should be ignored
  23683. */
  23684. ignoreParent?: boolean;
  23685. /**
  23686. * Specifies if bi-directional transformations should be disabled
  23687. */
  23688. disableBidirectionalTransformation?: boolean;
  23689. /**
  23690. * The pressure inside the physics imposter, soft object only
  23691. */
  23692. pressure?: number;
  23693. /**
  23694. * The stiffness the physics imposter, soft object only
  23695. */
  23696. stiffness?: number;
  23697. /**
  23698. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23699. */
  23700. velocityIterations?: number;
  23701. /**
  23702. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23703. */
  23704. positionIterations?: number;
  23705. /**
  23706. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23707. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23708. * Add to fix multiple points
  23709. */
  23710. fixedPoints?: number;
  23711. /**
  23712. * The collision margin around a soft object
  23713. */
  23714. margin?: number;
  23715. /**
  23716. * The collision margin around a soft object
  23717. */
  23718. damping?: number;
  23719. /**
  23720. * The path for a rope based on an extrusion
  23721. */
  23722. path?: any;
  23723. /**
  23724. * The shape of an extrusion used for a rope based on an extrusion
  23725. */
  23726. shape?: any;
  23727. }
  23728. /**
  23729. * Interface for a physics-enabled object
  23730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23731. */
  23732. export interface IPhysicsEnabledObject {
  23733. /**
  23734. * The position of the physics-enabled object
  23735. */
  23736. position: Vector3;
  23737. /**
  23738. * The rotation of the physics-enabled object
  23739. */
  23740. rotationQuaternion: Nullable<Quaternion>;
  23741. /**
  23742. * The scale of the physics-enabled object
  23743. */
  23744. scaling: Vector3;
  23745. /**
  23746. * The rotation of the physics-enabled object
  23747. */
  23748. rotation?: Vector3;
  23749. /**
  23750. * The parent of the physics-enabled object
  23751. */
  23752. parent?: any;
  23753. /**
  23754. * The bounding info of the physics-enabled object
  23755. * @returns The bounding info of the physics-enabled object
  23756. */
  23757. getBoundingInfo(): BoundingInfo;
  23758. /**
  23759. * Computes the world matrix
  23760. * @param force Specifies if the world matrix should be computed by force
  23761. * @returns A world matrix
  23762. */
  23763. computeWorldMatrix(force: boolean): Matrix;
  23764. /**
  23765. * Gets the world matrix
  23766. * @returns A world matrix
  23767. */
  23768. getWorldMatrix?(): Matrix;
  23769. /**
  23770. * Gets the child meshes
  23771. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23772. * @returns An array of abstract meshes
  23773. */
  23774. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23775. /**
  23776. * Gets the vertex data
  23777. * @param kind The type of vertex data
  23778. * @returns A nullable array of numbers, or a float32 array
  23779. */
  23780. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23781. /**
  23782. * Gets the indices from the mesh
  23783. * @returns A nullable array of index arrays
  23784. */
  23785. getIndices?(): Nullable<IndicesArray>;
  23786. /**
  23787. * Gets the scene from the mesh
  23788. * @returns the indices array or null
  23789. */
  23790. getScene?(): Scene;
  23791. /**
  23792. * Gets the absolute position from the mesh
  23793. * @returns the absolute position
  23794. */
  23795. getAbsolutePosition(): Vector3;
  23796. /**
  23797. * Gets the absolute pivot point from the mesh
  23798. * @returns the absolute pivot point
  23799. */
  23800. getAbsolutePivotPoint(): Vector3;
  23801. /**
  23802. * Rotates the mesh
  23803. * @param axis The axis of rotation
  23804. * @param amount The amount of rotation
  23805. * @param space The space of the rotation
  23806. * @returns The rotation transform node
  23807. */
  23808. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23809. /**
  23810. * Translates the mesh
  23811. * @param axis The axis of translation
  23812. * @param distance The distance of translation
  23813. * @param space The space of the translation
  23814. * @returns The transform node
  23815. */
  23816. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23817. /**
  23818. * Sets the absolute position of the mesh
  23819. * @param absolutePosition The absolute position of the mesh
  23820. * @returns The transform node
  23821. */
  23822. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23823. /**
  23824. * Gets the class name of the mesh
  23825. * @returns The class name
  23826. */
  23827. getClassName(): string;
  23828. }
  23829. /**
  23830. * Represents a physics imposter
  23831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23832. */
  23833. export class PhysicsImpostor {
  23834. /**
  23835. * The physics-enabled object used as the physics imposter
  23836. */
  23837. object: IPhysicsEnabledObject;
  23838. /**
  23839. * The type of the physics imposter
  23840. */
  23841. type: number;
  23842. private _options;
  23843. private _scene?;
  23844. /**
  23845. * The default object size of the imposter
  23846. */
  23847. static DEFAULT_OBJECT_SIZE: Vector3;
  23848. /**
  23849. * The identity quaternion of the imposter
  23850. */
  23851. static IDENTITY_QUATERNION: Quaternion;
  23852. /** @hidden */
  23853. _pluginData: any;
  23854. private _physicsEngine;
  23855. private _physicsBody;
  23856. private _bodyUpdateRequired;
  23857. private _onBeforePhysicsStepCallbacks;
  23858. private _onAfterPhysicsStepCallbacks;
  23859. /** @hidden */
  23860. _onPhysicsCollideCallbacks: Array<{
  23861. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23862. otherImpostors: Array<PhysicsImpostor>;
  23863. }>;
  23864. private _deltaPosition;
  23865. private _deltaRotation;
  23866. private _deltaRotationConjugated;
  23867. /** @hidden */
  23868. _isFromLine: boolean;
  23869. private _parent;
  23870. private _isDisposed;
  23871. private static _tmpVecs;
  23872. private static _tmpQuat;
  23873. /**
  23874. * Specifies if the physics imposter is disposed
  23875. */
  23876. readonly isDisposed: boolean;
  23877. /**
  23878. * Gets the mass of the physics imposter
  23879. */
  23880. mass: number;
  23881. /**
  23882. * Gets the coefficient of friction
  23883. */
  23884. /**
  23885. * Sets the coefficient of friction
  23886. */
  23887. friction: number;
  23888. /**
  23889. * Gets the coefficient of restitution
  23890. */
  23891. /**
  23892. * Sets the coefficient of restitution
  23893. */
  23894. restitution: number;
  23895. /**
  23896. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23897. */
  23898. /**
  23899. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23900. */
  23901. pressure: number;
  23902. /**
  23903. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23904. */
  23905. /**
  23906. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23907. */
  23908. stiffness: number;
  23909. /**
  23910. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23911. */
  23912. /**
  23913. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23914. */
  23915. velocityIterations: number;
  23916. /**
  23917. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23918. */
  23919. /**
  23920. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23921. */
  23922. positionIterations: number;
  23923. /**
  23924. * The unique id of the physics imposter
  23925. * set by the physics engine when adding this impostor to the array
  23926. */
  23927. uniqueId: number;
  23928. /**
  23929. * @hidden
  23930. */
  23931. soft: boolean;
  23932. /**
  23933. * @hidden
  23934. */
  23935. segments: number;
  23936. private _joints;
  23937. /**
  23938. * Initializes the physics imposter
  23939. * @param object The physics-enabled object used as the physics imposter
  23940. * @param type The type of the physics imposter
  23941. * @param _options The options for the physics imposter
  23942. * @param _scene The Babylon scene
  23943. */
  23944. constructor(
  23945. /**
  23946. * The physics-enabled object used as the physics imposter
  23947. */
  23948. object: IPhysicsEnabledObject,
  23949. /**
  23950. * The type of the physics imposter
  23951. */
  23952. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23953. /**
  23954. * This function will completly initialize this impostor.
  23955. * It will create a new body - but only if this mesh has no parent.
  23956. * If it has, this impostor will not be used other than to define the impostor
  23957. * of the child mesh.
  23958. * @hidden
  23959. */
  23960. _init(): void;
  23961. private _getPhysicsParent;
  23962. /**
  23963. * Should a new body be generated.
  23964. * @returns boolean specifying if body initialization is required
  23965. */
  23966. isBodyInitRequired(): boolean;
  23967. /**
  23968. * Sets the updated scaling
  23969. * @param updated Specifies if the scaling is updated
  23970. */
  23971. setScalingUpdated(): void;
  23972. /**
  23973. * Force a regeneration of this or the parent's impostor's body.
  23974. * Use under cautious - This will remove all joints already implemented.
  23975. */
  23976. forceUpdate(): void;
  23977. /**
  23978. * Gets the body that holds this impostor. Either its own, or its parent.
  23979. */
  23980. /**
  23981. * Set the physics body. Used mainly by the physics engine/plugin
  23982. */
  23983. physicsBody: any;
  23984. /**
  23985. * Get the parent of the physics imposter
  23986. * @returns Physics imposter or null
  23987. */
  23988. /**
  23989. * Sets the parent of the physics imposter
  23990. */
  23991. parent: Nullable<PhysicsImpostor>;
  23992. /**
  23993. * Resets the update flags
  23994. */
  23995. resetUpdateFlags(): void;
  23996. /**
  23997. * Gets the object extend size
  23998. * @returns the object extend size
  23999. */
  24000. getObjectExtendSize(): Vector3;
  24001. /**
  24002. * Gets the object center
  24003. * @returns The object center
  24004. */
  24005. getObjectCenter(): Vector3;
  24006. /**
  24007. * Get a specific parametes from the options parameter
  24008. * @param paramName The object parameter name
  24009. * @returns The object parameter
  24010. */
  24011. getParam(paramName: string): any;
  24012. /**
  24013. * Sets a specific parameter in the options given to the physics plugin
  24014. * @param paramName The parameter name
  24015. * @param value The value of the parameter
  24016. */
  24017. setParam(paramName: string, value: number): void;
  24018. /**
  24019. * Specifically change the body's mass option. Won't recreate the physics body object
  24020. * @param mass The mass of the physics imposter
  24021. */
  24022. setMass(mass: number): void;
  24023. /**
  24024. * Gets the linear velocity
  24025. * @returns linear velocity or null
  24026. */
  24027. getLinearVelocity(): Nullable<Vector3>;
  24028. /**
  24029. * Sets the linear velocity
  24030. * @param velocity linear velocity or null
  24031. */
  24032. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24033. /**
  24034. * Gets the angular velocity
  24035. * @returns angular velocity or null
  24036. */
  24037. getAngularVelocity(): Nullable<Vector3>;
  24038. /**
  24039. * Sets the angular velocity
  24040. * @param velocity The velocity or null
  24041. */
  24042. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24043. /**
  24044. * Execute a function with the physics plugin native code
  24045. * Provide a function the will have two variables - the world object and the physics body object
  24046. * @param func The function to execute with the physics plugin native code
  24047. */
  24048. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24049. /**
  24050. * Register a function that will be executed before the physics world is stepping forward
  24051. * @param func The function to execute before the physics world is stepped forward
  24052. */
  24053. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24054. /**
  24055. * Unregister a function that will be executed before the physics world is stepping forward
  24056. * @param func The function to execute before the physics world is stepped forward
  24057. */
  24058. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24059. /**
  24060. * Register a function that will be executed after the physics step
  24061. * @param func The function to execute after physics step
  24062. */
  24063. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24064. /**
  24065. * Unregisters a function that will be executed after the physics step
  24066. * @param func The function to execute after physics step
  24067. */
  24068. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24069. /**
  24070. * register a function that will be executed when this impostor collides against a different body
  24071. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24072. * @param func Callback that is executed on collision
  24073. */
  24074. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24075. /**
  24076. * Unregisters the physics imposter on contact
  24077. * @param collideAgainst The physics object to collide against
  24078. * @param func Callback to execute on collision
  24079. */
  24080. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24081. private _tmpQuat;
  24082. private _tmpQuat2;
  24083. /**
  24084. * Get the parent rotation
  24085. * @returns The parent rotation
  24086. */
  24087. getParentsRotation(): Quaternion;
  24088. /**
  24089. * this function is executed by the physics engine.
  24090. */
  24091. beforeStep: () => void;
  24092. /**
  24093. * this function is executed by the physics engine
  24094. */
  24095. afterStep: () => void;
  24096. /**
  24097. * Legacy collision detection event support
  24098. */
  24099. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24100. /**
  24101. * event and body object due to cannon's event-based architecture.
  24102. */
  24103. onCollide: (e: {
  24104. body: any;
  24105. }) => void;
  24106. /**
  24107. * Apply a force
  24108. * @param force The force to apply
  24109. * @param contactPoint The contact point for the force
  24110. * @returns The physics imposter
  24111. */
  24112. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24113. /**
  24114. * Apply an impulse
  24115. * @param force The impulse force
  24116. * @param contactPoint The contact point for the impulse force
  24117. * @returns The physics imposter
  24118. */
  24119. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24120. /**
  24121. * A help function to create a joint
  24122. * @param otherImpostor A physics imposter used to create a joint
  24123. * @param jointType The type of joint
  24124. * @param jointData The data for the joint
  24125. * @returns The physics imposter
  24126. */
  24127. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24128. /**
  24129. * Add a joint to this impostor with a different impostor
  24130. * @param otherImpostor A physics imposter used to add a joint
  24131. * @param joint The joint to add
  24132. * @returns The physics imposter
  24133. */
  24134. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24135. /**
  24136. * Add an anchor to a cloth impostor
  24137. * @param otherImpostor rigid impostor to anchor to
  24138. * @param width ratio across width from 0 to 1
  24139. * @param height ratio up height from 0 to 1
  24140. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24141. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24142. * @returns impostor the soft imposter
  24143. */
  24144. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24145. /**
  24146. * Add a hook to a rope impostor
  24147. * @param otherImpostor rigid impostor to anchor to
  24148. * @param length ratio across rope from 0 to 1
  24149. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24150. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24151. * @returns impostor the rope imposter
  24152. */
  24153. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24154. /**
  24155. * Will keep this body still, in a sleep mode.
  24156. * @returns the physics imposter
  24157. */
  24158. sleep(): PhysicsImpostor;
  24159. /**
  24160. * Wake the body up.
  24161. * @returns The physics imposter
  24162. */
  24163. wakeUp(): PhysicsImpostor;
  24164. /**
  24165. * Clones the physics imposter
  24166. * @param newObject The physics imposter clones to this physics-enabled object
  24167. * @returns A nullable physics imposter
  24168. */
  24169. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24170. /**
  24171. * Disposes the physics imposter
  24172. */
  24173. dispose(): void;
  24174. /**
  24175. * Sets the delta position
  24176. * @param position The delta position amount
  24177. */
  24178. setDeltaPosition(position: Vector3): void;
  24179. /**
  24180. * Sets the delta rotation
  24181. * @param rotation The delta rotation amount
  24182. */
  24183. setDeltaRotation(rotation: Quaternion): void;
  24184. /**
  24185. * Gets the box size of the physics imposter and stores the result in the input parameter
  24186. * @param result Stores the box size
  24187. * @returns The physics imposter
  24188. */
  24189. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24190. /**
  24191. * Gets the radius of the physics imposter
  24192. * @returns Radius of the physics imposter
  24193. */
  24194. getRadius(): number;
  24195. /**
  24196. * Sync a bone with this impostor
  24197. * @param bone The bone to sync to the impostor.
  24198. * @param boneMesh The mesh that the bone is influencing.
  24199. * @param jointPivot The pivot of the joint / bone in local space.
  24200. * @param distToJoint Optional distance from the impostor to the joint.
  24201. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24202. */
  24203. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24204. /**
  24205. * Sync impostor to a bone
  24206. * @param bone The bone that the impostor will be synced to.
  24207. * @param boneMesh The mesh that the bone is influencing.
  24208. * @param jointPivot The pivot of the joint / bone in local space.
  24209. * @param distToJoint Optional distance from the impostor to the joint.
  24210. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24211. * @param boneAxis Optional vector3 axis the bone is aligned with
  24212. */
  24213. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24214. /**
  24215. * No-Imposter type
  24216. */
  24217. static NoImpostor: number;
  24218. /**
  24219. * Sphere-Imposter type
  24220. */
  24221. static SphereImpostor: number;
  24222. /**
  24223. * Box-Imposter type
  24224. */
  24225. static BoxImpostor: number;
  24226. /**
  24227. * Plane-Imposter type
  24228. */
  24229. static PlaneImpostor: number;
  24230. /**
  24231. * Mesh-imposter type
  24232. */
  24233. static MeshImpostor: number;
  24234. /**
  24235. * Capsule-Impostor type (Ammo.js plugin only)
  24236. */
  24237. static CapsuleImpostor: number;
  24238. /**
  24239. * Cylinder-Imposter type
  24240. */
  24241. static CylinderImpostor: number;
  24242. /**
  24243. * Particle-Imposter type
  24244. */
  24245. static ParticleImpostor: number;
  24246. /**
  24247. * Heightmap-Imposter type
  24248. */
  24249. static HeightmapImpostor: number;
  24250. /**
  24251. * ConvexHull-Impostor type (Ammo.js plugin only)
  24252. */
  24253. static ConvexHullImpostor: number;
  24254. /**
  24255. * Rope-Imposter type
  24256. */
  24257. static RopeImpostor: number;
  24258. /**
  24259. * Cloth-Imposter type
  24260. */
  24261. static ClothImpostor: number;
  24262. /**
  24263. * Softbody-Imposter type
  24264. */
  24265. static SoftbodyImpostor: number;
  24266. }
  24267. }
  24268. declare module "babylonjs/Meshes/mesh" {
  24269. import { Observable } from "babylonjs/Misc/observable";
  24270. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24271. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24272. import { Camera } from "babylonjs/Cameras/camera";
  24273. import { Scene } from "babylonjs/scene";
  24274. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24275. import { Color4 } from "babylonjs/Maths/math.color";
  24276. import { Engine } from "babylonjs/Engines/engine";
  24277. import { Node } from "babylonjs/node";
  24278. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24279. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24280. import { Buffer } from "babylonjs/Meshes/buffer";
  24281. import { Geometry } from "babylonjs/Meshes/geometry";
  24282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24284. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24285. import { Effect } from "babylonjs/Materials/effect";
  24286. import { Material } from "babylonjs/Materials/material";
  24287. import { Skeleton } from "babylonjs/Bones/skeleton";
  24288. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24289. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24290. import { Path3D } from "babylonjs/Maths/math.path";
  24291. import { Plane } from "babylonjs/Maths/math.plane";
  24292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24293. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24294. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24295. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24296. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24298. /**
  24299. * @hidden
  24300. **/
  24301. export class _CreationDataStorage {
  24302. closePath?: boolean;
  24303. closeArray?: boolean;
  24304. idx: number[];
  24305. dashSize: number;
  24306. gapSize: number;
  24307. path3D: Path3D;
  24308. pathArray: Vector3[][];
  24309. arc: number;
  24310. radius: number;
  24311. cap: number;
  24312. tessellation: number;
  24313. }
  24314. /**
  24315. * @hidden
  24316. **/
  24317. class _InstanceDataStorage {
  24318. visibleInstances: any;
  24319. batchCache: _InstancesBatch;
  24320. instancesBufferSize: number;
  24321. instancesBuffer: Nullable<Buffer>;
  24322. instancesData: Float32Array;
  24323. overridenInstanceCount: number;
  24324. isFrozen: boolean;
  24325. previousBatch: Nullable<_InstancesBatch>;
  24326. hardwareInstancedRendering: boolean;
  24327. sideOrientation: number;
  24328. }
  24329. /**
  24330. * @hidden
  24331. **/
  24332. export class _InstancesBatch {
  24333. mustReturn: boolean;
  24334. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24335. renderSelf: boolean[];
  24336. hardwareInstancedRendering: boolean[];
  24337. }
  24338. /**
  24339. * Class used to represent renderable models
  24340. */
  24341. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24342. /**
  24343. * Mesh side orientation : usually the external or front surface
  24344. */
  24345. static readonly FRONTSIDE: number;
  24346. /**
  24347. * Mesh side orientation : usually the internal or back surface
  24348. */
  24349. static readonly BACKSIDE: number;
  24350. /**
  24351. * Mesh side orientation : both internal and external or front and back surfaces
  24352. */
  24353. static readonly DOUBLESIDE: number;
  24354. /**
  24355. * Mesh side orientation : by default, `FRONTSIDE`
  24356. */
  24357. static readonly DEFAULTSIDE: number;
  24358. /**
  24359. * Mesh cap setting : no cap
  24360. */
  24361. static readonly NO_CAP: number;
  24362. /**
  24363. * Mesh cap setting : one cap at the beginning of the mesh
  24364. */
  24365. static readonly CAP_START: number;
  24366. /**
  24367. * Mesh cap setting : one cap at the end of the mesh
  24368. */
  24369. static readonly CAP_END: number;
  24370. /**
  24371. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24372. */
  24373. static readonly CAP_ALL: number;
  24374. /**
  24375. * Mesh pattern setting : no flip or rotate
  24376. */
  24377. static readonly NO_FLIP: number;
  24378. /**
  24379. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24380. */
  24381. static readonly FLIP_TILE: number;
  24382. /**
  24383. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24384. */
  24385. static readonly ROTATE_TILE: number;
  24386. /**
  24387. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24388. */
  24389. static readonly FLIP_ROW: number;
  24390. /**
  24391. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24392. */
  24393. static readonly ROTATE_ROW: number;
  24394. /**
  24395. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24396. */
  24397. static readonly FLIP_N_ROTATE_TILE: number;
  24398. /**
  24399. * Mesh pattern setting : rotate pattern and rotate
  24400. */
  24401. static readonly FLIP_N_ROTATE_ROW: number;
  24402. /**
  24403. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24404. */
  24405. static readonly CENTER: number;
  24406. /**
  24407. * Mesh tile positioning : part tiles on left
  24408. */
  24409. static readonly LEFT: number;
  24410. /**
  24411. * Mesh tile positioning : part tiles on right
  24412. */
  24413. static readonly RIGHT: number;
  24414. /**
  24415. * Mesh tile positioning : part tiles on top
  24416. */
  24417. static readonly TOP: number;
  24418. /**
  24419. * Mesh tile positioning : part tiles on bottom
  24420. */
  24421. static readonly BOTTOM: number;
  24422. /**
  24423. * Gets the default side orientation.
  24424. * @param orientation the orientation to value to attempt to get
  24425. * @returns the default orientation
  24426. * @hidden
  24427. */
  24428. static _GetDefaultSideOrientation(orientation?: number): number;
  24429. private _internalMeshDataInfo;
  24430. /**
  24431. * An event triggered before rendering the mesh
  24432. */
  24433. readonly onBeforeRenderObservable: Observable<Mesh>;
  24434. /**
  24435. * An event triggered before binding the mesh
  24436. */
  24437. readonly onBeforeBindObservable: Observable<Mesh>;
  24438. /**
  24439. * An event triggered after rendering the mesh
  24440. */
  24441. readonly onAfterRenderObservable: Observable<Mesh>;
  24442. /**
  24443. * An event triggered before drawing the mesh
  24444. */
  24445. readonly onBeforeDrawObservable: Observable<Mesh>;
  24446. private _onBeforeDrawObserver;
  24447. /**
  24448. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24449. */
  24450. onBeforeDraw: () => void;
  24451. readonly hasInstances: boolean;
  24452. /**
  24453. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24454. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24455. */
  24456. delayLoadState: number;
  24457. /**
  24458. * Gets the list of instances created from this mesh
  24459. * it is not supposed to be modified manually.
  24460. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24462. */
  24463. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24464. /**
  24465. * Gets the file containing delay loading data for this mesh
  24466. */
  24467. delayLoadingFile: string;
  24468. /** @hidden */
  24469. _binaryInfo: any;
  24470. /**
  24471. * User defined function used to change how LOD level selection is done
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24473. */
  24474. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24475. /**
  24476. * Gets or sets the morph target manager
  24477. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24478. */
  24479. morphTargetManager: Nullable<MorphTargetManager>;
  24480. /** @hidden */
  24481. _creationDataStorage: Nullable<_CreationDataStorage>;
  24482. /** @hidden */
  24483. _geometry: Nullable<Geometry>;
  24484. /** @hidden */
  24485. _delayInfo: Array<string>;
  24486. /** @hidden */
  24487. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24488. /** @hidden */
  24489. _instanceDataStorage: _InstanceDataStorage;
  24490. private _effectiveMaterial;
  24491. /** @hidden */
  24492. _shouldGenerateFlatShading: boolean;
  24493. /** @hidden */
  24494. _originalBuilderSideOrientation: number;
  24495. /**
  24496. * Use this property to change the original side orientation defined at construction time
  24497. */
  24498. overrideMaterialSideOrientation: Nullable<number>;
  24499. /**
  24500. * Gets the source mesh (the one used to clone this one from)
  24501. */
  24502. readonly source: Nullable<Mesh>;
  24503. /**
  24504. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24505. */
  24506. isUnIndexed: boolean;
  24507. /**
  24508. * @constructor
  24509. * @param name The value used by scene.getMeshByName() to do a lookup.
  24510. * @param scene The scene to add this mesh to.
  24511. * @param parent The parent of this mesh, if it has one
  24512. * @param source An optional Mesh from which geometry is shared, cloned.
  24513. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24514. * When false, achieved by calling a clone(), also passing False.
  24515. * This will make creation of children, recursive.
  24516. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24517. */
  24518. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24519. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24520. doNotInstantiate: boolean;
  24521. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24522. /**
  24523. * Gets the class name
  24524. * @returns the string "Mesh".
  24525. */
  24526. getClassName(): string;
  24527. /** @hidden */
  24528. readonly _isMesh: boolean;
  24529. /**
  24530. * Returns a description of this mesh
  24531. * @param fullDetails define if full details about this mesh must be used
  24532. * @returns a descriptive string representing this mesh
  24533. */
  24534. toString(fullDetails?: boolean): string;
  24535. /** @hidden */
  24536. _unBindEffect(): void;
  24537. /**
  24538. * Gets a boolean indicating if this mesh has LOD
  24539. */
  24540. readonly hasLODLevels: boolean;
  24541. /**
  24542. * Gets the list of MeshLODLevel associated with the current mesh
  24543. * @returns an array of MeshLODLevel
  24544. */
  24545. getLODLevels(): MeshLODLevel[];
  24546. private _sortLODLevels;
  24547. /**
  24548. * Add a mesh as LOD level triggered at the given distance.
  24549. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24550. * @param distance The distance from the center of the object to show this level
  24551. * @param mesh The mesh to be added as LOD level (can be null)
  24552. * @return This mesh (for chaining)
  24553. */
  24554. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24555. /**
  24556. * Returns the LOD level mesh at the passed distance or null if not found.
  24557. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24558. * @param distance The distance from the center of the object to show this level
  24559. * @returns a Mesh or `null`
  24560. */
  24561. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24562. /**
  24563. * Remove a mesh from the LOD array
  24564. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24565. * @param mesh defines the mesh to be removed
  24566. * @return This mesh (for chaining)
  24567. */
  24568. removeLODLevel(mesh: Mesh): Mesh;
  24569. /**
  24570. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24571. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24572. * @param camera defines the camera to use to compute distance
  24573. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24574. * @return This mesh (for chaining)
  24575. */
  24576. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24577. /**
  24578. * Gets the mesh internal Geometry object
  24579. */
  24580. readonly geometry: Nullable<Geometry>;
  24581. /**
  24582. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24583. * @returns the total number of vertices
  24584. */
  24585. getTotalVertices(): number;
  24586. /**
  24587. * Returns the content of an associated vertex buffer
  24588. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24589. * - VertexBuffer.PositionKind
  24590. * - VertexBuffer.UVKind
  24591. * - VertexBuffer.UV2Kind
  24592. * - VertexBuffer.UV3Kind
  24593. * - VertexBuffer.UV4Kind
  24594. * - VertexBuffer.UV5Kind
  24595. * - VertexBuffer.UV6Kind
  24596. * - VertexBuffer.ColorKind
  24597. * - VertexBuffer.MatricesIndicesKind
  24598. * - VertexBuffer.MatricesIndicesExtraKind
  24599. * - VertexBuffer.MatricesWeightsKind
  24600. * - VertexBuffer.MatricesWeightsExtraKind
  24601. * @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
  24602. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24603. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24604. */
  24605. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24606. /**
  24607. * Returns the mesh VertexBuffer object from the requested `kind`
  24608. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24609. * - VertexBuffer.PositionKind
  24610. * - VertexBuffer.NormalKind
  24611. * - VertexBuffer.UVKind
  24612. * - VertexBuffer.UV2Kind
  24613. * - VertexBuffer.UV3Kind
  24614. * - VertexBuffer.UV4Kind
  24615. * - VertexBuffer.UV5Kind
  24616. * - VertexBuffer.UV6Kind
  24617. * - VertexBuffer.ColorKind
  24618. * - VertexBuffer.MatricesIndicesKind
  24619. * - VertexBuffer.MatricesIndicesExtraKind
  24620. * - VertexBuffer.MatricesWeightsKind
  24621. * - VertexBuffer.MatricesWeightsExtraKind
  24622. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24623. */
  24624. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24625. /**
  24626. * Tests if a specific vertex buffer is associated with this mesh
  24627. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24628. * - VertexBuffer.PositionKind
  24629. * - VertexBuffer.NormalKind
  24630. * - VertexBuffer.UVKind
  24631. * - VertexBuffer.UV2Kind
  24632. * - VertexBuffer.UV3Kind
  24633. * - VertexBuffer.UV4Kind
  24634. * - VertexBuffer.UV5Kind
  24635. * - VertexBuffer.UV6Kind
  24636. * - VertexBuffer.ColorKind
  24637. * - VertexBuffer.MatricesIndicesKind
  24638. * - VertexBuffer.MatricesIndicesExtraKind
  24639. * - VertexBuffer.MatricesWeightsKind
  24640. * - VertexBuffer.MatricesWeightsExtraKind
  24641. * @returns a boolean
  24642. */
  24643. isVerticesDataPresent(kind: string): boolean;
  24644. /**
  24645. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24646. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24647. * - VertexBuffer.PositionKind
  24648. * - VertexBuffer.UVKind
  24649. * - VertexBuffer.UV2Kind
  24650. * - VertexBuffer.UV3Kind
  24651. * - VertexBuffer.UV4Kind
  24652. * - VertexBuffer.UV5Kind
  24653. * - VertexBuffer.UV6Kind
  24654. * - VertexBuffer.ColorKind
  24655. * - VertexBuffer.MatricesIndicesKind
  24656. * - VertexBuffer.MatricesIndicesExtraKind
  24657. * - VertexBuffer.MatricesWeightsKind
  24658. * - VertexBuffer.MatricesWeightsExtraKind
  24659. * @returns a boolean
  24660. */
  24661. isVertexBufferUpdatable(kind: string): boolean;
  24662. /**
  24663. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24664. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24665. * - VertexBuffer.PositionKind
  24666. * - VertexBuffer.NormalKind
  24667. * - VertexBuffer.UVKind
  24668. * - VertexBuffer.UV2Kind
  24669. * - VertexBuffer.UV3Kind
  24670. * - VertexBuffer.UV4Kind
  24671. * - VertexBuffer.UV5Kind
  24672. * - VertexBuffer.UV6Kind
  24673. * - VertexBuffer.ColorKind
  24674. * - VertexBuffer.MatricesIndicesKind
  24675. * - VertexBuffer.MatricesIndicesExtraKind
  24676. * - VertexBuffer.MatricesWeightsKind
  24677. * - VertexBuffer.MatricesWeightsExtraKind
  24678. * @returns an array of strings
  24679. */
  24680. getVerticesDataKinds(): string[];
  24681. /**
  24682. * Returns a positive integer : the total number of indices in this mesh geometry.
  24683. * @returns the numner of indices or zero if the mesh has no geometry.
  24684. */
  24685. getTotalIndices(): number;
  24686. /**
  24687. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24688. * @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.
  24689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24690. * @returns the indices array or an empty array if the mesh has no geometry
  24691. */
  24692. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24693. readonly isBlocked: boolean;
  24694. /**
  24695. * Determine if the current mesh is ready to be rendered
  24696. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24697. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24698. * @returns true if all associated assets are ready (material, textures, shaders)
  24699. */
  24700. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24701. /**
  24702. * 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.
  24703. */
  24704. readonly areNormalsFrozen: boolean;
  24705. /**
  24706. * 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.
  24707. * @returns the current mesh
  24708. */
  24709. freezeNormals(): Mesh;
  24710. /**
  24711. * 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
  24712. * @returns the current mesh
  24713. */
  24714. unfreezeNormals(): Mesh;
  24715. /**
  24716. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24717. */
  24718. overridenInstanceCount: number;
  24719. /** @hidden */
  24720. _preActivate(): Mesh;
  24721. /** @hidden */
  24722. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24723. /** @hidden */
  24724. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24725. /**
  24726. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24727. * This means the mesh underlying bounding box and sphere are recomputed.
  24728. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24729. * @returns the current mesh
  24730. */
  24731. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24732. /** @hidden */
  24733. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24734. /**
  24735. * This function will subdivide the mesh into multiple submeshes
  24736. * @param count defines the expected number of submeshes
  24737. */
  24738. subdivide(count: number): void;
  24739. /**
  24740. * Copy a FloatArray into a specific associated vertex buffer
  24741. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24742. * - VertexBuffer.PositionKind
  24743. * - VertexBuffer.UVKind
  24744. * - VertexBuffer.UV2Kind
  24745. * - VertexBuffer.UV3Kind
  24746. * - VertexBuffer.UV4Kind
  24747. * - VertexBuffer.UV5Kind
  24748. * - VertexBuffer.UV6Kind
  24749. * - VertexBuffer.ColorKind
  24750. * - VertexBuffer.MatricesIndicesKind
  24751. * - VertexBuffer.MatricesIndicesExtraKind
  24752. * - VertexBuffer.MatricesWeightsKind
  24753. * - VertexBuffer.MatricesWeightsExtraKind
  24754. * @param data defines the data source
  24755. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24756. * @param stride defines the data stride size (can be null)
  24757. * @returns the current mesh
  24758. */
  24759. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24760. /**
  24761. * Delete a vertex buffer associated with this mesh
  24762. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24763. * - VertexBuffer.PositionKind
  24764. * - VertexBuffer.UVKind
  24765. * - VertexBuffer.UV2Kind
  24766. * - VertexBuffer.UV3Kind
  24767. * - VertexBuffer.UV4Kind
  24768. * - VertexBuffer.UV5Kind
  24769. * - VertexBuffer.UV6Kind
  24770. * - VertexBuffer.ColorKind
  24771. * - VertexBuffer.MatricesIndicesKind
  24772. * - VertexBuffer.MatricesIndicesExtraKind
  24773. * - VertexBuffer.MatricesWeightsKind
  24774. * - VertexBuffer.MatricesWeightsExtraKind
  24775. */
  24776. removeVerticesData(kind: string): void;
  24777. /**
  24778. * Flags an associated vertex buffer as updatable
  24779. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24780. * - VertexBuffer.PositionKind
  24781. * - VertexBuffer.UVKind
  24782. * - VertexBuffer.UV2Kind
  24783. * - VertexBuffer.UV3Kind
  24784. * - VertexBuffer.UV4Kind
  24785. * - VertexBuffer.UV5Kind
  24786. * - VertexBuffer.UV6Kind
  24787. * - VertexBuffer.ColorKind
  24788. * - VertexBuffer.MatricesIndicesKind
  24789. * - VertexBuffer.MatricesIndicesExtraKind
  24790. * - VertexBuffer.MatricesWeightsKind
  24791. * - VertexBuffer.MatricesWeightsExtraKind
  24792. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24793. */
  24794. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24795. /**
  24796. * Sets the mesh global Vertex Buffer
  24797. * @param buffer defines the buffer to use
  24798. * @returns the current mesh
  24799. */
  24800. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24801. /**
  24802. * Update a specific associated vertex buffer
  24803. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @param data defines the data source
  24817. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24818. * @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)
  24819. * @returns the current mesh
  24820. */
  24821. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24822. /**
  24823. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24824. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24825. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24826. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24827. * @returns the current mesh
  24828. */
  24829. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24830. /**
  24831. * Creates a un-shared specific occurence of the geometry for the mesh.
  24832. * @returns the current mesh
  24833. */
  24834. makeGeometryUnique(): Mesh;
  24835. /**
  24836. * Set the index buffer of this mesh
  24837. * @param indices defines the source data
  24838. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24839. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24840. * @returns the current mesh
  24841. */
  24842. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24843. /**
  24844. * Update the current index buffer
  24845. * @param indices defines the source data
  24846. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24847. * @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)
  24848. * @returns the current mesh
  24849. */
  24850. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24851. /**
  24852. * Invert the geometry to move from a right handed system to a left handed one.
  24853. * @returns the current mesh
  24854. */
  24855. toLeftHanded(): Mesh;
  24856. /** @hidden */
  24857. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24858. /** @hidden */
  24859. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24860. /**
  24861. * Registers for this mesh a javascript function called just before the rendering process
  24862. * @param func defines the function to call before rendering this mesh
  24863. * @returns the current mesh
  24864. */
  24865. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24866. /**
  24867. * Disposes a previously registered javascript function called before the rendering
  24868. * @param func defines the function to remove
  24869. * @returns the current mesh
  24870. */
  24871. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24872. /**
  24873. * Registers for this mesh a javascript function called just after the rendering is complete
  24874. * @param func defines the function to call after rendering this mesh
  24875. * @returns the current mesh
  24876. */
  24877. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24878. /**
  24879. * Disposes a previously registered javascript function called after the rendering.
  24880. * @param func defines the function to remove
  24881. * @returns the current mesh
  24882. */
  24883. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24884. /** @hidden */
  24885. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24886. /** @hidden */
  24887. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24888. /** @hidden */
  24889. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24890. /** @hidden */
  24891. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24892. /** @hidden */
  24893. _rebuild(): void;
  24894. /** @hidden */
  24895. _freeze(): void;
  24896. /** @hidden */
  24897. _unFreeze(): void;
  24898. /**
  24899. * 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
  24900. * @param subMesh defines the subMesh to render
  24901. * @param enableAlphaMode defines if alpha mode can be changed
  24902. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24903. * @returns the current mesh
  24904. */
  24905. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24906. private _onBeforeDraw;
  24907. /**
  24908. * Renormalize the mesh and patch it up if there are no weights
  24909. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24910. * However in the case of zero weights then we set just a single influence to 1.
  24911. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24912. */
  24913. cleanMatrixWeights(): void;
  24914. private normalizeSkinFourWeights;
  24915. private normalizeSkinWeightsAndExtra;
  24916. /**
  24917. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24918. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24919. * the user know there was an issue with importing the mesh
  24920. * @returns a validation object with skinned, valid and report string
  24921. */
  24922. validateSkinning(): {
  24923. skinned: boolean;
  24924. valid: boolean;
  24925. report: string;
  24926. };
  24927. /** @hidden */
  24928. _checkDelayState(): Mesh;
  24929. private _queueLoad;
  24930. /**
  24931. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24932. * A mesh is in the frustum if its bounding box intersects the frustum
  24933. * @param frustumPlanes defines the frustum to test
  24934. * @returns true if the mesh is in the frustum planes
  24935. */
  24936. isInFrustum(frustumPlanes: Plane[]): boolean;
  24937. /**
  24938. * Sets the mesh material by the material or multiMaterial `id` property
  24939. * @param id is a string identifying the material or the multiMaterial
  24940. * @returns the current mesh
  24941. */
  24942. setMaterialByID(id: string): Mesh;
  24943. /**
  24944. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24945. * @returns an array of IAnimatable
  24946. */
  24947. getAnimatables(): IAnimatable[];
  24948. /**
  24949. * Modifies the mesh geometry according to the passed transformation matrix.
  24950. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24951. * The mesh normals are modified using the same transformation.
  24952. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24953. * @param transform defines the transform matrix to use
  24954. * @see http://doc.babylonjs.com/resources/baking_transformations
  24955. * @returns the current mesh
  24956. */
  24957. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24958. /**
  24959. * Modifies the mesh geometry according to its own current World Matrix.
  24960. * The mesh World Matrix is then reset.
  24961. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24962. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24963. * @see http://doc.babylonjs.com/resources/baking_transformations
  24964. * @returns the current mesh
  24965. */
  24966. bakeCurrentTransformIntoVertices(): Mesh;
  24967. /** @hidden */
  24968. readonly _positions: Nullable<Vector3[]>;
  24969. /** @hidden */
  24970. _resetPointsArrayCache(): Mesh;
  24971. /** @hidden */
  24972. _generatePointsArray(): boolean;
  24973. /**
  24974. * Returns a new Mesh object generated from the current mesh properties.
  24975. * This method must not get confused with createInstance()
  24976. * @param name is a string, the name given to the new mesh
  24977. * @param newParent can be any Node object (default `null`)
  24978. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24979. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24980. * @returns a new mesh
  24981. */
  24982. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24983. /**
  24984. * Releases resources associated with this mesh.
  24985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24987. */
  24988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24989. /** @hidden */
  24990. _disposeInstanceSpecificData(): void;
  24991. /**
  24992. * Modifies the mesh geometry according to a displacement map.
  24993. * 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.
  24994. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24995. * @param url is a string, the URL from the image file is to be downloaded.
  24996. * @param minHeight is the lower limit of the displacement.
  24997. * @param maxHeight is the upper limit of the displacement.
  24998. * @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.
  24999. * @param uvOffset is an optional vector2 used to offset UV.
  25000. * @param uvScale is an optional vector2 used to scale UV.
  25001. * @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.
  25002. * @returns the Mesh.
  25003. */
  25004. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25005. /**
  25006. * Modifies the mesh geometry according to a displacementMap buffer.
  25007. * 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.
  25008. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25009. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25010. * @param heightMapWidth is the width of the buffer image.
  25011. * @param heightMapHeight is the height of the buffer image.
  25012. * @param minHeight is the lower limit of the displacement.
  25013. * @param maxHeight is the upper limit of the displacement.
  25014. * @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.
  25015. * @param uvOffset is an optional vector2 used to offset UV.
  25016. * @param uvScale is an optional vector2 used to scale UV.
  25017. * @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.
  25018. * @returns the Mesh.
  25019. */
  25020. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25021. /**
  25022. * Modify the mesh to get a flat shading rendering.
  25023. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25024. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25025. * @returns current mesh
  25026. */
  25027. convertToFlatShadedMesh(): Mesh;
  25028. /**
  25029. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25030. * In other words, more vertices, no more indices and a single bigger VBO.
  25031. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25032. * @returns current mesh
  25033. */
  25034. convertToUnIndexedMesh(): Mesh;
  25035. /**
  25036. * Inverses facet orientations.
  25037. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25038. * @param flipNormals will also inverts the normals
  25039. * @returns current mesh
  25040. */
  25041. flipFaces(flipNormals?: boolean): Mesh;
  25042. /**
  25043. * Increase the number of facets and hence vertices in a mesh
  25044. * Vertex normals are interpolated from existing vertex normals
  25045. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25046. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25047. */
  25048. increaseVertices(numberPerEdge: number): void;
  25049. /**
  25050. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25051. * This will undo any application of covertToFlatShadedMesh
  25052. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25053. */
  25054. forceSharedVertices(): void;
  25055. /** @hidden */
  25056. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25057. /** @hidden */
  25058. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25059. /**
  25060. * Creates a new InstancedMesh object from the mesh model.
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25062. * @param name defines the name of the new instance
  25063. * @returns a new InstancedMesh
  25064. */
  25065. createInstance(name: string): InstancedMesh;
  25066. /**
  25067. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25068. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25069. * @returns the current mesh
  25070. */
  25071. synchronizeInstances(): Mesh;
  25072. /**
  25073. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25074. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25075. * This should be used together with the simplification to avoid disappearing triangles.
  25076. * @param successCallback an optional success callback to be called after the optimization finished.
  25077. * @returns the current mesh
  25078. */
  25079. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25080. /**
  25081. * Serialize current mesh
  25082. * @param serializationObject defines the object which will receive the serialization data
  25083. */
  25084. serialize(serializationObject: any): void;
  25085. /** @hidden */
  25086. _syncGeometryWithMorphTargetManager(): void;
  25087. /** @hidden */
  25088. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25089. /**
  25090. * Returns a new Mesh object parsed from the source provided.
  25091. * @param parsedMesh is the source
  25092. * @param scene defines the hosting scene
  25093. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25094. * @returns a new Mesh
  25095. */
  25096. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25097. /**
  25098. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25099. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25100. * @param name defines the name of the mesh to create
  25101. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25102. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25103. * @param closePath creates a seam between the first and the last points of each path of the path array
  25104. * @param offset is taken in account only if the `pathArray` is containing a single path
  25105. * @param scene defines the hosting scene
  25106. * @param updatable defines if the mesh must be flagged as updatable
  25107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25108. * @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)
  25109. * @returns a new Mesh
  25110. */
  25111. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25114. * @param name defines the name of the mesh to create
  25115. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25116. * @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
  25117. * @param scene defines the hosting scene
  25118. * @param updatable defines if the mesh must be flagged as updatable
  25119. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25120. * @returns a new Mesh
  25121. */
  25122. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25123. /**
  25124. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25125. * @param name defines the name of the mesh to create
  25126. * @param size sets the size (float) of each box side (default 1)
  25127. * @param scene defines the hosting scene
  25128. * @param updatable defines if the mesh must be flagged as updatable
  25129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25130. * @returns a new Mesh
  25131. */
  25132. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25133. /**
  25134. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25135. * @param name defines the name of the mesh to create
  25136. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25137. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25138. * @param scene defines the hosting scene
  25139. * @param updatable defines if the mesh must be flagged as updatable
  25140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25141. * @returns a new Mesh
  25142. */
  25143. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25144. /**
  25145. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25146. * @param name defines the name of the mesh to create
  25147. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25148. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25149. * @param scene defines the hosting scene
  25150. * @returns a new Mesh
  25151. */
  25152. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25153. /**
  25154. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25155. * @param name defines the name of the mesh to create
  25156. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25157. * @param diameterTop set the top cap diameter (floats, default 1)
  25158. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25159. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25160. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param diameter sets the diameter size (float) of the torus (default 1)
  25171. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25172. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25173. * @param scene defines the hosting scene
  25174. * @param updatable defines if the mesh must be flagged as updatable
  25175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25176. * @returns a new Mesh
  25177. */
  25178. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25179. /**
  25180. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25181. * @param name defines the name of the mesh to create
  25182. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25183. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25184. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25185. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25186. * @param p the number of windings on X axis (positive integers, default 2)
  25187. * @param q the number of windings on Y axis (positive integers, default 3)
  25188. * @param scene defines the hosting scene
  25189. * @param updatable defines if the mesh must be flagged as updatable
  25190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25191. * @returns a new Mesh
  25192. */
  25193. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25194. /**
  25195. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25196. * @param name defines the name of the mesh to create
  25197. * @param points is an array successive Vector3
  25198. * @param scene defines the hosting scene
  25199. * @param updatable defines if the mesh must be flagged as updatable
  25200. * @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).
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25204. /**
  25205. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param points is an array successive Vector3
  25208. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25209. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25210. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25211. * @param scene defines the hosting scene
  25212. * @param updatable defines if the mesh must be flagged as updatable
  25213. * @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)
  25214. * @returns a new Mesh
  25215. */
  25216. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25217. /**
  25218. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25219. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25220. * 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.
  25221. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25222. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25223. * Remember you can only change the shape positions, not their number when updating a polygon.
  25224. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25225. * @param name defines the name of the mesh to create
  25226. * @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
  25227. * @param scene defines the hosting scene
  25228. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25229. * @param updatable defines if the mesh must be flagged as updatable
  25230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25231. * @param earcutInjection can be used to inject your own earcut reference
  25232. * @returns a new Mesh
  25233. */
  25234. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25235. /**
  25236. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25237. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25238. * @param name defines the name of the mesh to create
  25239. * @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
  25240. * @param depth defines the height of extrusion
  25241. * @param scene defines the hosting scene
  25242. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25243. * @param updatable defines if the mesh must be flagged as updatable
  25244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25245. * @param earcutInjection can be used to inject your own earcut reference
  25246. * @returns a new Mesh
  25247. */
  25248. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25249. /**
  25250. * Creates an extruded shape mesh.
  25251. * 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
  25252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25253. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25254. * @param name defines the name of the mesh to create
  25255. * @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
  25256. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25257. * @param scale is the value to scale the shape
  25258. * @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
  25259. * @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
  25260. * @param scene defines the hosting scene
  25261. * @param updatable defines if the mesh must be flagged as updatable
  25262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25263. * @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)
  25264. * @returns a new Mesh
  25265. */
  25266. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25267. /**
  25268. * Creates an custom extruded shape mesh.
  25269. * The custom extrusion is a parametric shape.
  25270. * It has no predefined shape. Its final shape will depend on the input parameters.
  25271. * Please consider using the same method from the MeshBuilder class instead
  25272. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25273. * @param name defines the name of the mesh to create
  25274. * @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
  25275. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25276. * @param scaleFunction is a custom Javascript function called on each path point
  25277. * @param rotationFunction is a custom Javascript function called on each path point
  25278. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25279. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25280. * @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
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25284. * @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)
  25285. * @returns a new Mesh
  25286. */
  25287. 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;
  25288. /**
  25289. * Creates lathe mesh.
  25290. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25291. * Please consider using the same method from the MeshBuilder class instead
  25292. * @param name defines the name of the mesh to create
  25293. * @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
  25294. * @param radius is the radius value of the lathe
  25295. * @param tessellation is the side number of the lathe.
  25296. * @param scene defines the hosting scene
  25297. * @param updatable defines if the mesh must be flagged as updatable
  25298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25299. * @returns a new Mesh
  25300. */
  25301. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25302. /**
  25303. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25304. * @param name defines the name of the mesh to create
  25305. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25306. * @param scene defines the hosting scene
  25307. * @param updatable defines if the mesh must be flagged as updatable
  25308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25309. * @returns a new Mesh
  25310. */
  25311. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25312. /**
  25313. * Creates a ground mesh.
  25314. * Please consider using the same method from the MeshBuilder class instead
  25315. * @param name defines the name of the mesh to create
  25316. * @param width set the width of the ground
  25317. * @param height set the height of the ground
  25318. * @param subdivisions sets the number of subdivisions per side
  25319. * @param scene defines the hosting scene
  25320. * @param updatable defines if the mesh must be flagged as updatable
  25321. * @returns a new Mesh
  25322. */
  25323. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25324. /**
  25325. * Creates a tiled ground mesh.
  25326. * Please consider using the same method from the MeshBuilder class instead
  25327. * @param name defines the name of the mesh to create
  25328. * @param xmin set the ground minimum X coordinate
  25329. * @param zmin set the ground minimum Y coordinate
  25330. * @param xmax set the ground maximum X coordinate
  25331. * @param zmax set the ground maximum Z coordinate
  25332. * @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
  25333. * @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
  25334. * @param scene defines the hosting scene
  25335. * @param updatable defines if the mesh must be flagged as updatable
  25336. * @returns a new Mesh
  25337. */
  25338. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25339. w: number;
  25340. h: number;
  25341. }, precision: {
  25342. w: number;
  25343. h: number;
  25344. }, scene: Scene, updatable?: boolean): Mesh;
  25345. /**
  25346. * Creates a ground mesh from a height map.
  25347. * Please consider using the same method from the MeshBuilder class instead
  25348. * @see http://doc.babylonjs.com/babylon101/height_map
  25349. * @param name defines the name of the mesh to create
  25350. * @param url sets the URL of the height map image resource
  25351. * @param width set the ground width size
  25352. * @param height set the ground height size
  25353. * @param subdivisions sets the number of subdivision per side
  25354. * @param minHeight is the minimum altitude on the ground
  25355. * @param maxHeight is the maximum altitude on the ground
  25356. * @param scene defines the hosting scene
  25357. * @param updatable defines if the mesh must be flagged as updatable
  25358. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25359. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25360. * @returns a new Mesh
  25361. */
  25362. 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;
  25363. /**
  25364. * Creates a tube mesh.
  25365. * The tube is a parametric shape.
  25366. * It has no predefined shape. Its final shape will depend on the input parameters.
  25367. * Please consider using the same method from the MeshBuilder class instead
  25368. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25369. * @param name defines the name of the mesh to create
  25370. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25371. * @param radius sets the tube radius size
  25372. * @param tessellation is the number of sides on the tubular surface
  25373. * @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
  25374. * @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
  25375. * @param scene defines the hosting scene
  25376. * @param updatable defines if the mesh must be flagged as updatable
  25377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25378. * @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)
  25379. * @returns a new Mesh
  25380. */
  25381. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25382. (i: number, distance: number): number;
  25383. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25384. /**
  25385. * Creates a polyhedron mesh.
  25386. * Please consider using the same method from the MeshBuilder class instead.
  25387. * * 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
  25388. * * The parameter `size` (positive float, default 1) sets the polygon size
  25389. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25390. * * 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`
  25391. * * 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
  25392. * * 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)`)
  25393. * * 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
  25394. * * 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
  25395. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25396. * * If you create a double-sided mesh, you can choose what parts of 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
  25397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25398. * @param name defines the name of the mesh to create
  25399. * @param options defines the options used to create the mesh
  25400. * @param scene defines the hosting scene
  25401. * @returns a new Mesh
  25402. */
  25403. static CreatePolyhedron(name: string, options: {
  25404. type?: number;
  25405. size?: number;
  25406. sizeX?: number;
  25407. sizeY?: number;
  25408. sizeZ?: number;
  25409. custom?: any;
  25410. faceUV?: Vector4[];
  25411. faceColors?: Color4[];
  25412. updatable?: boolean;
  25413. sideOrientation?: number;
  25414. }, scene: Scene): Mesh;
  25415. /**
  25416. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25417. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25418. * * 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`)
  25419. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25420. * * 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
  25421. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25422. * * If you create a double-sided mesh, you can choose what parts of 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
  25423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25424. * @param name defines the name of the mesh
  25425. * @param options defines the options used to create the mesh
  25426. * @param scene defines the hosting scene
  25427. * @returns a new Mesh
  25428. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25429. */
  25430. static CreateIcoSphere(name: string, options: {
  25431. radius?: number;
  25432. flat?: boolean;
  25433. subdivisions?: number;
  25434. sideOrientation?: number;
  25435. updatable?: boolean;
  25436. }, scene: Scene): Mesh;
  25437. /**
  25438. * Creates a decal mesh.
  25439. * Please consider using the same method from the MeshBuilder class instead.
  25440. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25441. * @param name defines the name of the mesh
  25442. * @param sourceMesh defines the mesh receiving the decal
  25443. * @param position sets the position of the decal in world coordinates
  25444. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25445. * @param size sets the decal scaling
  25446. * @param angle sets the angle to rotate the decal
  25447. * @returns a new Mesh
  25448. */
  25449. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25450. /**
  25451. * Prepare internal position array for software CPU skinning
  25452. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25453. */
  25454. setPositionsForCPUSkinning(): Float32Array;
  25455. /**
  25456. * Prepare internal normal array for software CPU skinning
  25457. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25458. */
  25459. setNormalsForCPUSkinning(): Float32Array;
  25460. /**
  25461. * Updates the vertex buffer by applying transformation from the bones
  25462. * @param skeleton defines the skeleton to apply to current mesh
  25463. * @returns the current mesh
  25464. */
  25465. applySkeleton(skeleton: Skeleton): Mesh;
  25466. /**
  25467. * 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
  25468. * @param meshes defines the list of meshes to scan
  25469. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25470. */
  25471. static MinMax(meshes: AbstractMesh[]): {
  25472. min: Vector3;
  25473. max: Vector3;
  25474. };
  25475. /**
  25476. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25477. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25478. * @returns a vector3
  25479. */
  25480. static Center(meshesOrMinMaxVector: {
  25481. min: Vector3;
  25482. max: Vector3;
  25483. } | AbstractMesh[]): Vector3;
  25484. /**
  25485. * Merge the array of meshes into a single mesh for performance reasons.
  25486. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25487. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25488. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25489. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25490. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25491. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25492. * @returns a new mesh
  25493. */
  25494. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25495. /** @hidden */
  25496. addInstance(instance: InstancedMesh): void;
  25497. /** @hidden */
  25498. removeInstance(instance: InstancedMesh): void;
  25499. }
  25500. }
  25501. declare module "babylonjs/Cameras/camera" {
  25502. import { SmartArray } from "babylonjs/Misc/smartArray";
  25503. import { Observable } from "babylonjs/Misc/observable";
  25504. import { Nullable } from "babylonjs/types";
  25505. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25506. import { Scene } from "babylonjs/scene";
  25507. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25508. import { Node } from "babylonjs/node";
  25509. import { Mesh } from "babylonjs/Meshes/mesh";
  25510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25511. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25512. import { Viewport } from "babylonjs/Maths/math.viewport";
  25513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25516. import { Ray } from "babylonjs/Culling/ray";
  25517. /**
  25518. * This is the base class of all the camera used in the application.
  25519. * @see http://doc.babylonjs.com/features/cameras
  25520. */
  25521. export class Camera extends Node {
  25522. /** @hidden */
  25523. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25524. /**
  25525. * This is the default projection mode used by the cameras.
  25526. * It helps recreating a feeling of perspective and better appreciate depth.
  25527. * This is the best way to simulate real life cameras.
  25528. */
  25529. static readonly PERSPECTIVE_CAMERA: number;
  25530. /**
  25531. * This helps creating camera with an orthographic mode.
  25532. * 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.
  25533. */
  25534. static readonly ORTHOGRAPHIC_CAMERA: number;
  25535. /**
  25536. * This is the default FOV mode for perspective cameras.
  25537. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25538. */
  25539. static readonly FOVMODE_VERTICAL_FIXED: number;
  25540. /**
  25541. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25542. */
  25543. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25544. /**
  25545. * This specifies ther is no need for a camera rig.
  25546. * Basically only one eye is rendered corresponding to the camera.
  25547. */
  25548. static readonly RIG_MODE_NONE: number;
  25549. /**
  25550. * Simulates a camera Rig with one blue eye and one red eye.
  25551. * This can be use with 3d blue and red glasses.
  25552. */
  25553. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25554. /**
  25555. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25556. */
  25557. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25558. /**
  25559. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25560. */
  25561. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25562. /**
  25563. * Defines that both eyes of the camera will be rendered over under each other.
  25564. */
  25565. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25566. /**
  25567. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25568. */
  25569. static readonly RIG_MODE_VR: number;
  25570. /**
  25571. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25572. */
  25573. static readonly RIG_MODE_WEBVR: number;
  25574. /**
  25575. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25576. */
  25577. static readonly RIG_MODE_CUSTOM: number;
  25578. /**
  25579. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25580. */
  25581. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25582. /**
  25583. * Define the input manager associated with the camera.
  25584. */
  25585. inputs: CameraInputsManager<Camera>;
  25586. /** @hidden */
  25587. _position: Vector3;
  25588. /**
  25589. * Define the current local position of the camera in the scene
  25590. */
  25591. position: Vector3;
  25592. /**
  25593. * The vector the camera should consider as up.
  25594. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25595. */
  25596. upVector: Vector3;
  25597. /**
  25598. * Define the current limit on the left side for an orthographic camera
  25599. * In scene unit
  25600. */
  25601. orthoLeft: Nullable<number>;
  25602. /**
  25603. * Define the current limit on the right side for an orthographic camera
  25604. * In scene unit
  25605. */
  25606. orthoRight: Nullable<number>;
  25607. /**
  25608. * Define the current limit on the bottom side for an orthographic camera
  25609. * In scene unit
  25610. */
  25611. orthoBottom: Nullable<number>;
  25612. /**
  25613. * Define the current limit on the top side for an orthographic camera
  25614. * In scene unit
  25615. */
  25616. orthoTop: Nullable<number>;
  25617. /**
  25618. * Field Of View is set in Radians. (default is 0.8)
  25619. */
  25620. fov: number;
  25621. /**
  25622. * Define the minimum distance the camera can see from.
  25623. * This is important to note that the depth buffer are not infinite and the closer it starts
  25624. * the more your scene might encounter depth fighting issue.
  25625. */
  25626. minZ: number;
  25627. /**
  25628. * Define the maximum distance the camera can see to.
  25629. * This is important to note that the depth buffer are not infinite and the further it end
  25630. * the more your scene might encounter depth fighting issue.
  25631. */
  25632. maxZ: number;
  25633. /**
  25634. * Define the default inertia of the camera.
  25635. * This helps giving a smooth feeling to the camera movement.
  25636. */
  25637. inertia: number;
  25638. /**
  25639. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25640. */
  25641. mode: number;
  25642. /**
  25643. * Define wether the camera is intermediate.
  25644. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25645. */
  25646. isIntermediate: boolean;
  25647. /**
  25648. * Define the viewport of the camera.
  25649. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25650. */
  25651. viewport: Viewport;
  25652. /**
  25653. * Restricts the camera to viewing objects with the same layerMask.
  25654. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25655. */
  25656. layerMask: number;
  25657. /**
  25658. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25659. */
  25660. fovMode: number;
  25661. /**
  25662. * Rig mode of the camera.
  25663. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25664. * This is normally controlled byt the camera themselves as internal use.
  25665. */
  25666. cameraRigMode: number;
  25667. /**
  25668. * Defines the distance between both "eyes" in case of a RIG
  25669. */
  25670. interaxialDistance: number;
  25671. /**
  25672. * Defines if stereoscopic rendering is done side by side or over under.
  25673. */
  25674. isStereoscopicSideBySide: boolean;
  25675. /**
  25676. * 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
  25677. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25678. * else in the scene. (Eg. security camera)
  25679. *
  25680. * 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)
  25681. */
  25682. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25683. /**
  25684. * When set, the camera will render to this render target instead of the default canvas
  25685. *
  25686. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25687. */
  25688. outputRenderTarget: Nullable<RenderTargetTexture>;
  25689. /**
  25690. * Observable triggered when the camera view matrix has changed.
  25691. */
  25692. onViewMatrixChangedObservable: Observable<Camera>;
  25693. /**
  25694. * Observable triggered when the camera Projection matrix has changed.
  25695. */
  25696. onProjectionMatrixChangedObservable: Observable<Camera>;
  25697. /**
  25698. * Observable triggered when the inputs have been processed.
  25699. */
  25700. onAfterCheckInputsObservable: Observable<Camera>;
  25701. /**
  25702. * Observable triggered when reset has been called and applied to the camera.
  25703. */
  25704. onRestoreStateObservable: Observable<Camera>;
  25705. /** @hidden */
  25706. _cameraRigParams: any;
  25707. /** @hidden */
  25708. _rigCameras: Camera[];
  25709. /** @hidden */
  25710. _rigPostProcess: Nullable<PostProcess>;
  25711. protected _webvrViewMatrix: Matrix;
  25712. /** @hidden */
  25713. _skipRendering: boolean;
  25714. /** @hidden */
  25715. _projectionMatrix: Matrix;
  25716. /** @hidden */
  25717. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25718. /** @hidden */
  25719. _activeMeshes: SmartArray<AbstractMesh>;
  25720. protected _globalPosition: Vector3;
  25721. /** @hidden */
  25722. _computedViewMatrix: Matrix;
  25723. private _doNotComputeProjectionMatrix;
  25724. private _transformMatrix;
  25725. private _frustumPlanes;
  25726. private _refreshFrustumPlanes;
  25727. private _storedFov;
  25728. private _stateStored;
  25729. /**
  25730. * Instantiates a new camera object.
  25731. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25732. * @see http://doc.babylonjs.com/features/cameras
  25733. * @param name Defines the name of the camera in the scene
  25734. * @param position Defines the position of the camera
  25735. * @param scene Defines the scene the camera belongs too
  25736. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25737. */
  25738. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25739. /**
  25740. * Store current camera state (fov, position, etc..)
  25741. * @returns the camera
  25742. */
  25743. storeState(): Camera;
  25744. /**
  25745. * Restores the camera state values if it has been stored. You must call storeState() first
  25746. */
  25747. protected _restoreStateValues(): boolean;
  25748. /**
  25749. * Restored camera state. You must call storeState() first.
  25750. * @returns true if restored and false otherwise
  25751. */
  25752. restoreState(): boolean;
  25753. /**
  25754. * Gets the class name of the camera.
  25755. * @returns the class name
  25756. */
  25757. getClassName(): string;
  25758. /** @hidden */
  25759. readonly _isCamera: boolean;
  25760. /**
  25761. * Gets a string representation of the camera useful for debug purpose.
  25762. * @param fullDetails Defines that a more verboe level of logging is required
  25763. * @returns the string representation
  25764. */
  25765. toString(fullDetails?: boolean): string;
  25766. /**
  25767. * Gets the current world space position of the camera.
  25768. */
  25769. readonly globalPosition: Vector3;
  25770. /**
  25771. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25772. * @returns the active meshe list
  25773. */
  25774. getActiveMeshes(): SmartArray<AbstractMesh>;
  25775. /**
  25776. * Check wether a mesh is part of the current active mesh list of the camera
  25777. * @param mesh Defines the mesh to check
  25778. * @returns true if active, false otherwise
  25779. */
  25780. isActiveMesh(mesh: Mesh): boolean;
  25781. /**
  25782. * Is this camera ready to be used/rendered
  25783. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25784. * @return true if the camera is ready
  25785. */
  25786. isReady(completeCheck?: boolean): boolean;
  25787. /** @hidden */
  25788. _initCache(): void;
  25789. /** @hidden */
  25790. _updateCache(ignoreParentClass?: boolean): void;
  25791. /** @hidden */
  25792. _isSynchronized(): boolean;
  25793. /** @hidden */
  25794. _isSynchronizedViewMatrix(): boolean;
  25795. /** @hidden */
  25796. _isSynchronizedProjectionMatrix(): boolean;
  25797. /**
  25798. * Attach the input controls to a specific dom element to get the input from.
  25799. * @param element Defines the element the controls should be listened from
  25800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25801. */
  25802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25803. /**
  25804. * Detach the current controls from the specified dom element.
  25805. * @param element Defines the element to stop listening the inputs from
  25806. */
  25807. detachControl(element: HTMLElement): void;
  25808. /**
  25809. * Update the camera state according to the different inputs gathered during the frame.
  25810. */
  25811. update(): void;
  25812. /** @hidden */
  25813. _checkInputs(): void;
  25814. /** @hidden */
  25815. readonly rigCameras: Camera[];
  25816. /**
  25817. * Gets the post process used by the rig cameras
  25818. */
  25819. readonly rigPostProcess: Nullable<PostProcess>;
  25820. /**
  25821. * Internal, gets the first post proces.
  25822. * @returns the first post process to be run on this camera.
  25823. */
  25824. _getFirstPostProcess(): Nullable<PostProcess>;
  25825. private _cascadePostProcessesToRigCams;
  25826. /**
  25827. * Attach a post process to the camera.
  25828. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25829. * @param postProcess The post process to attach to the camera
  25830. * @param insertAt The position of the post process in case several of them are in use in the scene
  25831. * @returns the position the post process has been inserted at
  25832. */
  25833. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25834. /**
  25835. * Detach a post process to the camera.
  25836. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25837. * @param postProcess The post process to detach from the camera
  25838. */
  25839. detachPostProcess(postProcess: PostProcess): void;
  25840. /**
  25841. * Gets the current world matrix of the camera
  25842. */
  25843. getWorldMatrix(): Matrix;
  25844. /** @hidden */
  25845. _getViewMatrix(): Matrix;
  25846. /**
  25847. * Gets the current view matrix of the camera.
  25848. * @param force forces the camera to recompute the matrix without looking at the cached state
  25849. * @returns the view matrix
  25850. */
  25851. getViewMatrix(force?: boolean): Matrix;
  25852. /**
  25853. * Freeze the projection matrix.
  25854. * It will prevent the cache check of the camera projection compute and can speed up perf
  25855. * if no parameter of the camera are meant to change
  25856. * @param projection Defines manually a projection if necessary
  25857. */
  25858. freezeProjectionMatrix(projection?: Matrix): void;
  25859. /**
  25860. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25861. */
  25862. unfreezeProjectionMatrix(): void;
  25863. /**
  25864. * Gets the current projection matrix of the camera.
  25865. * @param force forces the camera to recompute the matrix without looking at the cached state
  25866. * @returns the projection matrix
  25867. */
  25868. getProjectionMatrix(force?: boolean): Matrix;
  25869. /**
  25870. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25871. * @returns a Matrix
  25872. */
  25873. getTransformationMatrix(): Matrix;
  25874. private _updateFrustumPlanes;
  25875. /**
  25876. * Checks if a cullable object (mesh...) is in the camera frustum
  25877. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25878. * @param target The object to check
  25879. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25880. * @returns true if the object is in frustum otherwise false
  25881. */
  25882. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25883. /**
  25884. * Checks if a cullable object (mesh...) is in the camera frustum
  25885. * Unlike isInFrustum this cheks the full bounding box
  25886. * @param target The object to check
  25887. * @returns true if the object is in frustum otherwise false
  25888. */
  25889. isCompletelyInFrustum(target: ICullable): boolean;
  25890. /**
  25891. * Gets a ray in the forward direction from the camera.
  25892. * @param length Defines the length of the ray to create
  25893. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25894. * @param origin Defines the start point of the ray which defaults to the camera position
  25895. * @returns the forward ray
  25896. */
  25897. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25898. /**
  25899. * Releases resources associated with this node.
  25900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25902. */
  25903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25904. /** @hidden */
  25905. _isLeftCamera: boolean;
  25906. /**
  25907. * Gets the left camera of a rig setup in case of Rigged Camera
  25908. */
  25909. readonly isLeftCamera: boolean;
  25910. /** @hidden */
  25911. _isRightCamera: boolean;
  25912. /**
  25913. * Gets the right camera of a rig setup in case of Rigged Camera
  25914. */
  25915. readonly isRightCamera: boolean;
  25916. /**
  25917. * Gets the left camera of a rig setup in case of Rigged Camera
  25918. */
  25919. readonly leftCamera: Nullable<FreeCamera>;
  25920. /**
  25921. * Gets the right camera of a rig setup in case of Rigged Camera
  25922. */
  25923. readonly rightCamera: Nullable<FreeCamera>;
  25924. /**
  25925. * Gets the left camera target of a rig setup in case of Rigged Camera
  25926. * @returns the target position
  25927. */
  25928. getLeftTarget(): Nullable<Vector3>;
  25929. /**
  25930. * Gets the right camera target of a rig setup in case of Rigged Camera
  25931. * @returns the target position
  25932. */
  25933. getRightTarget(): Nullable<Vector3>;
  25934. /**
  25935. * @hidden
  25936. */
  25937. setCameraRigMode(mode: number, rigParams: any): void;
  25938. /** @hidden */
  25939. static _setStereoscopicRigMode(camera: Camera): void;
  25940. /** @hidden */
  25941. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25942. /** @hidden */
  25943. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25944. /** @hidden */
  25945. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25946. /** @hidden */
  25947. _getVRProjectionMatrix(): Matrix;
  25948. protected _updateCameraRotationMatrix(): void;
  25949. protected _updateWebVRCameraRotationMatrix(): void;
  25950. /**
  25951. * This function MUST be overwritten by the different WebVR cameras available.
  25952. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25953. * @hidden
  25954. */
  25955. _getWebVRProjectionMatrix(): Matrix;
  25956. /**
  25957. * This function MUST be overwritten by the different WebVR cameras available.
  25958. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25959. * @hidden
  25960. */
  25961. _getWebVRViewMatrix(): Matrix;
  25962. /** @hidden */
  25963. setCameraRigParameter(name: string, value: any): void;
  25964. /**
  25965. * needs to be overridden by children so sub has required properties to be copied
  25966. * @hidden
  25967. */
  25968. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25969. /**
  25970. * May need to be overridden by children
  25971. * @hidden
  25972. */
  25973. _updateRigCameras(): void;
  25974. /** @hidden */
  25975. _setupInputs(): void;
  25976. /**
  25977. * Serialiaze the camera setup to a json represention
  25978. * @returns the JSON representation
  25979. */
  25980. serialize(): any;
  25981. /**
  25982. * Clones the current camera.
  25983. * @param name The cloned camera name
  25984. * @returns the cloned camera
  25985. */
  25986. clone(name: string): Camera;
  25987. /**
  25988. * Gets the direction of the camera relative to a given local axis.
  25989. * @param localAxis Defines the reference axis to provide a relative direction.
  25990. * @return the direction
  25991. */
  25992. getDirection(localAxis: Vector3): Vector3;
  25993. /**
  25994. * Returns the current camera absolute rotation
  25995. */
  25996. readonly absoluteRotation: Quaternion;
  25997. /**
  25998. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25999. * @param localAxis Defines the reference axis to provide a relative direction.
  26000. * @param result Defines the vector to store the result in
  26001. */
  26002. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26003. /**
  26004. * Gets a camera constructor for a given camera type
  26005. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26006. * @param name The name of the camera the result will be able to instantiate
  26007. * @param scene The scene the result will construct the camera in
  26008. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26009. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26010. * @returns a factory method to construc the camera
  26011. */
  26012. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26013. /**
  26014. * Compute the world matrix of the camera.
  26015. * @returns the camera world matrix
  26016. */
  26017. computeWorldMatrix(): Matrix;
  26018. /**
  26019. * Parse a JSON and creates the camera from the parsed information
  26020. * @param parsedCamera The JSON to parse
  26021. * @param scene The scene to instantiate the camera in
  26022. * @returns the newly constructed camera
  26023. */
  26024. static Parse(parsedCamera: any, scene: Scene): Camera;
  26025. }
  26026. }
  26027. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26028. import { Nullable } from "babylonjs/types";
  26029. import { Scene } from "babylonjs/scene";
  26030. import { Vector4 } from "babylonjs/Maths/math.vector";
  26031. import { Mesh } from "babylonjs/Meshes/mesh";
  26032. /**
  26033. * Class containing static functions to help procedurally build meshes
  26034. */
  26035. export class DiscBuilder {
  26036. /**
  26037. * Creates a plane polygonal mesh. By default, this is a disc
  26038. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26039. * * 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
  26040. * * 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
  26041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26044. * @param name defines the name of the mesh
  26045. * @param options defines the options used to create the mesh
  26046. * @param scene defines the hosting scene
  26047. * @returns the plane polygonal mesh
  26048. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26049. */
  26050. static CreateDisc(name: string, options: {
  26051. radius?: number;
  26052. tessellation?: number;
  26053. arc?: number;
  26054. updatable?: boolean;
  26055. sideOrientation?: number;
  26056. frontUVs?: Vector4;
  26057. backUVs?: Vector4;
  26058. }, scene?: Nullable<Scene>): Mesh;
  26059. }
  26060. }
  26061. declare module "babylonjs/Particles/solidParticleSystem" {
  26062. import { Vector3 } from "babylonjs/Maths/math.vector";
  26063. import { Mesh } from "babylonjs/Meshes/mesh";
  26064. import { Scene, IDisposable } from "babylonjs/scene";
  26065. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26066. /**
  26067. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26068. *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.
  26069. * The SPS is also a particle system. It provides some methods to manage the particles.
  26070. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26071. *
  26072. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26073. */
  26074. export class SolidParticleSystem implements IDisposable {
  26075. /**
  26076. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26077. * Example : var p = SPS.particles[i];
  26078. */
  26079. particles: SolidParticle[];
  26080. /**
  26081. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26082. */
  26083. nbParticles: number;
  26084. /**
  26085. * If the particles must ever face the camera (default false). Useful for planar particles.
  26086. */
  26087. billboard: boolean;
  26088. /**
  26089. * Recompute normals when adding a shape
  26090. */
  26091. recomputeNormals: boolean;
  26092. /**
  26093. * This a counter ofr your own usage. It's not set by any SPS functions.
  26094. */
  26095. counter: number;
  26096. /**
  26097. * The SPS name. This name is also given to the underlying mesh.
  26098. */
  26099. name: string;
  26100. /**
  26101. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26102. */
  26103. mesh: Mesh;
  26104. /**
  26105. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26106. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26107. */
  26108. vars: any;
  26109. /**
  26110. * This array is populated when the SPS is set as 'pickable'.
  26111. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26112. * Each element of this array is an object `{idx: int, faceId: int}`.
  26113. * `idx` is the picked particle index in the `SPS.particles` array
  26114. * `faceId` is the picked face index counted within this particle.
  26115. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26116. */
  26117. pickedParticles: {
  26118. idx: number;
  26119. faceId: number;
  26120. }[];
  26121. /**
  26122. * This array is populated when `enableDepthSort` is set to true.
  26123. * Each element of this array is an instance of the class DepthSortedParticle.
  26124. */
  26125. depthSortedParticles: DepthSortedParticle[];
  26126. /**
  26127. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26128. * @hidden
  26129. */
  26130. _bSphereOnly: boolean;
  26131. /**
  26132. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26133. * @hidden
  26134. */
  26135. _bSphereRadiusFactor: number;
  26136. private _scene;
  26137. private _positions;
  26138. private _indices;
  26139. private _normals;
  26140. private _colors;
  26141. private _uvs;
  26142. private _indices32;
  26143. private _positions32;
  26144. private _normals32;
  26145. private _fixedNormal32;
  26146. private _colors32;
  26147. private _uvs32;
  26148. private _index;
  26149. private _updatable;
  26150. private _pickable;
  26151. private _isVisibilityBoxLocked;
  26152. private _alwaysVisible;
  26153. private _depthSort;
  26154. private _expandable;
  26155. private _shapeCounter;
  26156. private _copy;
  26157. private _color;
  26158. private _computeParticleColor;
  26159. private _computeParticleTexture;
  26160. private _computeParticleRotation;
  26161. private _computeParticleVertex;
  26162. private _computeBoundingBox;
  26163. private _depthSortParticles;
  26164. private _camera;
  26165. private _mustUnrotateFixedNormals;
  26166. private _particlesIntersect;
  26167. private _needs32Bits;
  26168. private _isNotBuilt;
  26169. /**
  26170. * Creates a SPS (Solid Particle System) object.
  26171. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26172. * @param scene (Scene) is the scene in which the SPS is added.
  26173. * @param options defines the options of the sps e.g.
  26174. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26175. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26176. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26177. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26178. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26179. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26180. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26181. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26182. */
  26183. constructor(name: string, scene: Scene, options?: {
  26184. updatable?: boolean;
  26185. isPickable?: boolean;
  26186. enableDepthSort?: boolean;
  26187. particleIntersection?: boolean;
  26188. boundingSphereOnly?: boolean;
  26189. bSphereRadiusFactor?: number;
  26190. expandable?: boolean;
  26191. });
  26192. /**
  26193. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26194. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26195. * @returns the created mesh
  26196. */
  26197. buildMesh(): Mesh;
  26198. /**
  26199. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26200. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26201. * Thus the particles generated from `digest()` have their property `position` set yet.
  26202. * @param mesh ( Mesh ) is the mesh to be digested
  26203. * @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
  26204. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26205. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26206. * @returns the current SPS
  26207. */
  26208. digest(mesh: Mesh, options?: {
  26209. facetNb?: number;
  26210. number?: number;
  26211. delta?: number;
  26212. }): SolidParticleSystem;
  26213. private _unrotateFixedNormals;
  26214. private _resetCopy;
  26215. private _meshBuilder;
  26216. private _posToShape;
  26217. private _uvsToShapeUV;
  26218. private _addParticle;
  26219. /**
  26220. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26221. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26222. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26223. * @param nb (positive integer) the number of particles to be created from this model
  26224. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26225. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26226. * @returns the number of shapes in the system
  26227. */
  26228. addShape(mesh: Mesh, nb: number, options?: {
  26229. positionFunction?: any;
  26230. vertexFunction?: any;
  26231. }): number;
  26232. private _rebuildParticle;
  26233. /**
  26234. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26235. * @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.
  26236. * @returns the SPS.
  26237. */
  26238. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26239. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26240. * Returns an array with the removed particles.
  26241. * 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.
  26242. * The SPS can't be empty so at least one particle needs to remain in place.
  26243. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26244. * @param start index of the first particle to remove
  26245. * @param end index of the last particle to remove (included)
  26246. * @returns an array populated with the removed particles
  26247. */
  26248. removeParticles(start: number, end: number): SolidParticle[];
  26249. /**
  26250. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26251. * This method calls `updateParticle()` for each particle of the SPS.
  26252. * For an animated SPS, it is usually called within the render loop.
  26253. * 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.
  26254. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26255. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26256. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26257. * @returns the SPS.
  26258. */
  26259. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26260. /**
  26261. * Disposes the SPS.
  26262. */
  26263. dispose(): void;
  26264. /**
  26265. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26266. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26267. * @returns the SPS.
  26268. */
  26269. refreshVisibleSize(): SolidParticleSystem;
  26270. /**
  26271. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26272. * @param size the size (float) of the visibility box
  26273. * note : this doesn't lock the SPS mesh bounding box.
  26274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26275. */
  26276. setVisibilityBox(size: number): void;
  26277. /**
  26278. * Gets whether the SPS as always visible or not
  26279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26280. */
  26281. /**
  26282. * Sets the SPS as always visible or not
  26283. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26284. */
  26285. isAlwaysVisible: boolean;
  26286. /**
  26287. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26289. */
  26290. /**
  26291. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26292. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26293. */
  26294. isVisibilityBoxLocked: boolean;
  26295. /**
  26296. * Tells to `setParticles()` to compute the particle rotations or not.
  26297. * Default value : true. The SPS is faster when it's set to false.
  26298. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26299. */
  26300. /**
  26301. * Gets if `setParticles()` computes the particle rotations or not.
  26302. * Default value : true. The SPS is faster when it's set to false.
  26303. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26304. */
  26305. computeParticleRotation: boolean;
  26306. /**
  26307. * Tells to `setParticles()` to compute the particle colors or not.
  26308. * Default value : true. The SPS is faster when it's set to false.
  26309. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26310. */
  26311. /**
  26312. * Gets if `setParticles()` computes the particle colors or not.
  26313. * Default value : true. The SPS is faster when it's set to false.
  26314. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26315. */
  26316. computeParticleColor: boolean;
  26317. /**
  26318. * Gets if `setParticles()` computes the particle textures or not.
  26319. * Default value : true. The SPS is faster when it's set to false.
  26320. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26321. */
  26322. computeParticleTexture: boolean;
  26323. /**
  26324. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26325. * Default value : false. The SPS is faster when it's set to false.
  26326. * Note : the particle custom vertex positions aren't stored values.
  26327. */
  26328. /**
  26329. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26330. * Default value : false. The SPS is faster when it's set to false.
  26331. * Note : the particle custom vertex positions aren't stored values.
  26332. */
  26333. computeParticleVertex: boolean;
  26334. /**
  26335. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26336. */
  26337. /**
  26338. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26339. */
  26340. computeBoundingBox: boolean;
  26341. /**
  26342. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26343. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26344. * Default : `true`
  26345. */
  26346. /**
  26347. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26348. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26349. * Default : `true`
  26350. */
  26351. depthSortParticles: boolean;
  26352. /**
  26353. * Gets if the SPS is created as expandable at construction time.
  26354. * Default : `false`
  26355. */
  26356. readonly expandable: boolean;
  26357. /**
  26358. * This function does nothing. It may be overwritten to set all the particle first values.
  26359. * The SPS doesn't call this function, you may have to call it by your own.
  26360. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26361. */
  26362. initParticles(): void;
  26363. /**
  26364. * This function does nothing. It may be overwritten to recycle a particle.
  26365. * The SPS doesn't call this function, you may have to call it by your own.
  26366. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26367. * @param particle The particle to recycle
  26368. * @returns the recycled particle
  26369. */
  26370. recycleParticle(particle: SolidParticle): SolidParticle;
  26371. /**
  26372. * Updates a particle : this function should be overwritten by the user.
  26373. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26375. * @example : just set a particle position or velocity and recycle conditions
  26376. * @param particle The particle to update
  26377. * @returns the updated particle
  26378. */
  26379. updateParticle(particle: SolidParticle): SolidParticle;
  26380. /**
  26381. * Updates a vertex of a particle : it can be overwritten by the user.
  26382. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26383. * @param particle the current particle
  26384. * @param vertex the current index of the current particle
  26385. * @param pt the index of the current vertex in the particle shape
  26386. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26387. * @example : just set a vertex particle position
  26388. * @returns the updated vertex
  26389. */
  26390. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26391. /**
  26392. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26393. * This does nothing and may be overwritten by the user.
  26394. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26395. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26396. * @param update the boolean update value actually passed to setParticles()
  26397. */
  26398. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26399. /**
  26400. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26401. * This will be passed three parameters.
  26402. * This does nothing and may be overwritten by the user.
  26403. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26404. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26405. * @param update the boolean update value actually passed to setParticles()
  26406. */
  26407. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26408. }
  26409. }
  26410. declare module "babylonjs/Particles/solidParticle" {
  26411. import { Nullable } from "babylonjs/types";
  26412. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26413. import { Color4 } from "babylonjs/Maths/math.color";
  26414. import { Mesh } from "babylonjs/Meshes/mesh";
  26415. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26416. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26417. import { Plane } from "babylonjs/Maths/math.plane";
  26418. /**
  26419. * Represents one particle of a solid particle system.
  26420. */
  26421. export class SolidParticle {
  26422. /**
  26423. * particle global index
  26424. */
  26425. idx: number;
  26426. /**
  26427. * The color of the particle
  26428. */
  26429. color: Nullable<Color4>;
  26430. /**
  26431. * The world space position of the particle.
  26432. */
  26433. position: Vector3;
  26434. /**
  26435. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26436. */
  26437. rotation: Vector3;
  26438. /**
  26439. * The world space rotation quaternion of the particle.
  26440. */
  26441. rotationQuaternion: Nullable<Quaternion>;
  26442. /**
  26443. * The scaling of the particle.
  26444. */
  26445. scaling: Vector3;
  26446. /**
  26447. * The uvs of the particle.
  26448. */
  26449. uvs: Vector4;
  26450. /**
  26451. * The current speed of the particle.
  26452. */
  26453. velocity: Vector3;
  26454. /**
  26455. * The pivot point in the particle local space.
  26456. */
  26457. pivot: Vector3;
  26458. /**
  26459. * Must the particle be translated from its pivot point in its local space ?
  26460. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26461. * Default : false
  26462. */
  26463. translateFromPivot: boolean;
  26464. /**
  26465. * Is the particle active or not ?
  26466. */
  26467. alive: boolean;
  26468. /**
  26469. * Is the particle visible or not ?
  26470. */
  26471. isVisible: boolean;
  26472. /**
  26473. * Index of this particle in the global "positions" array (Internal use)
  26474. * @hidden
  26475. */
  26476. _pos: number;
  26477. /**
  26478. * @hidden Index of this particle in the global "indices" array (Internal use)
  26479. */
  26480. _ind: number;
  26481. /**
  26482. * @hidden ModelShape of this particle (Internal use)
  26483. */
  26484. _model: ModelShape;
  26485. /**
  26486. * ModelShape id of this particle
  26487. */
  26488. shapeId: number;
  26489. /**
  26490. * Index of the particle in its shape id
  26491. */
  26492. idxInShape: number;
  26493. /**
  26494. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26495. */
  26496. _modelBoundingInfo: BoundingInfo;
  26497. /**
  26498. * @hidden Particle BoundingInfo object (Internal use)
  26499. */
  26500. _boundingInfo: BoundingInfo;
  26501. /**
  26502. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26503. */
  26504. _sps: SolidParticleSystem;
  26505. /**
  26506. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26507. */
  26508. _stillInvisible: boolean;
  26509. /**
  26510. * @hidden Last computed particle rotation matrix
  26511. */
  26512. _rotationMatrix: number[];
  26513. /**
  26514. * Parent particle Id, if any.
  26515. * Default null.
  26516. */
  26517. parentId: Nullable<number>;
  26518. /**
  26519. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26520. * The possible values are :
  26521. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26522. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26523. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26524. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26525. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26526. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26527. * */
  26528. cullingStrategy: number;
  26529. /**
  26530. * @hidden Internal global position in the SPS.
  26531. */
  26532. _globalPosition: Vector3;
  26533. /**
  26534. * Creates a Solid Particle object.
  26535. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26536. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26537. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26538. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26539. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26540. * @param shapeId (integer) is the model shape identifier in the SPS.
  26541. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26542. * @param sps defines the sps it is associated to
  26543. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26544. */
  26545. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26546. /**
  26547. * Legacy support, changed scale to scaling
  26548. */
  26549. /**
  26550. * Legacy support, changed scale to scaling
  26551. */
  26552. scale: Vector3;
  26553. /**
  26554. * Legacy support, changed quaternion to rotationQuaternion
  26555. */
  26556. /**
  26557. * Legacy support, changed quaternion to rotationQuaternion
  26558. */
  26559. quaternion: Nullable<Quaternion>;
  26560. /**
  26561. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26562. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26563. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26564. * @returns true if it intersects
  26565. */
  26566. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26567. /**
  26568. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26569. * A particle is in the frustum if its bounding box intersects the frustum
  26570. * @param frustumPlanes defines the frustum to test
  26571. * @returns true if the particle is in the frustum planes
  26572. */
  26573. isInFrustum(frustumPlanes: Plane[]): boolean;
  26574. /**
  26575. * get the rotation matrix of the particle
  26576. * @hidden
  26577. */
  26578. getRotationMatrix(m: Matrix): void;
  26579. }
  26580. /**
  26581. * Represents the shape of the model used by one particle of a solid particle system.
  26582. * SPS internal tool, don't use it manually.
  26583. */
  26584. export class ModelShape {
  26585. /**
  26586. * The shape id
  26587. * @hidden
  26588. */
  26589. shapeID: number;
  26590. /**
  26591. * flat array of model positions (internal use)
  26592. * @hidden
  26593. */
  26594. _shape: Vector3[];
  26595. /**
  26596. * flat array of model UVs (internal use)
  26597. * @hidden
  26598. */
  26599. _shapeUV: number[];
  26600. /**
  26601. * color array of the model
  26602. * @hidden
  26603. */
  26604. _shapeColors: number[];
  26605. /**
  26606. * indices array of the model
  26607. * @hidden
  26608. */
  26609. _indices: number[];
  26610. /**
  26611. * normals array of the model
  26612. * @hidden
  26613. */
  26614. _normals: number[];
  26615. /**
  26616. * length of the shape in the model indices array (internal use)
  26617. * @hidden
  26618. */
  26619. _indicesLength: number;
  26620. /**
  26621. * Custom position function (internal use)
  26622. * @hidden
  26623. */
  26624. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26625. /**
  26626. * Custom vertex function (internal use)
  26627. * @hidden
  26628. */
  26629. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26630. /**
  26631. * 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.
  26632. * SPS internal tool, don't use it manually.
  26633. * @hidden
  26634. */
  26635. 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>);
  26636. }
  26637. /**
  26638. * Represents a Depth Sorted Particle in the solid particle system.
  26639. */
  26640. export class DepthSortedParticle {
  26641. /**
  26642. * Index of the particle in the "indices" array
  26643. */
  26644. ind: number;
  26645. /**
  26646. * Length of the particle shape in the "indices" array
  26647. */
  26648. indicesLength: number;
  26649. /**
  26650. * Squared distance from the particle to the camera
  26651. */
  26652. sqDistance: number;
  26653. }
  26654. }
  26655. declare module "babylonjs/Collisions/meshCollisionData" {
  26656. import { Collider } from "babylonjs/Collisions/collider";
  26657. import { Vector3 } from "babylonjs/Maths/math.vector";
  26658. import { Nullable } from "babylonjs/types";
  26659. import { Observer } from "babylonjs/Misc/observable";
  26660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26661. /**
  26662. * @hidden
  26663. */
  26664. export class _MeshCollisionData {
  26665. _checkCollisions: boolean;
  26666. _collisionMask: number;
  26667. _collisionGroup: number;
  26668. _collider: Nullable<Collider>;
  26669. _oldPositionForCollisions: Vector3;
  26670. _diffPositionForCollisions: Vector3;
  26671. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26672. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26673. }
  26674. }
  26675. declare module "babylonjs/Meshes/abstractMesh" {
  26676. import { Observable } from "babylonjs/Misc/observable";
  26677. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26678. import { Camera } from "babylonjs/Cameras/camera";
  26679. import { Scene, IDisposable } from "babylonjs/scene";
  26680. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26681. import { Node } from "babylonjs/node";
  26682. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26683. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26685. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26686. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26687. import { Material } from "babylonjs/Materials/material";
  26688. import { Light } from "babylonjs/Lights/light";
  26689. import { Skeleton } from "babylonjs/Bones/skeleton";
  26690. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26691. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26692. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26693. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26694. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26695. import { Plane } from "babylonjs/Maths/math.plane";
  26696. import { Ray } from "babylonjs/Culling/ray";
  26697. import { Collider } from "babylonjs/Collisions/collider";
  26698. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26699. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26700. /** @hidden */
  26701. class _FacetDataStorage {
  26702. facetPositions: Vector3[];
  26703. facetNormals: Vector3[];
  26704. facetPartitioning: number[][];
  26705. facetNb: number;
  26706. partitioningSubdivisions: number;
  26707. partitioningBBoxRatio: number;
  26708. facetDataEnabled: boolean;
  26709. facetParameters: any;
  26710. bbSize: Vector3;
  26711. subDiv: {
  26712. max: number;
  26713. X: number;
  26714. Y: number;
  26715. Z: number;
  26716. };
  26717. facetDepthSort: boolean;
  26718. facetDepthSortEnabled: boolean;
  26719. depthSortedIndices: IndicesArray;
  26720. depthSortedFacets: {
  26721. ind: number;
  26722. sqDistance: number;
  26723. }[];
  26724. facetDepthSortFunction: (f1: {
  26725. ind: number;
  26726. sqDistance: number;
  26727. }, f2: {
  26728. ind: number;
  26729. sqDistance: number;
  26730. }) => number;
  26731. facetDepthSortFrom: Vector3;
  26732. facetDepthSortOrigin: Vector3;
  26733. invertedMatrix: Matrix;
  26734. }
  26735. /**
  26736. * @hidden
  26737. **/
  26738. class _InternalAbstractMeshDataInfo {
  26739. _hasVertexAlpha: boolean;
  26740. _useVertexColors: boolean;
  26741. _numBoneInfluencers: number;
  26742. _applyFog: boolean;
  26743. _receiveShadows: boolean;
  26744. _facetData: _FacetDataStorage;
  26745. _visibility: number;
  26746. _skeleton: Nullable<Skeleton>;
  26747. _layerMask: number;
  26748. _computeBonesUsingShaders: boolean;
  26749. _isActive: boolean;
  26750. _onlyForInstances: boolean;
  26751. _isActiveIntermediate: boolean;
  26752. _onlyForInstancesIntermediate: boolean;
  26753. _actAsRegularMesh: boolean;
  26754. }
  26755. /**
  26756. * Class used to store all common mesh properties
  26757. */
  26758. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26759. /** No occlusion */
  26760. static OCCLUSION_TYPE_NONE: number;
  26761. /** Occlusion set to optimisitic */
  26762. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26763. /** Occlusion set to strict */
  26764. static OCCLUSION_TYPE_STRICT: number;
  26765. /** Use an accurante occlusion algorithm */
  26766. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26767. /** Use a conservative occlusion algorithm */
  26768. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26769. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26770. * Test order :
  26771. * Is the bounding sphere outside the frustum ?
  26772. * If not, are the bounding box vertices outside the frustum ?
  26773. * It not, then the cullable object is in the frustum.
  26774. */
  26775. static readonly CULLINGSTRATEGY_STANDARD: number;
  26776. /** Culling strategy : Bounding Sphere Only.
  26777. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26778. * It's also less accurate than the standard because some not visible objects can still be selected.
  26779. * Test : is the bounding sphere outside the frustum ?
  26780. * If not, then the cullable object is in the frustum.
  26781. */
  26782. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26783. /** Culling strategy : Optimistic Inclusion.
  26784. * This in an inclusion test first, then the standard exclusion test.
  26785. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26786. * 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.
  26787. * Anyway, it's as accurate as the standard strategy.
  26788. * Test :
  26789. * Is the cullable object bounding sphere center in the frustum ?
  26790. * If not, apply the default culling strategy.
  26791. */
  26792. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26793. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26794. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26795. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26796. * 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.
  26797. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26798. * Test :
  26799. * Is the cullable object bounding sphere center in the frustum ?
  26800. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26801. */
  26802. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26803. /**
  26804. * No billboard
  26805. */
  26806. static readonly BILLBOARDMODE_NONE: number;
  26807. /** Billboard on X axis */
  26808. static readonly BILLBOARDMODE_X: number;
  26809. /** Billboard on Y axis */
  26810. static readonly BILLBOARDMODE_Y: number;
  26811. /** Billboard on Z axis */
  26812. static readonly BILLBOARDMODE_Z: number;
  26813. /** Billboard on all axes */
  26814. static readonly BILLBOARDMODE_ALL: number;
  26815. /** Billboard on using position instead of orientation */
  26816. static readonly BILLBOARDMODE_USE_POSITION: number;
  26817. /** @hidden */
  26818. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26819. /**
  26820. * The culling strategy to use to check whether the mesh must be rendered or not.
  26821. * This value can be changed at any time and will be used on the next render mesh selection.
  26822. * The possible values are :
  26823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26827. * Please read each static variable documentation to get details about the culling process.
  26828. * */
  26829. cullingStrategy: number;
  26830. /**
  26831. * Gets the number of facets in the mesh
  26832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26833. */
  26834. readonly facetNb: number;
  26835. /**
  26836. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26838. */
  26839. partitioningSubdivisions: number;
  26840. /**
  26841. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26842. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26844. */
  26845. partitioningBBoxRatio: number;
  26846. /**
  26847. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26848. * Works only for updatable meshes.
  26849. * Doesn't work with multi-materials
  26850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26851. */
  26852. mustDepthSortFacets: boolean;
  26853. /**
  26854. * The location (Vector3) where the facet depth sort must be computed from.
  26855. * By default, the active camera position.
  26856. * Used only when facet depth sort is enabled
  26857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26858. */
  26859. facetDepthSortFrom: Vector3;
  26860. /**
  26861. * gets a boolean indicating if facetData is enabled
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26863. */
  26864. readonly isFacetDataEnabled: boolean;
  26865. /** @hidden */
  26866. _updateNonUniformScalingState(value: boolean): boolean;
  26867. /**
  26868. * An event triggered when this mesh collides with another one
  26869. */
  26870. onCollideObservable: Observable<AbstractMesh>;
  26871. /** Set a function to call when this mesh collides with another one */
  26872. onCollide: () => void;
  26873. /**
  26874. * An event triggered when the collision's position changes
  26875. */
  26876. onCollisionPositionChangeObservable: Observable<Vector3>;
  26877. /** Set a function to call when the collision's position changes */
  26878. onCollisionPositionChange: () => void;
  26879. /**
  26880. * An event triggered when material is changed
  26881. */
  26882. onMaterialChangedObservable: Observable<AbstractMesh>;
  26883. /**
  26884. * Gets or sets the orientation for POV movement & rotation
  26885. */
  26886. definedFacingForward: boolean;
  26887. /** @hidden */
  26888. _occlusionQuery: Nullable<WebGLQuery>;
  26889. /** @hidden */
  26890. _renderingGroup: Nullable<RenderingGroup>;
  26891. /**
  26892. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26893. */
  26894. /**
  26895. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26896. */
  26897. visibility: number;
  26898. /** Gets or sets the alpha index used to sort transparent meshes
  26899. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26900. */
  26901. alphaIndex: number;
  26902. /**
  26903. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26904. */
  26905. isVisible: boolean;
  26906. /**
  26907. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26908. */
  26909. isPickable: boolean;
  26910. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26911. showSubMeshesBoundingBox: boolean;
  26912. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26913. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26914. */
  26915. isBlocker: boolean;
  26916. /**
  26917. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26918. */
  26919. enablePointerMoveEvents: boolean;
  26920. /**
  26921. * Specifies the rendering group id for this mesh (0 by default)
  26922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26923. */
  26924. renderingGroupId: number;
  26925. private _material;
  26926. /** Gets or sets current material */
  26927. material: Nullable<Material>;
  26928. /**
  26929. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26930. * @see http://doc.babylonjs.com/babylon101/shadows
  26931. */
  26932. receiveShadows: boolean;
  26933. /** Defines color to use when rendering outline */
  26934. outlineColor: Color3;
  26935. /** Define width to use when rendering outline */
  26936. outlineWidth: number;
  26937. /** Defines color to use when rendering overlay */
  26938. overlayColor: Color3;
  26939. /** Defines alpha to use when rendering overlay */
  26940. overlayAlpha: number;
  26941. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26942. hasVertexAlpha: boolean;
  26943. /** 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) */
  26944. useVertexColors: boolean;
  26945. /**
  26946. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26947. */
  26948. computeBonesUsingShaders: boolean;
  26949. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26950. numBoneInfluencers: number;
  26951. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26952. applyFog: boolean;
  26953. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26954. useOctreeForRenderingSelection: boolean;
  26955. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26956. useOctreeForPicking: boolean;
  26957. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26958. useOctreeForCollisions: boolean;
  26959. /**
  26960. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26961. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26962. */
  26963. layerMask: number;
  26964. /**
  26965. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26966. */
  26967. alwaysSelectAsActiveMesh: boolean;
  26968. /**
  26969. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26970. */
  26971. doNotSyncBoundingInfo: boolean;
  26972. /**
  26973. * Gets or sets the current action manager
  26974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26975. */
  26976. actionManager: Nullable<AbstractActionManager>;
  26977. private _meshCollisionData;
  26978. /**
  26979. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26981. */
  26982. ellipsoid: Vector3;
  26983. /**
  26984. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26986. */
  26987. ellipsoidOffset: Vector3;
  26988. /**
  26989. * Gets or sets a collision mask used to mask collisions (default is -1).
  26990. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26991. */
  26992. collisionMask: number;
  26993. /**
  26994. * Gets or sets the current collision group mask (-1 by default).
  26995. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26996. */
  26997. collisionGroup: number;
  26998. /**
  26999. * Defines edge width used when edgesRenderer is enabled
  27000. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27001. */
  27002. edgesWidth: number;
  27003. /**
  27004. * Defines edge color used when edgesRenderer is enabled
  27005. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27006. */
  27007. edgesColor: Color4;
  27008. /** @hidden */
  27009. _edgesRenderer: Nullable<IEdgesRenderer>;
  27010. /** @hidden */
  27011. _masterMesh: Nullable<AbstractMesh>;
  27012. /** @hidden */
  27013. _boundingInfo: Nullable<BoundingInfo>;
  27014. /** @hidden */
  27015. _renderId: number;
  27016. /**
  27017. * Gets or sets the list of subMeshes
  27018. * @see http://doc.babylonjs.com/how_to/multi_materials
  27019. */
  27020. subMeshes: SubMesh[];
  27021. /** @hidden */
  27022. _intersectionsInProgress: AbstractMesh[];
  27023. /** @hidden */
  27024. _unIndexed: boolean;
  27025. /** @hidden */
  27026. _lightSources: Light[];
  27027. /** Gets the list of lights affecting that mesh */
  27028. readonly lightSources: Light[];
  27029. /** @hidden */
  27030. readonly _positions: Nullable<Vector3[]>;
  27031. /** @hidden */
  27032. _waitingData: {
  27033. lods: Nullable<any>;
  27034. actions: Nullable<any>;
  27035. freezeWorldMatrix: Nullable<boolean>;
  27036. };
  27037. /** @hidden */
  27038. _bonesTransformMatrices: Nullable<Float32Array>;
  27039. /** @hidden */
  27040. _transformMatrixTexture: Nullable<RawTexture>;
  27041. /**
  27042. * Gets or sets a skeleton to apply skining transformations
  27043. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27044. */
  27045. skeleton: Nullable<Skeleton>;
  27046. /**
  27047. * An event triggered when the mesh is rebuilt.
  27048. */
  27049. onRebuildObservable: Observable<AbstractMesh>;
  27050. /**
  27051. * Creates a new AbstractMesh
  27052. * @param name defines the name of the mesh
  27053. * @param scene defines the hosting scene
  27054. */
  27055. constructor(name: string, scene?: Nullable<Scene>);
  27056. /**
  27057. * Returns the string "AbstractMesh"
  27058. * @returns "AbstractMesh"
  27059. */
  27060. getClassName(): string;
  27061. /**
  27062. * Gets a string representation of the current mesh
  27063. * @param fullDetails defines a boolean indicating if full details must be included
  27064. * @returns a string representation of the current mesh
  27065. */
  27066. toString(fullDetails?: boolean): string;
  27067. /**
  27068. * @hidden
  27069. */
  27070. protected _getEffectiveParent(): Nullable<Node>;
  27071. /** @hidden */
  27072. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27073. /** @hidden */
  27074. _rebuild(): void;
  27075. /** @hidden */
  27076. _resyncLightSources(): void;
  27077. /** @hidden */
  27078. _resyncLighSource(light: Light): void;
  27079. /** @hidden */
  27080. _unBindEffect(): void;
  27081. /** @hidden */
  27082. _removeLightSource(light: Light, dispose: boolean): void;
  27083. private _markSubMeshesAsDirty;
  27084. /** @hidden */
  27085. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27086. /** @hidden */
  27087. _markSubMeshesAsAttributesDirty(): void;
  27088. /** @hidden */
  27089. _markSubMeshesAsMiscDirty(): void;
  27090. /**
  27091. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27092. */
  27093. scaling: Vector3;
  27094. /**
  27095. * Returns true if the mesh is blocked. Implemented by child classes
  27096. */
  27097. readonly isBlocked: boolean;
  27098. /**
  27099. * Returns the mesh itself by default. Implemented by child classes
  27100. * @param camera defines the camera to use to pick the right LOD level
  27101. * @returns the currentAbstractMesh
  27102. */
  27103. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27104. /**
  27105. * Returns 0 by default. Implemented by child classes
  27106. * @returns an integer
  27107. */
  27108. getTotalVertices(): number;
  27109. /**
  27110. * Returns a positive integer : the total number of indices in this mesh geometry.
  27111. * @returns the numner of indices or zero if the mesh has no geometry.
  27112. */
  27113. getTotalIndices(): number;
  27114. /**
  27115. * Returns null by default. Implemented by child classes
  27116. * @returns null
  27117. */
  27118. getIndices(): Nullable<IndicesArray>;
  27119. /**
  27120. * Returns the array of the requested vertex data kind. Implemented by child classes
  27121. * @param kind defines the vertex data kind to use
  27122. * @returns null
  27123. */
  27124. getVerticesData(kind: string): Nullable<FloatArray>;
  27125. /**
  27126. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27127. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27128. * Note that a new underlying VertexBuffer object is created each call.
  27129. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27130. * @param kind defines vertex data kind:
  27131. * * VertexBuffer.PositionKind
  27132. * * VertexBuffer.UVKind
  27133. * * VertexBuffer.UV2Kind
  27134. * * VertexBuffer.UV3Kind
  27135. * * VertexBuffer.UV4Kind
  27136. * * VertexBuffer.UV5Kind
  27137. * * VertexBuffer.UV6Kind
  27138. * * VertexBuffer.ColorKind
  27139. * * VertexBuffer.MatricesIndicesKind
  27140. * * VertexBuffer.MatricesIndicesExtraKind
  27141. * * VertexBuffer.MatricesWeightsKind
  27142. * * VertexBuffer.MatricesWeightsExtraKind
  27143. * @param data defines the data source
  27144. * @param updatable defines if the data must be flagged as updatable (or static)
  27145. * @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
  27146. * @returns the current mesh
  27147. */
  27148. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27149. /**
  27150. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27151. * If the mesh has no geometry, it is simply returned as it is.
  27152. * @param kind defines vertex data kind:
  27153. * * VertexBuffer.PositionKind
  27154. * * VertexBuffer.UVKind
  27155. * * VertexBuffer.UV2Kind
  27156. * * VertexBuffer.UV3Kind
  27157. * * VertexBuffer.UV4Kind
  27158. * * VertexBuffer.UV5Kind
  27159. * * VertexBuffer.UV6Kind
  27160. * * VertexBuffer.ColorKind
  27161. * * VertexBuffer.MatricesIndicesKind
  27162. * * VertexBuffer.MatricesIndicesExtraKind
  27163. * * VertexBuffer.MatricesWeightsKind
  27164. * * VertexBuffer.MatricesWeightsExtraKind
  27165. * @param data defines the data source
  27166. * @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
  27167. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27168. * @returns the current mesh
  27169. */
  27170. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27171. /**
  27172. * Sets the mesh indices,
  27173. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27174. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27175. * @param totalVertices Defines the total number of vertices
  27176. * @returns the current mesh
  27177. */
  27178. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27179. /**
  27180. * Gets a boolean indicating if specific vertex data is present
  27181. * @param kind defines the vertex data kind to use
  27182. * @returns true is data kind is present
  27183. */
  27184. isVerticesDataPresent(kind: string): boolean;
  27185. /**
  27186. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27187. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27188. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27189. * @returns a BoundingInfo
  27190. */
  27191. getBoundingInfo(): BoundingInfo;
  27192. /**
  27193. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27194. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27195. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27196. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27197. * @returns the current mesh
  27198. */
  27199. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27200. /**
  27201. * Overwrite the current bounding info
  27202. * @param boundingInfo defines the new bounding info
  27203. * @returns the current mesh
  27204. */
  27205. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27206. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27207. readonly useBones: boolean;
  27208. /** @hidden */
  27209. _preActivate(): void;
  27210. /** @hidden */
  27211. _preActivateForIntermediateRendering(renderId: number): void;
  27212. /** @hidden */
  27213. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27214. /** @hidden */
  27215. _postActivate(): void;
  27216. /** @hidden */
  27217. _freeze(): void;
  27218. /** @hidden */
  27219. _unFreeze(): void;
  27220. /**
  27221. * Gets the current world matrix
  27222. * @returns a Matrix
  27223. */
  27224. getWorldMatrix(): Matrix;
  27225. /** @hidden */
  27226. _getWorldMatrixDeterminant(): number;
  27227. /**
  27228. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27229. */
  27230. readonly isAnInstance: boolean;
  27231. /**
  27232. * Gets a boolean indicating if this mesh has instances
  27233. */
  27234. readonly hasInstances: boolean;
  27235. /**
  27236. * Perform relative position change from the point of view of behind the front of the mesh.
  27237. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27238. * Supports definition of mesh facing forward or backward
  27239. * @param amountRight defines the distance on the right axis
  27240. * @param amountUp defines the distance on the up axis
  27241. * @param amountForward defines the distance on the forward axis
  27242. * @returns the current mesh
  27243. */
  27244. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27245. /**
  27246. * Calculate relative position change from the point of view of behind the front of the mesh.
  27247. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27248. * Supports definition of mesh facing forward or backward
  27249. * @param amountRight defines the distance on the right axis
  27250. * @param amountUp defines the distance on the up axis
  27251. * @param amountForward defines the distance on the forward axis
  27252. * @returns the new displacement vector
  27253. */
  27254. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27255. /**
  27256. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27257. * Supports definition of mesh facing forward or backward
  27258. * @param flipBack defines the flip
  27259. * @param twirlClockwise defines the twirl
  27260. * @param tiltRight defines the tilt
  27261. * @returns the current mesh
  27262. */
  27263. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27264. /**
  27265. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27266. * Supports definition of mesh facing forward or backward.
  27267. * @param flipBack defines the flip
  27268. * @param twirlClockwise defines the twirl
  27269. * @param tiltRight defines the tilt
  27270. * @returns the new rotation vector
  27271. */
  27272. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27273. /**
  27274. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27275. * This means the mesh underlying bounding box and sphere are recomputed.
  27276. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27277. * @returns the current mesh
  27278. */
  27279. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27280. /** @hidden */
  27281. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27282. /** @hidden */
  27283. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27284. /** @hidden */
  27285. _updateBoundingInfo(): AbstractMesh;
  27286. /** @hidden */
  27287. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27288. /** @hidden */
  27289. protected _afterComputeWorldMatrix(): void;
  27290. /** @hidden */
  27291. readonly _effectiveMesh: AbstractMesh;
  27292. /**
  27293. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27294. * A mesh is in the frustum if its bounding box intersects the frustum
  27295. * @param frustumPlanes defines the frustum to test
  27296. * @returns true if the mesh is in the frustum planes
  27297. */
  27298. isInFrustum(frustumPlanes: Plane[]): boolean;
  27299. /**
  27300. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27301. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27302. * @param frustumPlanes defines the frustum to test
  27303. * @returns true if the mesh is completely in the frustum planes
  27304. */
  27305. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27306. /**
  27307. * True if the mesh intersects another mesh or a SolidParticle object
  27308. * @param mesh defines a target mesh or SolidParticle to test
  27309. * @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)
  27310. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27311. * @returns true if there is an intersection
  27312. */
  27313. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27314. /**
  27315. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27316. * @param point defines the point to test
  27317. * @returns true if there is an intersection
  27318. */
  27319. intersectsPoint(point: Vector3): boolean;
  27320. /**
  27321. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27323. */
  27324. checkCollisions: boolean;
  27325. /**
  27326. * Gets Collider object used to compute collisions (not physics)
  27327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27328. */
  27329. readonly collider: Nullable<Collider>;
  27330. /**
  27331. * Move the mesh using collision engine
  27332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27333. * @param displacement defines the requested displacement vector
  27334. * @returns the current mesh
  27335. */
  27336. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27337. private _onCollisionPositionChange;
  27338. /** @hidden */
  27339. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27340. /** @hidden */
  27341. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27342. /** @hidden */
  27343. _checkCollision(collider: Collider): AbstractMesh;
  27344. /** @hidden */
  27345. _generatePointsArray(): boolean;
  27346. /**
  27347. * Checks if the passed Ray intersects with the mesh
  27348. * @param ray defines the ray to use
  27349. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27350. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27351. * @returns the picking info
  27352. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27353. */
  27354. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27355. /**
  27356. * Clones the current mesh
  27357. * @param name defines the mesh name
  27358. * @param newParent defines the new mesh parent
  27359. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27360. * @returns the new mesh
  27361. */
  27362. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27363. /**
  27364. * Disposes all the submeshes of the current meshnp
  27365. * @returns the current mesh
  27366. */
  27367. releaseSubMeshes(): AbstractMesh;
  27368. /**
  27369. * Releases resources associated with this abstract mesh.
  27370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27372. */
  27373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27374. /**
  27375. * Adds the passed mesh as a child to the current mesh
  27376. * @param mesh defines the child mesh
  27377. * @returns the current mesh
  27378. */
  27379. addChild(mesh: AbstractMesh): AbstractMesh;
  27380. /**
  27381. * Removes the passed mesh from the current mesh children list
  27382. * @param mesh defines the child mesh
  27383. * @returns the current mesh
  27384. */
  27385. removeChild(mesh: AbstractMesh): AbstractMesh;
  27386. /** @hidden */
  27387. private _initFacetData;
  27388. /**
  27389. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27390. * This method can be called within the render loop.
  27391. * 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
  27392. * @returns the current mesh
  27393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27394. */
  27395. updateFacetData(): AbstractMesh;
  27396. /**
  27397. * Returns the facetLocalNormals array.
  27398. * The normals are expressed in the mesh local spac
  27399. * @returns an array of Vector3
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27401. */
  27402. getFacetLocalNormals(): Vector3[];
  27403. /**
  27404. * Returns the facetLocalPositions array.
  27405. * The facet positions are expressed in the mesh local space
  27406. * @returns an array of Vector3
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27408. */
  27409. getFacetLocalPositions(): Vector3[];
  27410. /**
  27411. * Returns the facetLocalPartioning array
  27412. * @returns an array of array of numbers
  27413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27414. */
  27415. getFacetLocalPartitioning(): number[][];
  27416. /**
  27417. * Returns the i-th facet position in the world system.
  27418. * This method allocates a new Vector3 per call
  27419. * @param i defines the facet index
  27420. * @returns a new Vector3
  27421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27422. */
  27423. getFacetPosition(i: number): Vector3;
  27424. /**
  27425. * Sets the reference Vector3 with the i-th facet position in the world system
  27426. * @param i defines the facet index
  27427. * @param ref defines the target vector
  27428. * @returns the current mesh
  27429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27430. */
  27431. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27432. /**
  27433. * Returns the i-th facet normal in the world system.
  27434. * This method allocates a new Vector3 per call
  27435. * @param i defines the facet index
  27436. * @returns a new Vector3
  27437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27438. */
  27439. getFacetNormal(i: number): Vector3;
  27440. /**
  27441. * Sets the reference Vector3 with the i-th facet normal in the world system
  27442. * @param i defines the facet index
  27443. * @param ref defines the target vector
  27444. * @returns the current mesh
  27445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27446. */
  27447. getFacetNormalToRef(i: number, ref: Vector3): this;
  27448. /**
  27449. * 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)
  27450. * @param x defines x coordinate
  27451. * @param y defines y coordinate
  27452. * @param z defines z coordinate
  27453. * @returns the array of facet indexes
  27454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27455. */
  27456. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27457. /**
  27458. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27459. * @param projected sets as the (x,y,z) world projection on the facet
  27460. * @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
  27461. * @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
  27462. * @param x defines x coordinate
  27463. * @param y defines y coordinate
  27464. * @param z defines z coordinate
  27465. * @returns the face index if found (or null instead)
  27466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27467. */
  27468. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27469. /**
  27470. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27471. * @param projected sets as the (x,y,z) local projection on the facet
  27472. * @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
  27473. * @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
  27474. * @param x defines x coordinate
  27475. * @param y defines y coordinate
  27476. * @param z defines z coordinate
  27477. * @returns the face index if found (or null instead)
  27478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27479. */
  27480. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27481. /**
  27482. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27483. * @returns the parameters
  27484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27485. */
  27486. getFacetDataParameters(): any;
  27487. /**
  27488. * Disables the feature FacetData and frees the related memory
  27489. * @returns the current mesh
  27490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27491. */
  27492. disableFacetData(): AbstractMesh;
  27493. /**
  27494. * Updates the AbstractMesh indices array
  27495. * @param indices defines the data source
  27496. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27497. * @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)
  27498. * @returns the current mesh
  27499. */
  27500. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27501. /**
  27502. * Creates new normals data for the mesh
  27503. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27504. * @returns the current mesh
  27505. */
  27506. createNormals(updatable: boolean): AbstractMesh;
  27507. /**
  27508. * Align the mesh with a normal
  27509. * @param normal defines the normal to use
  27510. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27511. * @returns the current mesh
  27512. */
  27513. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27514. /** @hidden */
  27515. _checkOcclusionQuery(): boolean;
  27516. /**
  27517. * Disables the mesh edge rendering mode
  27518. * @returns the currentAbstractMesh
  27519. */
  27520. disableEdgesRendering(): AbstractMesh;
  27521. /**
  27522. * Enables the edge rendering mode on the mesh.
  27523. * This mode makes the mesh edges visible
  27524. * @param epsilon defines the maximal distance between two angles to detect a face
  27525. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27526. * @returns the currentAbstractMesh
  27527. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27528. */
  27529. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27530. }
  27531. }
  27532. declare module "babylonjs/Actions/actionEvent" {
  27533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27534. import { Nullable } from "babylonjs/types";
  27535. import { Sprite } from "babylonjs/Sprites/sprite";
  27536. import { Scene } from "babylonjs/scene";
  27537. import { Vector2 } from "babylonjs/Maths/math.vector";
  27538. /**
  27539. * Interface used to define ActionEvent
  27540. */
  27541. export interface IActionEvent {
  27542. /** The mesh or sprite that triggered the action */
  27543. source: any;
  27544. /** The X mouse cursor position at the time of the event */
  27545. pointerX: number;
  27546. /** The Y mouse cursor position at the time of the event */
  27547. pointerY: number;
  27548. /** The mesh that is currently pointed at (can be null) */
  27549. meshUnderPointer: Nullable<AbstractMesh>;
  27550. /** the original (browser) event that triggered the ActionEvent */
  27551. sourceEvent?: any;
  27552. /** additional data for the event */
  27553. additionalData?: any;
  27554. }
  27555. /**
  27556. * ActionEvent is the event being sent when an action is triggered.
  27557. */
  27558. export class ActionEvent implements IActionEvent {
  27559. /** The mesh or sprite that triggered the action */
  27560. source: any;
  27561. /** The X mouse cursor position at the time of the event */
  27562. pointerX: number;
  27563. /** The Y mouse cursor position at the time of the event */
  27564. pointerY: number;
  27565. /** The mesh that is currently pointed at (can be null) */
  27566. meshUnderPointer: Nullable<AbstractMesh>;
  27567. /** the original (browser) event that triggered the ActionEvent */
  27568. sourceEvent?: any;
  27569. /** additional data for the event */
  27570. additionalData?: any;
  27571. /**
  27572. * Creates a new ActionEvent
  27573. * @param source The mesh or sprite that triggered the action
  27574. * @param pointerX The X mouse cursor position at the time of the event
  27575. * @param pointerY The Y mouse cursor position at the time of the event
  27576. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27577. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27578. * @param additionalData additional data for the event
  27579. */
  27580. constructor(
  27581. /** The mesh or sprite that triggered the action */
  27582. source: any,
  27583. /** The X mouse cursor position at the time of the event */
  27584. pointerX: number,
  27585. /** The Y mouse cursor position at the time of the event */
  27586. pointerY: number,
  27587. /** The mesh that is currently pointed at (can be null) */
  27588. meshUnderPointer: Nullable<AbstractMesh>,
  27589. /** the original (browser) event that triggered the ActionEvent */
  27590. sourceEvent?: any,
  27591. /** additional data for the event */
  27592. additionalData?: any);
  27593. /**
  27594. * Helper function to auto-create an ActionEvent from a source mesh.
  27595. * @param source The source mesh that triggered the event
  27596. * @param evt The original (browser) event
  27597. * @param additionalData additional data for the event
  27598. * @returns the new ActionEvent
  27599. */
  27600. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27601. /**
  27602. * Helper function to auto-create an ActionEvent from a source sprite
  27603. * @param source The source sprite that triggered the event
  27604. * @param scene Scene associated with the sprite
  27605. * @param evt The original (browser) event
  27606. * @param additionalData additional data for the event
  27607. * @returns the new ActionEvent
  27608. */
  27609. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27610. /**
  27611. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27612. * @param scene the scene where the event occurred
  27613. * @param evt The original (browser) event
  27614. * @returns the new ActionEvent
  27615. */
  27616. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27617. /**
  27618. * Helper function to auto-create an ActionEvent from a primitive
  27619. * @param prim defines the target primitive
  27620. * @param pointerPos defines the pointer position
  27621. * @param evt The original (browser) event
  27622. * @param additionalData additional data for the event
  27623. * @returns the new ActionEvent
  27624. */
  27625. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27626. }
  27627. }
  27628. declare module "babylonjs/Actions/abstractActionManager" {
  27629. import { IDisposable } from "babylonjs/scene";
  27630. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27631. import { IAction } from "babylonjs/Actions/action";
  27632. import { Nullable } from "babylonjs/types";
  27633. /**
  27634. * Abstract class used to decouple action Manager from scene and meshes.
  27635. * Do not instantiate.
  27636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27637. */
  27638. export abstract class AbstractActionManager implements IDisposable {
  27639. /** Gets the list of active triggers */
  27640. static Triggers: {
  27641. [key: string]: number;
  27642. };
  27643. /** Gets the cursor to use when hovering items */
  27644. hoverCursor: string;
  27645. /** Gets the list of actions */
  27646. actions: IAction[];
  27647. /**
  27648. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27649. */
  27650. isRecursive: boolean;
  27651. /**
  27652. * Releases all associated resources
  27653. */
  27654. abstract dispose(): void;
  27655. /**
  27656. * Does this action manager has pointer triggers
  27657. */
  27658. abstract readonly hasPointerTriggers: boolean;
  27659. /**
  27660. * Does this action manager has pick triggers
  27661. */
  27662. abstract readonly hasPickTriggers: boolean;
  27663. /**
  27664. * Process a specific trigger
  27665. * @param trigger defines the trigger to process
  27666. * @param evt defines the event details to be processed
  27667. */
  27668. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27669. /**
  27670. * Does this action manager handles actions of any of the given triggers
  27671. * @param triggers defines the triggers to be tested
  27672. * @return a boolean indicating whether one (or more) of the triggers is handled
  27673. */
  27674. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27675. /**
  27676. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27677. * speed.
  27678. * @param triggerA defines the trigger to be tested
  27679. * @param triggerB defines the trigger to be tested
  27680. * @return a boolean indicating whether one (or more) of the triggers is handled
  27681. */
  27682. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27683. /**
  27684. * Does this action manager handles actions of a given trigger
  27685. * @param trigger defines the trigger to be tested
  27686. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27687. * @return whether the trigger is handled
  27688. */
  27689. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27690. /**
  27691. * Serialize this manager to a JSON object
  27692. * @param name defines the property name to store this manager
  27693. * @returns a JSON representation of this manager
  27694. */
  27695. abstract serialize(name: string): any;
  27696. /**
  27697. * Registers an action to this action manager
  27698. * @param action defines the action to be registered
  27699. * @return the action amended (prepared) after registration
  27700. */
  27701. abstract registerAction(action: IAction): Nullable<IAction>;
  27702. /**
  27703. * Unregisters an action to this action manager
  27704. * @param action defines the action to be unregistered
  27705. * @return a boolean indicating whether the action has been unregistered
  27706. */
  27707. abstract unregisterAction(action: IAction): Boolean;
  27708. /**
  27709. * Does exist one action manager with at least one trigger
  27710. **/
  27711. static readonly HasTriggers: boolean;
  27712. /**
  27713. * Does exist one action manager with at least one pick trigger
  27714. **/
  27715. static readonly HasPickTriggers: boolean;
  27716. /**
  27717. * Does exist one action manager that handles actions of a given trigger
  27718. * @param trigger defines the trigger to be tested
  27719. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27720. **/
  27721. static HasSpecificTrigger(trigger: number): boolean;
  27722. }
  27723. }
  27724. declare module "babylonjs/node" {
  27725. import { Scene } from "babylonjs/scene";
  27726. import { Nullable } from "babylonjs/types";
  27727. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27728. import { Engine } from "babylonjs/Engines/engine";
  27729. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27730. import { Observable } from "babylonjs/Misc/observable";
  27731. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27732. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27733. import { Animatable } from "babylonjs/Animations/animatable";
  27734. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27735. import { Animation } from "babylonjs/Animations/animation";
  27736. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27738. /**
  27739. * Defines how a node can be built from a string name.
  27740. */
  27741. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27742. /**
  27743. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27744. */
  27745. export class Node implements IBehaviorAware<Node> {
  27746. /** @hidden */
  27747. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27748. private static _NodeConstructors;
  27749. /**
  27750. * Add a new node constructor
  27751. * @param type defines the type name of the node to construct
  27752. * @param constructorFunc defines the constructor function
  27753. */
  27754. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27755. /**
  27756. * Returns a node constructor based on type name
  27757. * @param type defines the type name
  27758. * @param name defines the new node name
  27759. * @param scene defines the hosting scene
  27760. * @param options defines optional options to transmit to constructors
  27761. * @returns the new constructor or null
  27762. */
  27763. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27764. /**
  27765. * Gets or sets the name of the node
  27766. */
  27767. name: string;
  27768. /**
  27769. * Gets or sets the id of the node
  27770. */
  27771. id: string;
  27772. /**
  27773. * Gets or sets the unique id of the node
  27774. */
  27775. uniqueId: number;
  27776. /**
  27777. * Gets or sets a string used to store user defined state for the node
  27778. */
  27779. state: string;
  27780. /**
  27781. * Gets or sets an object used to store user defined information for the node
  27782. */
  27783. metadata: any;
  27784. /**
  27785. * For internal use only. Please do not use.
  27786. */
  27787. reservedDataStore: any;
  27788. /**
  27789. * List of inspectable custom properties (used by the Inspector)
  27790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27791. */
  27792. inspectableCustomProperties: IInspectable[];
  27793. private _doNotSerialize;
  27794. /**
  27795. * Gets or sets a boolean used to define if the node must be serialized
  27796. */
  27797. doNotSerialize: boolean;
  27798. /** @hidden */
  27799. _isDisposed: boolean;
  27800. /**
  27801. * Gets a list of Animations associated with the node
  27802. */
  27803. animations: import("babylonjs/Animations/animation").Animation[];
  27804. protected _ranges: {
  27805. [name: string]: Nullable<AnimationRange>;
  27806. };
  27807. /**
  27808. * Callback raised when the node is ready to be used
  27809. */
  27810. onReady: Nullable<(node: Node) => void>;
  27811. private _isEnabled;
  27812. private _isParentEnabled;
  27813. private _isReady;
  27814. /** @hidden */
  27815. _currentRenderId: number;
  27816. private _parentUpdateId;
  27817. /** @hidden */
  27818. _childUpdateId: number;
  27819. /** @hidden */
  27820. _waitingParentId: Nullable<string>;
  27821. /** @hidden */
  27822. _scene: Scene;
  27823. /** @hidden */
  27824. _cache: any;
  27825. private _parentNode;
  27826. private _children;
  27827. /** @hidden */
  27828. _worldMatrix: Matrix;
  27829. /** @hidden */
  27830. _worldMatrixDeterminant: number;
  27831. /** @hidden */
  27832. _worldMatrixDeterminantIsDirty: boolean;
  27833. /** @hidden */
  27834. private _sceneRootNodesIndex;
  27835. /**
  27836. * Gets a boolean indicating if the node has been disposed
  27837. * @returns true if the node was disposed
  27838. */
  27839. isDisposed(): boolean;
  27840. /**
  27841. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27842. * @see https://doc.babylonjs.com/how_to/parenting
  27843. */
  27844. parent: Nullable<Node>;
  27845. /** @hidden */
  27846. _addToSceneRootNodes(): void;
  27847. /** @hidden */
  27848. _removeFromSceneRootNodes(): void;
  27849. private _animationPropertiesOverride;
  27850. /**
  27851. * Gets or sets the animation properties override
  27852. */
  27853. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27854. /**
  27855. * Gets a string idenfifying the name of the class
  27856. * @returns "Node" string
  27857. */
  27858. getClassName(): string;
  27859. /** @hidden */
  27860. readonly _isNode: boolean;
  27861. /**
  27862. * An event triggered when the mesh is disposed
  27863. */
  27864. onDisposeObservable: Observable<Node>;
  27865. private _onDisposeObserver;
  27866. /**
  27867. * Sets a callback that will be raised when the node will be disposed
  27868. */
  27869. onDispose: () => void;
  27870. /**
  27871. * Creates a new Node
  27872. * @param name the name and id to be given to this node
  27873. * @param scene the scene this node will be added to
  27874. */
  27875. constructor(name: string, scene?: Nullable<Scene>);
  27876. /**
  27877. * Gets the scene of the node
  27878. * @returns a scene
  27879. */
  27880. getScene(): Scene;
  27881. /**
  27882. * Gets the engine of the node
  27883. * @returns a Engine
  27884. */
  27885. getEngine(): Engine;
  27886. private _behaviors;
  27887. /**
  27888. * Attach a behavior to the node
  27889. * @see http://doc.babylonjs.com/features/behaviour
  27890. * @param behavior defines the behavior to attach
  27891. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27892. * @returns the current Node
  27893. */
  27894. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27895. /**
  27896. * Remove an attached behavior
  27897. * @see http://doc.babylonjs.com/features/behaviour
  27898. * @param behavior defines the behavior to attach
  27899. * @returns the current Node
  27900. */
  27901. removeBehavior(behavior: Behavior<Node>): Node;
  27902. /**
  27903. * Gets the list of attached behaviors
  27904. * @see http://doc.babylonjs.com/features/behaviour
  27905. */
  27906. readonly behaviors: Behavior<Node>[];
  27907. /**
  27908. * Gets an attached behavior by name
  27909. * @param name defines the name of the behavior to look for
  27910. * @see http://doc.babylonjs.com/features/behaviour
  27911. * @returns null if behavior was not found else the requested behavior
  27912. */
  27913. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27914. /**
  27915. * Returns the latest update of the World matrix
  27916. * @returns a Matrix
  27917. */
  27918. getWorldMatrix(): Matrix;
  27919. /** @hidden */
  27920. _getWorldMatrixDeterminant(): number;
  27921. /**
  27922. * Returns directly the latest state of the mesh World matrix.
  27923. * A Matrix is returned.
  27924. */
  27925. readonly worldMatrixFromCache: Matrix;
  27926. /** @hidden */
  27927. _initCache(): void;
  27928. /** @hidden */
  27929. updateCache(force?: boolean): void;
  27930. /** @hidden */
  27931. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27932. /** @hidden */
  27933. _updateCache(ignoreParentClass?: boolean): void;
  27934. /** @hidden */
  27935. _isSynchronized(): boolean;
  27936. /** @hidden */
  27937. _markSyncedWithParent(): void;
  27938. /** @hidden */
  27939. isSynchronizedWithParent(): boolean;
  27940. /** @hidden */
  27941. isSynchronized(): boolean;
  27942. /**
  27943. * Is this node ready to be used/rendered
  27944. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27945. * @return true if the node is ready
  27946. */
  27947. isReady(completeCheck?: boolean): boolean;
  27948. /**
  27949. * Is this node enabled?
  27950. * 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
  27951. * @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
  27952. * @return whether this node (and its parent) is enabled
  27953. */
  27954. isEnabled(checkAncestors?: boolean): boolean;
  27955. /** @hidden */
  27956. protected _syncParentEnabledState(): void;
  27957. /**
  27958. * Set the enabled state of this node
  27959. * @param value defines the new enabled state
  27960. */
  27961. setEnabled(value: boolean): void;
  27962. /**
  27963. * Is this node a descendant of the given node?
  27964. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27965. * @param ancestor defines the parent node to inspect
  27966. * @returns a boolean indicating if this node is a descendant of the given node
  27967. */
  27968. isDescendantOf(ancestor: Node): boolean;
  27969. /** @hidden */
  27970. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27971. /**
  27972. * Will return all nodes that have this node as ascendant
  27973. * @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
  27974. * @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
  27975. * @return all children nodes of all types
  27976. */
  27977. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27978. /**
  27979. * Get all child-meshes of this node
  27980. * @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)
  27981. * @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
  27982. * @returns an array of AbstractMesh
  27983. */
  27984. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27985. /**
  27986. * Get all direct children of this node
  27987. * @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
  27988. * @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)
  27989. * @returns an array of Node
  27990. */
  27991. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27992. /** @hidden */
  27993. _setReady(state: boolean): void;
  27994. /**
  27995. * Get an animation by name
  27996. * @param name defines the name of the animation to look for
  27997. * @returns null if not found else the requested animation
  27998. */
  27999. getAnimationByName(name: string): Nullable<Animation>;
  28000. /**
  28001. * Creates an animation range for this node
  28002. * @param name defines the name of the range
  28003. * @param from defines the starting key
  28004. * @param to defines the end key
  28005. */
  28006. createAnimationRange(name: string, from: number, to: number): void;
  28007. /**
  28008. * Delete a specific animation range
  28009. * @param name defines the name of the range to delete
  28010. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28011. */
  28012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28013. /**
  28014. * Get an animation range by name
  28015. * @param name defines the name of the animation range to look for
  28016. * @returns null if not found else the requested animation range
  28017. */
  28018. getAnimationRange(name: string): Nullable<AnimationRange>;
  28019. /**
  28020. * Gets the list of all animation ranges defined on this node
  28021. * @returns an array
  28022. */
  28023. getAnimationRanges(): Nullable<AnimationRange>[];
  28024. /**
  28025. * Will start the animation sequence
  28026. * @param name defines the range frames for animation sequence
  28027. * @param loop defines if the animation should loop (false by default)
  28028. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28029. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28030. * @returns the object created for this animation. If range does not exist, it will return null
  28031. */
  28032. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28033. /**
  28034. * Serialize animation ranges into a JSON compatible object
  28035. * @returns serialization object
  28036. */
  28037. serializeAnimationRanges(): any;
  28038. /**
  28039. * Computes the world matrix of the node
  28040. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28041. * @returns the world matrix
  28042. */
  28043. computeWorldMatrix(force?: boolean): Matrix;
  28044. /**
  28045. * Releases resources associated with this node.
  28046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28048. */
  28049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28050. /**
  28051. * Parse animation range data from a serialization object and store them into a given node
  28052. * @param node defines where to store the animation ranges
  28053. * @param parsedNode defines the serialization object to read data from
  28054. * @param scene defines the hosting scene
  28055. */
  28056. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28057. /**
  28058. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28059. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28060. * @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
  28061. * @returns the new bounding vectors
  28062. */
  28063. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28064. min: Vector3;
  28065. max: Vector3;
  28066. };
  28067. }
  28068. }
  28069. declare module "babylonjs/Animations/animation" {
  28070. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28071. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28072. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28073. import { Nullable } from "babylonjs/types";
  28074. import { Scene } from "babylonjs/scene";
  28075. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28076. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28077. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28078. import { Node } from "babylonjs/node";
  28079. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28080. import { Size } from "babylonjs/Maths/math.size";
  28081. import { Animatable } from "babylonjs/Animations/animatable";
  28082. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28083. /**
  28084. * @hidden
  28085. */
  28086. export class _IAnimationState {
  28087. key: number;
  28088. repeatCount: number;
  28089. workValue?: any;
  28090. loopMode?: number;
  28091. offsetValue?: any;
  28092. highLimitValue?: any;
  28093. }
  28094. /**
  28095. * Class used to store any kind of animation
  28096. */
  28097. export class Animation {
  28098. /**Name of the animation */
  28099. name: string;
  28100. /**Property to animate */
  28101. targetProperty: string;
  28102. /**The frames per second of the animation */
  28103. framePerSecond: number;
  28104. /**The data type of the animation */
  28105. dataType: number;
  28106. /**The loop mode of the animation */
  28107. loopMode?: number | undefined;
  28108. /**Specifies if blending should be enabled */
  28109. enableBlending?: boolean | undefined;
  28110. /**
  28111. * Use matrix interpolation instead of using direct key value when animating matrices
  28112. */
  28113. static AllowMatricesInterpolation: boolean;
  28114. /**
  28115. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28116. */
  28117. static AllowMatrixDecomposeForInterpolation: boolean;
  28118. /**
  28119. * Stores the key frames of the animation
  28120. */
  28121. private _keys;
  28122. /**
  28123. * Stores the easing function of the animation
  28124. */
  28125. private _easingFunction;
  28126. /**
  28127. * @hidden Internal use only
  28128. */
  28129. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28130. /**
  28131. * The set of event that will be linked to this animation
  28132. */
  28133. private _events;
  28134. /**
  28135. * Stores an array of target property paths
  28136. */
  28137. targetPropertyPath: string[];
  28138. /**
  28139. * Stores the blending speed of the animation
  28140. */
  28141. blendingSpeed: number;
  28142. /**
  28143. * Stores the animation ranges for the animation
  28144. */
  28145. private _ranges;
  28146. /**
  28147. * @hidden Internal use
  28148. */
  28149. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28150. /**
  28151. * Sets up an animation
  28152. * @param property The property to animate
  28153. * @param animationType The animation type to apply
  28154. * @param framePerSecond The frames per second of the animation
  28155. * @param easingFunction The easing function used in the animation
  28156. * @returns The created animation
  28157. */
  28158. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28159. /**
  28160. * Create and start an animation on a node
  28161. * @param name defines the name of the global animation that will be run on all nodes
  28162. * @param node defines the root node where the animation will take place
  28163. * @param targetProperty defines property to animate
  28164. * @param framePerSecond defines the number of frame per second yo use
  28165. * @param totalFrame defines the number of frames in total
  28166. * @param from defines the initial value
  28167. * @param to defines the final value
  28168. * @param loopMode defines which loop mode you want to use (off by default)
  28169. * @param easingFunction defines the easing function to use (linear by default)
  28170. * @param onAnimationEnd defines the callback to call when animation end
  28171. * @returns the animatable created for this animation
  28172. */
  28173. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28174. /**
  28175. * Create and start an animation on a node and its descendants
  28176. * @param name defines the name of the global animation that will be run on all nodes
  28177. * @param node defines the root node where the animation will take place
  28178. * @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
  28179. * @param targetProperty defines property to animate
  28180. * @param framePerSecond defines the number of frame per second to use
  28181. * @param totalFrame defines the number of frames in total
  28182. * @param from defines the initial value
  28183. * @param to defines the final value
  28184. * @param loopMode defines which loop mode you want to use (off by default)
  28185. * @param easingFunction defines the easing function to use (linear by default)
  28186. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28187. * @returns the list of animatables created for all nodes
  28188. * @example https://www.babylonjs-playground.com/#MH0VLI
  28189. */
  28190. 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[]>;
  28191. /**
  28192. * Creates a new animation, merges it with the existing animations and starts it
  28193. * @param name Name of the animation
  28194. * @param node Node which contains the scene that begins the animations
  28195. * @param targetProperty Specifies which property to animate
  28196. * @param framePerSecond The frames per second of the animation
  28197. * @param totalFrame The total number of frames
  28198. * @param from The frame at the beginning of the animation
  28199. * @param to The frame at the end of the animation
  28200. * @param loopMode Specifies the loop mode of the animation
  28201. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28202. * @param onAnimationEnd Callback to run once the animation is complete
  28203. * @returns Nullable animation
  28204. */
  28205. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28206. /**
  28207. * Transition property of an host to the target Value
  28208. * @param property The property to transition
  28209. * @param targetValue The target Value of the property
  28210. * @param host The object where the property to animate belongs
  28211. * @param scene Scene used to run the animation
  28212. * @param frameRate Framerate (in frame/s) to use
  28213. * @param transition The transition type we want to use
  28214. * @param duration The duration of the animation, in milliseconds
  28215. * @param onAnimationEnd Callback trigger at the end of the animation
  28216. * @returns Nullable animation
  28217. */
  28218. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28219. /**
  28220. * Return the array of runtime animations currently using this animation
  28221. */
  28222. readonly runtimeAnimations: RuntimeAnimation[];
  28223. /**
  28224. * Specifies if any of the runtime animations are currently running
  28225. */
  28226. readonly hasRunningRuntimeAnimations: boolean;
  28227. /**
  28228. * Initializes the animation
  28229. * @param name Name of the animation
  28230. * @param targetProperty Property to animate
  28231. * @param framePerSecond The frames per second of the animation
  28232. * @param dataType The data type of the animation
  28233. * @param loopMode The loop mode of the animation
  28234. * @param enableBlending Specifies if blending should be enabled
  28235. */
  28236. constructor(
  28237. /**Name of the animation */
  28238. name: string,
  28239. /**Property to animate */
  28240. targetProperty: string,
  28241. /**The frames per second of the animation */
  28242. framePerSecond: number,
  28243. /**The data type of the animation */
  28244. dataType: number,
  28245. /**The loop mode of the animation */
  28246. loopMode?: number | undefined,
  28247. /**Specifies if blending should be enabled */
  28248. enableBlending?: boolean | undefined);
  28249. /**
  28250. * Converts the animation to a string
  28251. * @param fullDetails support for multiple levels of logging within scene loading
  28252. * @returns String form of the animation
  28253. */
  28254. toString(fullDetails?: boolean): string;
  28255. /**
  28256. * Add an event to this animation
  28257. * @param event Event to add
  28258. */
  28259. addEvent(event: AnimationEvent): void;
  28260. /**
  28261. * Remove all events found at the given frame
  28262. * @param frame The frame to remove events from
  28263. */
  28264. removeEvents(frame: number): void;
  28265. /**
  28266. * Retrieves all the events from the animation
  28267. * @returns Events from the animation
  28268. */
  28269. getEvents(): AnimationEvent[];
  28270. /**
  28271. * Creates an animation range
  28272. * @param name Name of the animation range
  28273. * @param from Starting frame of the animation range
  28274. * @param to Ending frame of the animation
  28275. */
  28276. createRange(name: string, from: number, to: number): void;
  28277. /**
  28278. * Deletes an animation range by name
  28279. * @param name Name of the animation range to delete
  28280. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28281. */
  28282. deleteRange(name: string, deleteFrames?: boolean): void;
  28283. /**
  28284. * Gets the animation range by name, or null if not defined
  28285. * @param name Name of the animation range
  28286. * @returns Nullable animation range
  28287. */
  28288. getRange(name: string): Nullable<AnimationRange>;
  28289. /**
  28290. * Gets the key frames from the animation
  28291. * @returns The key frames of the animation
  28292. */
  28293. getKeys(): Array<IAnimationKey>;
  28294. /**
  28295. * Gets the highest frame rate of the animation
  28296. * @returns Highest frame rate of the animation
  28297. */
  28298. getHighestFrame(): number;
  28299. /**
  28300. * Gets the easing function of the animation
  28301. * @returns Easing function of the animation
  28302. */
  28303. getEasingFunction(): IEasingFunction;
  28304. /**
  28305. * Sets the easing function of the animation
  28306. * @param easingFunction A custom mathematical formula for animation
  28307. */
  28308. setEasingFunction(easingFunction: EasingFunction): void;
  28309. /**
  28310. * Interpolates a scalar linearly
  28311. * @param startValue Start value of the animation curve
  28312. * @param endValue End value of the animation curve
  28313. * @param gradient Scalar amount to interpolate
  28314. * @returns Interpolated scalar value
  28315. */
  28316. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28317. /**
  28318. * Interpolates a scalar cubically
  28319. * @param startValue Start value of the animation curve
  28320. * @param outTangent End tangent of the animation
  28321. * @param endValue End value of the animation curve
  28322. * @param inTangent Start tangent of the animation curve
  28323. * @param gradient Scalar amount to interpolate
  28324. * @returns Interpolated scalar value
  28325. */
  28326. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28327. /**
  28328. * Interpolates a quaternion using a spherical linear interpolation
  28329. * @param startValue Start value of the animation curve
  28330. * @param endValue End value of the animation curve
  28331. * @param gradient Scalar amount to interpolate
  28332. * @returns Interpolated quaternion value
  28333. */
  28334. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28335. /**
  28336. * Interpolates a quaternion cubically
  28337. * @param startValue Start value of the animation curve
  28338. * @param outTangent End tangent of the animation curve
  28339. * @param endValue End value of the animation curve
  28340. * @param inTangent Start tangent of the animation curve
  28341. * @param gradient Scalar amount to interpolate
  28342. * @returns Interpolated quaternion value
  28343. */
  28344. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28345. /**
  28346. * Interpolates a Vector3 linearl
  28347. * @param startValue Start value of the animation curve
  28348. * @param endValue End value of the animation curve
  28349. * @param gradient Scalar amount to interpolate
  28350. * @returns Interpolated scalar value
  28351. */
  28352. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28353. /**
  28354. * Interpolates a Vector3 cubically
  28355. * @param startValue Start value of the animation curve
  28356. * @param outTangent End tangent of the animation
  28357. * @param endValue End value of the animation curve
  28358. * @param inTangent Start tangent of the animation curve
  28359. * @param gradient Scalar amount to interpolate
  28360. * @returns InterpolatedVector3 value
  28361. */
  28362. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28363. /**
  28364. * Interpolates a Vector2 linearly
  28365. * @param startValue Start value of the animation curve
  28366. * @param endValue End value of the animation curve
  28367. * @param gradient Scalar amount to interpolate
  28368. * @returns Interpolated Vector2 value
  28369. */
  28370. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28371. /**
  28372. * Interpolates a Vector2 cubically
  28373. * @param startValue Start value of the animation curve
  28374. * @param outTangent End tangent of the animation
  28375. * @param endValue End value of the animation curve
  28376. * @param inTangent Start tangent of the animation curve
  28377. * @param gradient Scalar amount to interpolate
  28378. * @returns Interpolated Vector2 value
  28379. */
  28380. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28381. /**
  28382. * Interpolates a size linearly
  28383. * @param startValue Start value of the animation curve
  28384. * @param endValue End value of the animation curve
  28385. * @param gradient Scalar amount to interpolate
  28386. * @returns Interpolated Size value
  28387. */
  28388. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28389. /**
  28390. * Interpolates a Color3 linearly
  28391. * @param startValue Start value of the animation curve
  28392. * @param endValue End value of the animation curve
  28393. * @param gradient Scalar amount to interpolate
  28394. * @returns Interpolated Color3 value
  28395. */
  28396. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28397. /**
  28398. * Interpolates a Color4 linearly
  28399. * @param startValue Start value of the animation curve
  28400. * @param endValue End value of the animation curve
  28401. * @param gradient Scalar amount to interpolate
  28402. * @returns Interpolated Color3 value
  28403. */
  28404. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28405. /**
  28406. * @hidden Internal use only
  28407. */
  28408. _getKeyValue(value: any): any;
  28409. /**
  28410. * @hidden Internal use only
  28411. */
  28412. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28413. /**
  28414. * Defines the function to use to interpolate matrices
  28415. * @param startValue defines the start matrix
  28416. * @param endValue defines the end matrix
  28417. * @param gradient defines the gradient between both matrices
  28418. * @param result defines an optional target matrix where to store the interpolation
  28419. * @returns the interpolated matrix
  28420. */
  28421. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28422. /**
  28423. * Makes a copy of the animation
  28424. * @returns Cloned animation
  28425. */
  28426. clone(): Animation;
  28427. /**
  28428. * Sets the key frames of the animation
  28429. * @param values The animation key frames to set
  28430. */
  28431. setKeys(values: Array<IAnimationKey>): void;
  28432. /**
  28433. * Serializes the animation to an object
  28434. * @returns Serialized object
  28435. */
  28436. serialize(): any;
  28437. /**
  28438. * Float animation type
  28439. */
  28440. static readonly ANIMATIONTYPE_FLOAT: number;
  28441. /**
  28442. * Vector3 animation type
  28443. */
  28444. static readonly ANIMATIONTYPE_VECTOR3: number;
  28445. /**
  28446. * Quaternion animation type
  28447. */
  28448. static readonly ANIMATIONTYPE_QUATERNION: number;
  28449. /**
  28450. * Matrix animation type
  28451. */
  28452. static readonly ANIMATIONTYPE_MATRIX: number;
  28453. /**
  28454. * Color3 animation type
  28455. */
  28456. static readonly ANIMATIONTYPE_COLOR3: number;
  28457. /**
  28458. * Color3 animation type
  28459. */
  28460. static readonly ANIMATIONTYPE_COLOR4: number;
  28461. /**
  28462. * Vector2 animation type
  28463. */
  28464. static readonly ANIMATIONTYPE_VECTOR2: number;
  28465. /**
  28466. * Size animation type
  28467. */
  28468. static readonly ANIMATIONTYPE_SIZE: number;
  28469. /**
  28470. * Relative Loop Mode
  28471. */
  28472. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28473. /**
  28474. * Cycle Loop Mode
  28475. */
  28476. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28477. /**
  28478. * Constant Loop Mode
  28479. */
  28480. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28481. /** @hidden */
  28482. static _UniversalLerp(left: any, right: any, amount: number): any;
  28483. /**
  28484. * Parses an animation object and creates an animation
  28485. * @param parsedAnimation Parsed animation object
  28486. * @returns Animation object
  28487. */
  28488. static Parse(parsedAnimation: any): Animation;
  28489. /**
  28490. * Appends the serialized animations from the source animations
  28491. * @param source Source containing the animations
  28492. * @param destination Target to store the animations
  28493. */
  28494. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28495. }
  28496. }
  28497. declare module "babylonjs/Animations/animatable.interface" {
  28498. import { Nullable } from "babylonjs/types";
  28499. import { Animation } from "babylonjs/Animations/animation";
  28500. /**
  28501. * Interface containing an array of animations
  28502. */
  28503. export interface IAnimatable {
  28504. /**
  28505. * Array of animations
  28506. */
  28507. animations: Nullable<Array<Animation>>;
  28508. }
  28509. }
  28510. declare module "babylonjs/Materials/fresnelParameters" {
  28511. import { Color3 } from "babylonjs/Maths/math.color";
  28512. /**
  28513. * This represents all the required information to add a fresnel effect on a material:
  28514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28515. */
  28516. export class FresnelParameters {
  28517. private _isEnabled;
  28518. /**
  28519. * Define if the fresnel effect is enable or not.
  28520. */
  28521. isEnabled: boolean;
  28522. /**
  28523. * Define the color used on edges (grazing angle)
  28524. */
  28525. leftColor: Color3;
  28526. /**
  28527. * Define the color used on center
  28528. */
  28529. rightColor: Color3;
  28530. /**
  28531. * Define bias applied to computed fresnel term
  28532. */
  28533. bias: number;
  28534. /**
  28535. * Defined the power exponent applied to fresnel term
  28536. */
  28537. power: number;
  28538. /**
  28539. * Clones the current fresnel and its valuues
  28540. * @returns a clone fresnel configuration
  28541. */
  28542. clone(): FresnelParameters;
  28543. /**
  28544. * Serializes the current fresnel parameters to a JSON representation.
  28545. * @return the JSON serialization
  28546. */
  28547. serialize(): any;
  28548. /**
  28549. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28550. * @param parsedFresnelParameters Define the JSON representation
  28551. * @returns the parsed parameters
  28552. */
  28553. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28554. }
  28555. }
  28556. declare module "babylonjs/Misc/decorators" {
  28557. import { Nullable } from "babylonjs/types";
  28558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28559. import { Scene } from "babylonjs/scene";
  28560. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28561. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28562. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28563. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28564. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28565. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28566. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28567. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28568. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28569. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28570. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28571. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28572. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28573. /**
  28574. * Decorator used to define property that can be serialized as reference to a camera
  28575. * @param sourceName defines the name of the property to decorate
  28576. */
  28577. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28578. /**
  28579. * Class used to help serialization objects
  28580. */
  28581. export class SerializationHelper {
  28582. /** @hidden */
  28583. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28584. /** @hidden */
  28585. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28586. /** @hidden */
  28587. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28588. /** @hidden */
  28589. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28590. /**
  28591. * Appends the serialized animations from the source animations
  28592. * @param source Source containing the animations
  28593. * @param destination Target to store the animations
  28594. */
  28595. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28596. /**
  28597. * Static function used to serialized a specific entity
  28598. * @param entity defines the entity to serialize
  28599. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28600. * @returns a JSON compatible object representing the serialization of the entity
  28601. */
  28602. static Serialize<T>(entity: T, serializationObject?: any): any;
  28603. /**
  28604. * Creates a new entity from a serialization data object
  28605. * @param creationFunction defines a function used to instanciated the new entity
  28606. * @param source defines the source serialization data
  28607. * @param scene defines the hosting scene
  28608. * @param rootUrl defines the root url for resources
  28609. * @returns a new entity
  28610. */
  28611. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28612. /**
  28613. * Clones an object
  28614. * @param creationFunction defines the function used to instanciate the new object
  28615. * @param source defines the source object
  28616. * @returns the cloned object
  28617. */
  28618. static Clone<T>(creationFunction: () => T, source: T): T;
  28619. /**
  28620. * Instanciates a new object based on a source one (some data will be shared between both object)
  28621. * @param creationFunction defines the function used to instanciate the new object
  28622. * @param source defines the source object
  28623. * @returns the new object
  28624. */
  28625. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28626. }
  28627. }
  28628. declare module "babylonjs/Misc/guid" {
  28629. /**
  28630. * Class used to manipulate GUIDs
  28631. */
  28632. export class GUID {
  28633. /**
  28634. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28635. * Be aware Math.random() could cause collisions, but:
  28636. * "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"
  28637. * @returns a pseudo random id
  28638. */
  28639. static RandomId(): string;
  28640. }
  28641. }
  28642. declare module "babylonjs/Materials/Textures/baseTexture" {
  28643. import { Observable } from "babylonjs/Misc/observable";
  28644. import { Nullable } from "babylonjs/types";
  28645. import { Scene } from "babylonjs/scene";
  28646. import { Matrix } from "babylonjs/Maths/math.vector";
  28647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28648. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28649. import { ISize } from "babylonjs/Maths/math.size";
  28650. /**
  28651. * Base class of all the textures in babylon.
  28652. * It groups all the common properties the materials, post process, lights... might need
  28653. * in order to make a correct use of the texture.
  28654. */
  28655. export class BaseTexture implements IAnimatable {
  28656. /**
  28657. * Default anisotropic filtering level for the application.
  28658. * It is set to 4 as a good tradeoff between perf and quality.
  28659. */
  28660. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28661. /**
  28662. * Gets or sets the unique id of the texture
  28663. */
  28664. uniqueId: number;
  28665. /**
  28666. * Define the name of the texture.
  28667. */
  28668. name: string;
  28669. /**
  28670. * Gets or sets an object used to store user defined information.
  28671. */
  28672. metadata: any;
  28673. /**
  28674. * For internal use only. Please do not use.
  28675. */
  28676. reservedDataStore: any;
  28677. private _hasAlpha;
  28678. /**
  28679. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28680. */
  28681. hasAlpha: boolean;
  28682. /**
  28683. * Defines if the alpha value should be determined via the rgb values.
  28684. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28685. */
  28686. getAlphaFromRGB: boolean;
  28687. /**
  28688. * Intensity or strength of the texture.
  28689. * It is commonly used by materials to fine tune the intensity of the texture
  28690. */
  28691. level: number;
  28692. /**
  28693. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28694. * This is part of the texture as textures usually maps to one uv set.
  28695. */
  28696. coordinatesIndex: number;
  28697. private _coordinatesMode;
  28698. /**
  28699. * How a texture is mapped.
  28700. *
  28701. * | Value | Type | Description |
  28702. * | ----- | ----------------------------------- | ----------- |
  28703. * | 0 | EXPLICIT_MODE | |
  28704. * | 1 | SPHERICAL_MODE | |
  28705. * | 2 | PLANAR_MODE | |
  28706. * | 3 | CUBIC_MODE | |
  28707. * | 4 | PROJECTION_MODE | |
  28708. * | 5 | SKYBOX_MODE | |
  28709. * | 6 | INVCUBIC_MODE | |
  28710. * | 7 | EQUIRECTANGULAR_MODE | |
  28711. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28712. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28713. */
  28714. coordinatesMode: number;
  28715. /**
  28716. * | Value | Type | Description |
  28717. * | ----- | ------------------ | ----------- |
  28718. * | 0 | CLAMP_ADDRESSMODE | |
  28719. * | 1 | WRAP_ADDRESSMODE | |
  28720. * | 2 | MIRROR_ADDRESSMODE | |
  28721. */
  28722. wrapU: number;
  28723. /**
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 0 | CLAMP_ADDRESSMODE | |
  28727. * | 1 | WRAP_ADDRESSMODE | |
  28728. * | 2 | MIRROR_ADDRESSMODE | |
  28729. */
  28730. wrapV: number;
  28731. /**
  28732. * | Value | Type | Description |
  28733. * | ----- | ------------------ | ----------- |
  28734. * | 0 | CLAMP_ADDRESSMODE | |
  28735. * | 1 | WRAP_ADDRESSMODE | |
  28736. * | 2 | MIRROR_ADDRESSMODE | |
  28737. */
  28738. wrapR: number;
  28739. /**
  28740. * With compliant hardware and browser (supporting anisotropic filtering)
  28741. * this defines the level of anisotropic filtering in the texture.
  28742. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28743. */
  28744. anisotropicFilteringLevel: number;
  28745. /**
  28746. * Define if the texture is a cube texture or if false a 2d texture.
  28747. */
  28748. isCube: boolean;
  28749. /**
  28750. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28751. */
  28752. is3D: boolean;
  28753. /**
  28754. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28755. * HDR texture are usually stored in linear space.
  28756. * This only impacts the PBR and Background materials
  28757. */
  28758. gammaSpace: boolean;
  28759. /**
  28760. * Gets or sets whether or not the texture contains RGBD data.
  28761. */
  28762. isRGBD: boolean;
  28763. /**
  28764. * Is Z inverted in the texture (useful in a cube texture).
  28765. */
  28766. invertZ: boolean;
  28767. /**
  28768. * Are mip maps generated for this texture or not.
  28769. */
  28770. readonly noMipmap: boolean;
  28771. /**
  28772. * @hidden
  28773. */
  28774. lodLevelInAlpha: boolean;
  28775. /**
  28776. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28777. */
  28778. lodGenerationOffset: number;
  28779. /**
  28780. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28781. */
  28782. lodGenerationScale: number;
  28783. /**
  28784. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28785. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28786. * average roughness values.
  28787. */
  28788. linearSpecularLOD: boolean;
  28789. /**
  28790. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28791. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28792. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28793. */
  28794. irradianceTexture: Nullable<BaseTexture>;
  28795. /**
  28796. * Define if the texture is a render target.
  28797. */
  28798. isRenderTarget: boolean;
  28799. /**
  28800. * Define the unique id of the texture in the scene.
  28801. */
  28802. readonly uid: string;
  28803. /**
  28804. * Return a string representation of the texture.
  28805. * @returns the texture as a string
  28806. */
  28807. toString(): string;
  28808. /**
  28809. * Get the class name of the texture.
  28810. * @returns "BaseTexture"
  28811. */
  28812. getClassName(): string;
  28813. /**
  28814. * Define the list of animation attached to the texture.
  28815. */
  28816. animations: import("babylonjs/Animations/animation").Animation[];
  28817. /**
  28818. * An event triggered when the texture is disposed.
  28819. */
  28820. onDisposeObservable: Observable<BaseTexture>;
  28821. private _onDisposeObserver;
  28822. /**
  28823. * Callback triggered when the texture has been disposed.
  28824. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28825. */
  28826. onDispose: () => void;
  28827. /**
  28828. * Define the current state of the loading sequence when in delayed load mode.
  28829. */
  28830. delayLoadState: number;
  28831. private _scene;
  28832. /** @hidden */
  28833. _texture: Nullable<InternalTexture>;
  28834. private _uid;
  28835. /**
  28836. * Define if the texture is preventinga material to render or not.
  28837. * If not and the texture is not ready, the engine will use a default black texture instead.
  28838. */
  28839. readonly isBlocking: boolean;
  28840. /**
  28841. * Instantiates a new BaseTexture.
  28842. * Base class of all the textures in babylon.
  28843. * It groups all the common properties the materials, post process, lights... might need
  28844. * in order to make a correct use of the texture.
  28845. * @param scene Define the scene the texture blongs to
  28846. */
  28847. constructor(scene: Nullable<Scene>);
  28848. /**
  28849. * Get the scene the texture belongs to.
  28850. * @returns the scene or null if undefined
  28851. */
  28852. getScene(): Nullable<Scene>;
  28853. /**
  28854. * Get the texture transform matrix used to offset tile the texture for istance.
  28855. * @returns the transformation matrix
  28856. */
  28857. getTextureMatrix(): Matrix;
  28858. /**
  28859. * Get the texture reflection matrix used to rotate/transform the reflection.
  28860. * @returns the reflection matrix
  28861. */
  28862. getReflectionTextureMatrix(): Matrix;
  28863. /**
  28864. * Get the underlying lower level texture from Babylon.
  28865. * @returns the insternal texture
  28866. */
  28867. getInternalTexture(): Nullable<InternalTexture>;
  28868. /**
  28869. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28870. * @returns true if ready or not blocking
  28871. */
  28872. isReadyOrNotBlocking(): boolean;
  28873. /**
  28874. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28875. * @returns true if fully ready
  28876. */
  28877. isReady(): boolean;
  28878. private _cachedSize;
  28879. /**
  28880. * Get the size of the texture.
  28881. * @returns the texture size.
  28882. */
  28883. getSize(): ISize;
  28884. /**
  28885. * Get the base size of the texture.
  28886. * It can be different from the size if the texture has been resized for POT for instance
  28887. * @returns the base size
  28888. */
  28889. getBaseSize(): ISize;
  28890. /**
  28891. * Update the sampling mode of the texture.
  28892. * Default is Trilinear mode.
  28893. *
  28894. * | Value | Type | Description |
  28895. * | ----- | ------------------ | ----------- |
  28896. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28897. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28898. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28899. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28900. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28901. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28902. * | 7 | NEAREST_LINEAR | |
  28903. * | 8 | NEAREST_NEAREST | |
  28904. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28905. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28906. * | 11 | LINEAR_LINEAR | |
  28907. * | 12 | LINEAR_NEAREST | |
  28908. *
  28909. * > _mag_: magnification filter (close to the viewer)
  28910. * > _min_: minification filter (far from the viewer)
  28911. * > _mip_: filter used between mip map levels
  28912. *@param samplingMode Define the new sampling mode of the texture
  28913. */
  28914. updateSamplingMode(samplingMode: number): void;
  28915. /**
  28916. * Scales the texture if is `canRescale()`
  28917. * @param ratio the resize factor we want to use to rescale
  28918. */
  28919. scale(ratio: number): void;
  28920. /**
  28921. * Get if the texture can rescale.
  28922. */
  28923. readonly canRescale: boolean;
  28924. /** @hidden */
  28925. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28926. /** @hidden */
  28927. _rebuild(): void;
  28928. /**
  28929. * Triggers the load sequence in delayed load mode.
  28930. */
  28931. delayLoad(): void;
  28932. /**
  28933. * Clones the texture.
  28934. * @returns the cloned texture
  28935. */
  28936. clone(): Nullable<BaseTexture>;
  28937. /**
  28938. * Get the texture underlying type (INT, FLOAT...)
  28939. */
  28940. readonly textureType: number;
  28941. /**
  28942. * Get the texture underlying format (RGB, RGBA...)
  28943. */
  28944. readonly textureFormat: number;
  28945. /**
  28946. * Indicates that textures need to be re-calculated for all materials
  28947. */
  28948. protected _markAllSubMeshesAsTexturesDirty(): void;
  28949. /**
  28950. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28951. * This will returns an RGBA array buffer containing either in values (0-255) or
  28952. * float values (0-1) depending of the underlying buffer type.
  28953. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28954. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28955. * @param buffer defines a user defined buffer to fill with data (can be null)
  28956. * @returns The Array buffer containing the pixels data.
  28957. */
  28958. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28959. /**
  28960. * Release and destroy the underlying lower level texture aka internalTexture.
  28961. */
  28962. releaseInternalTexture(): void;
  28963. /** @hidden */
  28964. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28965. /** @hidden */
  28966. readonly _lodTextureMid: Nullable<BaseTexture>;
  28967. /** @hidden */
  28968. readonly _lodTextureLow: Nullable<BaseTexture>;
  28969. /**
  28970. * Dispose the texture and release its associated resources.
  28971. */
  28972. dispose(): void;
  28973. /**
  28974. * Serialize the texture into a JSON representation that can be parsed later on.
  28975. * @returns the JSON representation of the texture
  28976. */
  28977. serialize(): any;
  28978. /**
  28979. * Helper function to be called back once a list of texture contains only ready textures.
  28980. * @param textures Define the list of textures to wait for
  28981. * @param callback Define the callback triggered once the entire list will be ready
  28982. */
  28983. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28984. }
  28985. }
  28986. declare module "babylonjs/Materials/effect" {
  28987. import { Observable } from "babylonjs/Misc/observable";
  28988. import { Nullable } from "babylonjs/types";
  28989. import { IDisposable } from "babylonjs/scene";
  28990. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28992. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28993. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28994. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28995. import { Engine } from "babylonjs/Engines/engine";
  28996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28999. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29000. /**
  29001. * Options to be used when creating an effect.
  29002. */
  29003. export interface IEffectCreationOptions {
  29004. /**
  29005. * Atrributes that will be used in the shader.
  29006. */
  29007. attributes: string[];
  29008. /**
  29009. * Uniform varible names that will be set in the shader.
  29010. */
  29011. uniformsNames: string[];
  29012. /**
  29013. * Uniform buffer varible names that will be set in the shader.
  29014. */
  29015. uniformBuffersNames: string[];
  29016. /**
  29017. * Sampler texture variable names that will be set in the shader.
  29018. */
  29019. samplers: string[];
  29020. /**
  29021. * Define statements that will be set in the shader.
  29022. */
  29023. defines: any;
  29024. /**
  29025. * Possible fallbacks for this effect to improve performance when needed.
  29026. */
  29027. fallbacks: Nullable<IEffectFallbacks>;
  29028. /**
  29029. * Callback that will be called when the shader is compiled.
  29030. */
  29031. onCompiled: Nullable<(effect: Effect) => void>;
  29032. /**
  29033. * Callback that will be called if an error occurs during shader compilation.
  29034. */
  29035. onError: Nullable<(effect: Effect, errors: string) => void>;
  29036. /**
  29037. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29038. */
  29039. indexParameters?: any;
  29040. /**
  29041. * Max number of lights that can be used in the shader.
  29042. */
  29043. maxSimultaneousLights?: number;
  29044. /**
  29045. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29046. */
  29047. transformFeedbackVaryings?: Nullable<string[]>;
  29048. }
  29049. /**
  29050. * Effect containing vertex and fragment shader that can be executed on an object.
  29051. */
  29052. export class Effect implements IDisposable {
  29053. /**
  29054. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29055. */
  29056. static ShadersRepository: string;
  29057. /**
  29058. * Name of the effect.
  29059. */
  29060. name: any;
  29061. /**
  29062. * String container all the define statements that should be set on the shader.
  29063. */
  29064. defines: string;
  29065. /**
  29066. * Callback that will be called when the shader is compiled.
  29067. */
  29068. onCompiled: Nullable<(effect: Effect) => void>;
  29069. /**
  29070. * Callback that will be called if an error occurs during shader compilation.
  29071. */
  29072. onError: Nullable<(effect: Effect, errors: string) => void>;
  29073. /**
  29074. * Callback that will be called when effect is bound.
  29075. */
  29076. onBind: Nullable<(effect: Effect) => void>;
  29077. /**
  29078. * Unique ID of the effect.
  29079. */
  29080. uniqueId: number;
  29081. /**
  29082. * Observable that will be called when the shader is compiled.
  29083. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29084. */
  29085. onCompileObservable: Observable<Effect>;
  29086. /**
  29087. * Observable that will be called if an error occurs during shader compilation.
  29088. */
  29089. onErrorObservable: Observable<Effect>;
  29090. /** @hidden */
  29091. _onBindObservable: Nullable<Observable<Effect>>;
  29092. /**
  29093. * Observable that will be called when effect is bound.
  29094. */
  29095. readonly onBindObservable: Observable<Effect>;
  29096. /** @hidden */
  29097. _bonesComputationForcedToCPU: boolean;
  29098. private static _uniqueIdSeed;
  29099. private _engine;
  29100. private _uniformBuffersNames;
  29101. private _uniformsNames;
  29102. private _samplerList;
  29103. private _samplers;
  29104. private _isReady;
  29105. private _compilationError;
  29106. private _allFallbacksProcessed;
  29107. private _attributesNames;
  29108. private _attributes;
  29109. private _uniforms;
  29110. /**
  29111. * Key for the effect.
  29112. * @hidden
  29113. */
  29114. _key: string;
  29115. private _indexParameters;
  29116. private _fallbacks;
  29117. private _vertexSourceCode;
  29118. private _fragmentSourceCode;
  29119. private _vertexSourceCodeOverride;
  29120. private _fragmentSourceCodeOverride;
  29121. private _transformFeedbackVaryings;
  29122. /**
  29123. * Compiled shader to webGL program.
  29124. * @hidden
  29125. */
  29126. _pipelineContext: Nullable<IPipelineContext>;
  29127. private _valueCache;
  29128. private static _baseCache;
  29129. /**
  29130. * Instantiates an effect.
  29131. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29132. * @param baseName Name of the effect.
  29133. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29134. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29135. * @param samplers List of sampler variables that will be passed to the shader.
  29136. * @param engine Engine to be used to render the effect
  29137. * @param defines Define statements to be added to the shader.
  29138. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29139. * @param onCompiled Callback that will be called when the shader is compiled.
  29140. * @param onError Callback that will be called if an error occurs during shader compilation.
  29141. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29142. */
  29143. 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);
  29144. private _useFinalCode;
  29145. /**
  29146. * Unique key for this effect
  29147. */
  29148. readonly key: string;
  29149. /**
  29150. * If the effect has been compiled and prepared.
  29151. * @returns if the effect is compiled and prepared.
  29152. */
  29153. isReady(): boolean;
  29154. private _isReadyInternal;
  29155. /**
  29156. * The engine the effect was initialized with.
  29157. * @returns the engine.
  29158. */
  29159. getEngine(): Engine;
  29160. /**
  29161. * The pipeline context for this effect
  29162. * @returns the associated pipeline context
  29163. */
  29164. getPipelineContext(): Nullable<IPipelineContext>;
  29165. /**
  29166. * The set of names of attribute variables for the shader.
  29167. * @returns An array of attribute names.
  29168. */
  29169. getAttributesNames(): string[];
  29170. /**
  29171. * Returns the attribute at the given index.
  29172. * @param index The index of the attribute.
  29173. * @returns The location of the attribute.
  29174. */
  29175. getAttributeLocation(index: number): number;
  29176. /**
  29177. * Returns the attribute based on the name of the variable.
  29178. * @param name of the attribute to look up.
  29179. * @returns the attribute location.
  29180. */
  29181. getAttributeLocationByName(name: string): number;
  29182. /**
  29183. * The number of attributes.
  29184. * @returns the numnber of attributes.
  29185. */
  29186. getAttributesCount(): number;
  29187. /**
  29188. * Gets the index of a uniform variable.
  29189. * @param uniformName of the uniform to look up.
  29190. * @returns the index.
  29191. */
  29192. getUniformIndex(uniformName: string): number;
  29193. /**
  29194. * Returns the attribute based on the name of the variable.
  29195. * @param uniformName of the uniform to look up.
  29196. * @returns the location of the uniform.
  29197. */
  29198. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29199. /**
  29200. * Returns an array of sampler variable names
  29201. * @returns The array of sampler variable neames.
  29202. */
  29203. getSamplers(): string[];
  29204. /**
  29205. * The error from the last compilation.
  29206. * @returns the error string.
  29207. */
  29208. getCompilationError(): string;
  29209. /**
  29210. * Gets a boolean indicating that all fallbacks were used during compilation
  29211. * @returns true if all fallbacks were used
  29212. */
  29213. allFallbacksProcessed(): boolean;
  29214. /**
  29215. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29216. * @param func The callback to be used.
  29217. */
  29218. executeWhenCompiled(func: (effect: Effect) => void): void;
  29219. private _checkIsReady;
  29220. private _loadShader;
  29221. /**
  29222. * Recompiles the webGL program
  29223. * @param vertexSourceCode The source code for the vertex shader.
  29224. * @param fragmentSourceCode The source code for the fragment shader.
  29225. * @param onCompiled Callback called when completed.
  29226. * @param onError Callback called on error.
  29227. * @hidden
  29228. */
  29229. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29230. /**
  29231. * Prepares the effect
  29232. * @hidden
  29233. */
  29234. _prepareEffect(): void;
  29235. private _processCompilationErrors;
  29236. /**
  29237. * Checks if the effect is supported. (Must be called after compilation)
  29238. */
  29239. readonly isSupported: boolean;
  29240. /**
  29241. * Binds a texture to the engine to be used as output of the shader.
  29242. * @param channel Name of the output variable.
  29243. * @param texture Texture to bind.
  29244. * @hidden
  29245. */
  29246. _bindTexture(channel: string, texture: InternalTexture): void;
  29247. /**
  29248. * Sets a texture on the engine to be used in the shader.
  29249. * @param channel Name of the sampler variable.
  29250. * @param texture Texture to set.
  29251. */
  29252. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29253. /**
  29254. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29255. * @param channel Name of the sampler variable.
  29256. * @param texture Texture to set.
  29257. */
  29258. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29259. /**
  29260. * Sets an array of textures on the engine to be used in the shader.
  29261. * @param channel Name of the variable.
  29262. * @param textures Textures to set.
  29263. */
  29264. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29265. /**
  29266. * 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)
  29267. * @param channel Name of the sampler variable.
  29268. * @param postProcess Post process to get the input texture from.
  29269. */
  29270. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29271. /**
  29272. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29273. * 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)
  29274. * @param channel Name of the sampler variable.
  29275. * @param postProcess Post process to get the output texture from.
  29276. */
  29277. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29278. /** @hidden */
  29279. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29280. /** @hidden */
  29281. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29282. /** @hidden */
  29283. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29284. /** @hidden */
  29285. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29286. /**
  29287. * Binds a buffer to a uniform.
  29288. * @param buffer Buffer to bind.
  29289. * @param name Name of the uniform variable to bind to.
  29290. */
  29291. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29292. /**
  29293. * Binds block to a uniform.
  29294. * @param blockName Name of the block to bind.
  29295. * @param index Index to bind.
  29296. */
  29297. bindUniformBlock(blockName: string, index: number): void;
  29298. /**
  29299. * Sets an interger value on a uniform variable.
  29300. * @param uniformName Name of the variable.
  29301. * @param value Value to be set.
  29302. * @returns this effect.
  29303. */
  29304. setInt(uniformName: string, value: number): Effect;
  29305. /**
  29306. * Sets an int array on a uniform variable.
  29307. * @param uniformName Name of the variable.
  29308. * @param array array to be set.
  29309. * @returns this effect.
  29310. */
  29311. setIntArray(uniformName: string, array: Int32Array): Effect;
  29312. /**
  29313. * 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)
  29314. * @param uniformName Name of the variable.
  29315. * @param array array to be set.
  29316. * @returns this effect.
  29317. */
  29318. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29319. /**
  29320. * 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)
  29321. * @param uniformName Name of the variable.
  29322. * @param array array to be set.
  29323. * @returns this effect.
  29324. */
  29325. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29326. /**
  29327. * 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)
  29328. * @param uniformName Name of the variable.
  29329. * @param array array to be set.
  29330. * @returns this effect.
  29331. */
  29332. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29333. /**
  29334. * Sets an float array on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param array array to be set.
  29337. * @returns this effect.
  29338. */
  29339. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29340. /**
  29341. * 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)
  29342. * @param uniformName Name of the variable.
  29343. * @param array array to be set.
  29344. * @returns this effect.
  29345. */
  29346. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29347. /**
  29348. * 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)
  29349. * @param uniformName Name of the variable.
  29350. * @param array array to be set.
  29351. * @returns this effect.
  29352. */
  29353. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29354. /**
  29355. * 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)
  29356. * @param uniformName Name of the variable.
  29357. * @param array array to be set.
  29358. * @returns this effect.
  29359. */
  29360. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29361. /**
  29362. * Sets an array on a uniform variable.
  29363. * @param uniformName Name of the variable.
  29364. * @param array array to be set.
  29365. * @returns this effect.
  29366. */
  29367. setArray(uniformName: string, array: number[]): Effect;
  29368. /**
  29369. * 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)
  29370. * @param uniformName Name of the variable.
  29371. * @param array array to be set.
  29372. * @returns this effect.
  29373. */
  29374. setArray2(uniformName: string, array: number[]): Effect;
  29375. /**
  29376. * 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)
  29377. * @param uniformName Name of the variable.
  29378. * @param array array to be set.
  29379. * @returns this effect.
  29380. */
  29381. setArray3(uniformName: string, array: number[]): Effect;
  29382. /**
  29383. * 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)
  29384. * @param uniformName Name of the variable.
  29385. * @param array array to be set.
  29386. * @returns this effect.
  29387. */
  29388. setArray4(uniformName: string, array: number[]): Effect;
  29389. /**
  29390. * Sets matrices on a uniform variable.
  29391. * @param uniformName Name of the variable.
  29392. * @param matrices matrices to be set.
  29393. * @returns this effect.
  29394. */
  29395. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29396. /**
  29397. * Sets matrix on a uniform variable.
  29398. * @param uniformName Name of the variable.
  29399. * @param matrix matrix to be set.
  29400. * @returns this effect.
  29401. */
  29402. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29403. /**
  29404. * 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)
  29405. * @param uniformName Name of the variable.
  29406. * @param matrix matrix to be set.
  29407. * @returns this effect.
  29408. */
  29409. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29410. /**
  29411. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29412. * @param uniformName Name of the variable.
  29413. * @param matrix matrix to be set.
  29414. * @returns this effect.
  29415. */
  29416. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29417. /**
  29418. * Sets a float on a uniform variable.
  29419. * @param uniformName Name of the variable.
  29420. * @param value value to be set.
  29421. * @returns this effect.
  29422. */
  29423. setFloat(uniformName: string, value: number): Effect;
  29424. /**
  29425. * Sets a boolean on a uniform variable.
  29426. * @param uniformName Name of the variable.
  29427. * @param bool value to be set.
  29428. * @returns this effect.
  29429. */
  29430. setBool(uniformName: string, bool: boolean): Effect;
  29431. /**
  29432. * Sets a Vector2 on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param vector2 vector2 to be set.
  29435. * @returns this effect.
  29436. */
  29437. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29438. /**
  29439. * Sets a float2 on a uniform variable.
  29440. * @param uniformName Name of the variable.
  29441. * @param x First float in float2.
  29442. * @param y Second float in float2.
  29443. * @returns this effect.
  29444. */
  29445. setFloat2(uniformName: string, x: number, y: number): Effect;
  29446. /**
  29447. * Sets a Vector3 on a uniform variable.
  29448. * @param uniformName Name of the variable.
  29449. * @param vector3 Value to be set.
  29450. * @returns this effect.
  29451. */
  29452. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29453. /**
  29454. * Sets a float3 on a uniform variable.
  29455. * @param uniformName Name of the variable.
  29456. * @param x First float in float3.
  29457. * @param y Second float in float3.
  29458. * @param z Third float in float3.
  29459. * @returns this effect.
  29460. */
  29461. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29462. /**
  29463. * Sets a Vector4 on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param vector4 Value to be set.
  29466. * @returns this effect.
  29467. */
  29468. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29469. /**
  29470. * Sets a float4 on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param x First float in float4.
  29473. * @param y Second float in float4.
  29474. * @param z Third float in float4.
  29475. * @param w Fourth float in float4.
  29476. * @returns this effect.
  29477. */
  29478. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29479. /**
  29480. * Sets a Color3 on a uniform variable.
  29481. * @param uniformName Name of the variable.
  29482. * @param color3 Value to be set.
  29483. * @returns this effect.
  29484. */
  29485. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29486. /**
  29487. * Sets a Color4 on a uniform variable.
  29488. * @param uniformName Name of the variable.
  29489. * @param color3 Value to be set.
  29490. * @param alpha Alpha value to be set.
  29491. * @returns this effect.
  29492. */
  29493. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29494. /**
  29495. * Sets a Color4 on a uniform variable
  29496. * @param uniformName defines the name of the variable
  29497. * @param color4 defines the value to be set
  29498. * @returns this effect.
  29499. */
  29500. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29501. /** Release all associated resources */
  29502. dispose(): void;
  29503. /**
  29504. * This function will add a new shader to the shader store
  29505. * @param name the name of the shader
  29506. * @param pixelShader optional pixel shader content
  29507. * @param vertexShader optional vertex shader content
  29508. */
  29509. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29510. /**
  29511. * Store of each shader (The can be looked up using effect.key)
  29512. */
  29513. static ShadersStore: {
  29514. [key: string]: string;
  29515. };
  29516. /**
  29517. * Store of each included file for a shader (The can be looked up using effect.key)
  29518. */
  29519. static IncludesShadersStore: {
  29520. [key: string]: string;
  29521. };
  29522. /**
  29523. * Resets the cache of effects.
  29524. */
  29525. static ResetCache(): void;
  29526. }
  29527. }
  29528. declare module "babylonjs/Engines/engineCapabilities" {
  29529. /**
  29530. * Interface used to describe the capabilities of the engine relatively to the current browser
  29531. */
  29532. export interface EngineCapabilities {
  29533. /** Maximum textures units per fragment shader */
  29534. maxTexturesImageUnits: number;
  29535. /** Maximum texture units per vertex shader */
  29536. maxVertexTextureImageUnits: number;
  29537. /** Maximum textures units in the entire pipeline */
  29538. maxCombinedTexturesImageUnits: number;
  29539. /** Maximum texture size */
  29540. maxTextureSize: number;
  29541. /** Maximum cube texture size */
  29542. maxCubemapTextureSize: number;
  29543. /** Maximum render texture size */
  29544. maxRenderTextureSize: number;
  29545. /** Maximum number of vertex attributes */
  29546. maxVertexAttribs: number;
  29547. /** Maximum number of varyings */
  29548. maxVaryingVectors: number;
  29549. /** Maximum number of uniforms per vertex shader */
  29550. maxVertexUniformVectors: number;
  29551. /** Maximum number of uniforms per fragment shader */
  29552. maxFragmentUniformVectors: number;
  29553. /** Defines if standard derivates (dx/dy) are supported */
  29554. standardDerivatives: boolean;
  29555. /** Defines if s3tc texture compression is supported */
  29556. s3tc?: WEBGL_compressed_texture_s3tc;
  29557. /** Defines if pvrtc texture compression is supported */
  29558. pvrtc: any;
  29559. /** Defines if etc1 texture compression is supported */
  29560. etc1: any;
  29561. /** Defines if etc2 texture compression is supported */
  29562. etc2: any;
  29563. /** Defines if astc texture compression is supported */
  29564. astc: any;
  29565. /** Defines if float textures are supported */
  29566. textureFloat: boolean;
  29567. /** Defines if vertex array objects are supported */
  29568. vertexArrayObject: boolean;
  29569. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29570. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29571. /** Gets the maximum level of anisotropy supported */
  29572. maxAnisotropy: number;
  29573. /** Defines if instancing is supported */
  29574. instancedArrays: boolean;
  29575. /** Defines if 32 bits indices are supported */
  29576. uintIndices: boolean;
  29577. /** Defines if high precision shaders are supported */
  29578. highPrecisionShaderSupported: boolean;
  29579. /** Defines if depth reading in the fragment shader is supported */
  29580. fragmentDepthSupported: boolean;
  29581. /** Defines if float texture linear filtering is supported*/
  29582. textureFloatLinearFiltering: boolean;
  29583. /** Defines if rendering to float textures is supported */
  29584. textureFloatRender: boolean;
  29585. /** Defines if half float textures are supported*/
  29586. textureHalfFloat: boolean;
  29587. /** Defines if half float texture linear filtering is supported*/
  29588. textureHalfFloatLinearFiltering: boolean;
  29589. /** Defines if rendering to half float textures is supported */
  29590. textureHalfFloatRender: boolean;
  29591. /** Defines if textureLOD shader command is supported */
  29592. textureLOD: boolean;
  29593. /** Defines if draw buffers extension is supported */
  29594. drawBuffersExtension: boolean;
  29595. /** Defines if depth textures are supported */
  29596. depthTextureExtension: boolean;
  29597. /** Defines if float color buffer are supported */
  29598. colorBufferFloat: boolean;
  29599. /** Gets disjoint timer query extension (null if not supported) */
  29600. timerQuery?: EXT_disjoint_timer_query;
  29601. /** Defines if timestamp can be used with timer query */
  29602. canUseTimestampForTimerQuery: boolean;
  29603. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29604. multiview?: any;
  29605. /** Function used to let the system compiles shaders in background */
  29606. parallelShaderCompile?: {
  29607. COMPLETION_STATUS_KHR: number;
  29608. };
  29609. /** Max number of texture samples for MSAA */
  29610. maxMSAASamples: number;
  29611. /** Defines if the blend min max extension is supported */
  29612. blendMinMax: boolean;
  29613. }
  29614. }
  29615. declare module "babylonjs/States/depthCullingState" {
  29616. import { Nullable } from "babylonjs/types";
  29617. /**
  29618. * @hidden
  29619. **/
  29620. export class DepthCullingState {
  29621. private _isDepthTestDirty;
  29622. private _isDepthMaskDirty;
  29623. private _isDepthFuncDirty;
  29624. private _isCullFaceDirty;
  29625. private _isCullDirty;
  29626. private _isZOffsetDirty;
  29627. private _isFrontFaceDirty;
  29628. private _depthTest;
  29629. private _depthMask;
  29630. private _depthFunc;
  29631. private _cull;
  29632. private _cullFace;
  29633. private _zOffset;
  29634. private _frontFace;
  29635. /**
  29636. * Initializes the state.
  29637. */
  29638. constructor();
  29639. readonly isDirty: boolean;
  29640. zOffset: number;
  29641. cullFace: Nullable<number>;
  29642. cull: Nullable<boolean>;
  29643. depthFunc: Nullable<number>;
  29644. depthMask: boolean;
  29645. depthTest: boolean;
  29646. frontFace: Nullable<number>;
  29647. reset(): void;
  29648. apply(gl: WebGLRenderingContext): void;
  29649. }
  29650. }
  29651. declare module "babylonjs/States/stencilState" {
  29652. /**
  29653. * @hidden
  29654. **/
  29655. export class StencilState {
  29656. /** 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 */
  29657. static readonly ALWAYS: number;
  29658. /** Passed to stencilOperation to specify that stencil value must be kept */
  29659. static readonly KEEP: number;
  29660. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29661. static readonly REPLACE: number;
  29662. private _isStencilTestDirty;
  29663. private _isStencilMaskDirty;
  29664. private _isStencilFuncDirty;
  29665. private _isStencilOpDirty;
  29666. private _stencilTest;
  29667. private _stencilMask;
  29668. private _stencilFunc;
  29669. private _stencilFuncRef;
  29670. private _stencilFuncMask;
  29671. private _stencilOpStencilFail;
  29672. private _stencilOpDepthFail;
  29673. private _stencilOpStencilDepthPass;
  29674. readonly isDirty: boolean;
  29675. stencilFunc: number;
  29676. stencilFuncRef: number;
  29677. stencilFuncMask: number;
  29678. stencilOpStencilFail: number;
  29679. stencilOpDepthFail: number;
  29680. stencilOpStencilDepthPass: number;
  29681. stencilMask: number;
  29682. stencilTest: boolean;
  29683. constructor();
  29684. reset(): void;
  29685. apply(gl: WebGLRenderingContext): void;
  29686. }
  29687. }
  29688. declare module "babylonjs/States/alphaCullingState" {
  29689. /**
  29690. * @hidden
  29691. **/
  29692. export class AlphaState {
  29693. private _isAlphaBlendDirty;
  29694. private _isBlendFunctionParametersDirty;
  29695. private _isBlendEquationParametersDirty;
  29696. private _isBlendConstantsDirty;
  29697. private _alphaBlend;
  29698. private _blendFunctionParameters;
  29699. private _blendEquationParameters;
  29700. private _blendConstants;
  29701. /**
  29702. * Initializes the state.
  29703. */
  29704. constructor();
  29705. readonly isDirty: boolean;
  29706. alphaBlend: boolean;
  29707. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29708. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29709. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29710. reset(): void;
  29711. apply(gl: WebGLRenderingContext): void;
  29712. }
  29713. }
  29714. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29715. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29716. /** @hidden */
  29717. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29718. attributeProcessor(attribute: string): string;
  29719. varyingProcessor(varying: string, isFragment: boolean): string;
  29720. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29721. }
  29722. }
  29723. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29724. /**
  29725. * Interface for attribute information associated with buffer instanciation
  29726. */
  29727. export interface InstancingAttributeInfo {
  29728. /**
  29729. * Index/offset of the attribute in the vertex shader
  29730. */
  29731. index: number;
  29732. /**
  29733. * size of the attribute, 1, 2, 3 or 4
  29734. */
  29735. attributeSize: number;
  29736. /**
  29737. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29738. * default is FLOAT
  29739. */
  29740. attributeType: number;
  29741. /**
  29742. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29743. */
  29744. normalized: boolean;
  29745. /**
  29746. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29747. */
  29748. offset: number;
  29749. /**
  29750. * Name of the GLSL attribute, for debugging purpose only
  29751. */
  29752. attributeName: string;
  29753. }
  29754. }
  29755. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29757. import { Nullable } from "babylonjs/types";
  29758. module "babylonjs/Engines/thinEngine" {
  29759. interface ThinEngine {
  29760. /**
  29761. * Update a video texture
  29762. * @param texture defines the texture to update
  29763. * @param video defines the video element to use
  29764. * @param invertY defines if data must be stored with Y axis inverted
  29765. */
  29766. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29767. }
  29768. }
  29769. }
  29770. declare module "babylonjs/Materials/Textures/videoTexture" {
  29771. import { Observable } from "babylonjs/Misc/observable";
  29772. import { Nullable } from "babylonjs/types";
  29773. import { Scene } from "babylonjs/scene";
  29774. import { Texture } from "babylonjs/Materials/Textures/texture";
  29775. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29776. /**
  29777. * Settings for finer control over video usage
  29778. */
  29779. export interface VideoTextureSettings {
  29780. /**
  29781. * Applies `autoplay` to video, if specified
  29782. */
  29783. autoPlay?: boolean;
  29784. /**
  29785. * Applies `loop` to video, if specified
  29786. */
  29787. loop?: boolean;
  29788. /**
  29789. * Automatically updates internal texture from video at every frame in the render loop
  29790. */
  29791. autoUpdateTexture: boolean;
  29792. /**
  29793. * Image src displayed during the video loading or until the user interacts with the video.
  29794. */
  29795. poster?: string;
  29796. }
  29797. /**
  29798. * If you want to display a video in your scene, this is the special texture for that.
  29799. * This special texture works similar to other textures, with the exception of a few parameters.
  29800. * @see https://doc.babylonjs.com/how_to/video_texture
  29801. */
  29802. export class VideoTexture extends Texture {
  29803. /**
  29804. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29805. */
  29806. readonly autoUpdateTexture: boolean;
  29807. /**
  29808. * The video instance used by the texture internally
  29809. */
  29810. readonly video: HTMLVideoElement;
  29811. private _onUserActionRequestedObservable;
  29812. /**
  29813. * Event triggerd when a dom action is required by the user to play the video.
  29814. * This happens due to recent changes in browser policies preventing video to auto start.
  29815. */
  29816. readonly onUserActionRequestedObservable: Observable<Texture>;
  29817. private _generateMipMaps;
  29818. private _engine;
  29819. private _stillImageCaptured;
  29820. private _displayingPosterTexture;
  29821. private _settings;
  29822. private _createInternalTextureOnEvent;
  29823. private _frameId;
  29824. /**
  29825. * Creates a video texture.
  29826. * If you want to display a video in your scene, this is the special texture for that.
  29827. * This special texture works similar to other textures, with the exception of a few parameters.
  29828. * @see https://doc.babylonjs.com/how_to/video_texture
  29829. * @param name optional name, will detect from video source, if not defined
  29830. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29831. * @param scene is obviously the current scene.
  29832. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29833. * @param invertY is false by default but can be used to invert video on Y axis
  29834. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29835. * @param settings allows finer control over video usage
  29836. */
  29837. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29838. private _getName;
  29839. private _getVideo;
  29840. private _createInternalTexture;
  29841. private reset;
  29842. /**
  29843. * @hidden Internal method to initiate `update`.
  29844. */
  29845. _rebuild(): void;
  29846. /**
  29847. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29848. */
  29849. update(): void;
  29850. /**
  29851. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29852. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29853. */
  29854. updateTexture(isVisible: boolean): void;
  29855. protected _updateInternalTexture: () => void;
  29856. /**
  29857. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29858. * @param url New url.
  29859. */
  29860. updateURL(url: string): void;
  29861. /**
  29862. * Dispose the texture and release its associated resources.
  29863. */
  29864. dispose(): void;
  29865. /**
  29866. * Creates a video texture straight from a stream.
  29867. * @param scene Define the scene the texture should be created in
  29868. * @param stream Define the stream the texture should be created from
  29869. * @returns The created video texture as a promise
  29870. */
  29871. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29872. /**
  29873. * Creates a video texture straight from your WebCam video feed.
  29874. * @param scene Define the scene the texture should be created in
  29875. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29876. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29877. * @returns The created video texture as a promise
  29878. */
  29879. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29880. minWidth: number;
  29881. maxWidth: number;
  29882. minHeight: number;
  29883. maxHeight: number;
  29884. deviceId: string;
  29885. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29886. /**
  29887. * Creates a video texture straight from your WebCam video feed.
  29888. * @param scene Define the scene the texture should be created in
  29889. * @param onReady Define a callback to triggered once the texture will be ready
  29890. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29891. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29892. */
  29893. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29894. minWidth: number;
  29895. maxWidth: number;
  29896. minHeight: number;
  29897. maxHeight: number;
  29898. deviceId: string;
  29899. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29900. }
  29901. }
  29902. declare module "babylonjs/Engines/thinEngine" {
  29903. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29904. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29905. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29906. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29907. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29908. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29909. import { Observable } from "babylonjs/Misc/observable";
  29910. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29911. import { StencilState } from "babylonjs/States/stencilState";
  29912. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29914. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29915. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29916. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29917. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29918. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29919. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29920. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29922. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29923. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29924. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29925. /**
  29926. * Defines the interface used by objects working like Scene
  29927. * @hidden
  29928. */
  29929. interface ISceneLike {
  29930. _addPendingData(data: any): void;
  29931. _removePendingData(data: any): void;
  29932. offlineProvider: IOfflineProvider;
  29933. }
  29934. /** Interface defining initialization parameters for Engine class */
  29935. export interface EngineOptions extends WebGLContextAttributes {
  29936. /**
  29937. * Defines if the engine should no exceed a specified device ratio
  29938. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29939. */
  29940. limitDeviceRatio?: number;
  29941. /**
  29942. * Defines if webvr should be enabled automatically
  29943. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29944. */
  29945. autoEnableWebVR?: boolean;
  29946. /**
  29947. * Defines if webgl2 should be turned off even if supported
  29948. * @see http://doc.babylonjs.com/features/webgl2
  29949. */
  29950. disableWebGL2Support?: boolean;
  29951. /**
  29952. * Defines if webaudio should be initialized as well
  29953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29954. */
  29955. audioEngine?: boolean;
  29956. /**
  29957. * Defines if animations should run using a deterministic lock step
  29958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29959. */
  29960. deterministicLockstep?: boolean;
  29961. /** Defines the maximum steps to use with deterministic lock step mode */
  29962. lockstepMaxSteps?: number;
  29963. /**
  29964. * Defines that engine should ignore context lost events
  29965. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29966. */
  29967. doNotHandleContextLost?: boolean;
  29968. /**
  29969. * Defines that engine should ignore modifying touch action attribute and style
  29970. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29971. */
  29972. doNotHandleTouchAction?: boolean;
  29973. /**
  29974. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29975. */
  29976. useHighPrecisionFloats?: boolean;
  29977. }
  29978. /**
  29979. * The base engine class (root of all engines)
  29980. */
  29981. export class ThinEngine {
  29982. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29983. static ExceptionList: ({
  29984. key: string;
  29985. capture: string;
  29986. captureConstraint: number;
  29987. targets: string[];
  29988. } | {
  29989. key: string;
  29990. capture: null;
  29991. captureConstraint: null;
  29992. targets: string[];
  29993. })[];
  29994. /** @hidden */
  29995. static _TextureLoaders: IInternalTextureLoader[];
  29996. /**
  29997. * Returns the current npm package of the sdk
  29998. */
  29999. static readonly NpmPackage: string;
  30000. /**
  30001. * Returns the current version of the framework
  30002. */
  30003. static readonly Version: string;
  30004. /**
  30005. * Returns a string describing the current engine
  30006. */
  30007. readonly description: string;
  30008. /**
  30009. * Gets or sets the epsilon value used by collision engine
  30010. */
  30011. static CollisionsEpsilon: number;
  30012. /**
  30013. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30014. */
  30015. static ShadersRepository: string;
  30016. /** @hidden */
  30017. _shaderProcessor: IShaderProcessor;
  30018. /**
  30019. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30020. */
  30021. forcePOTTextures: boolean;
  30022. /**
  30023. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30024. */
  30025. isFullscreen: boolean;
  30026. /**
  30027. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30028. */
  30029. cullBackFaces: boolean;
  30030. /**
  30031. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30032. */
  30033. renderEvenInBackground: boolean;
  30034. /**
  30035. * Gets or sets a boolean indicating that cache can be kept between frames
  30036. */
  30037. preventCacheWipeBetweenFrames: boolean;
  30038. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30039. validateShaderPrograms: boolean;
  30040. /**
  30041. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30042. */
  30043. disableUniformBuffers: boolean;
  30044. /** @hidden */
  30045. _uniformBuffers: UniformBuffer[];
  30046. /**
  30047. * Gets a boolean indicating that the engine supports uniform buffers
  30048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30049. */
  30050. readonly supportsUniformBuffers: boolean;
  30051. /** @hidden */
  30052. _gl: WebGLRenderingContext;
  30053. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30054. protected _windowIsBackground: boolean;
  30055. protected _webGLVersion: number;
  30056. protected _creationOptions: EngineOptions;
  30057. protected _highPrecisionShadersAllowed: boolean;
  30058. /** @hidden */
  30059. readonly _shouldUseHighPrecisionShader: boolean;
  30060. /**
  30061. * Gets a boolean indicating that only power of 2 textures are supported
  30062. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30063. */
  30064. readonly needPOTTextures: boolean;
  30065. /** @hidden */
  30066. _badOS: boolean;
  30067. /** @hidden */
  30068. _badDesktopOS: boolean;
  30069. private _hardwareScalingLevel;
  30070. /** @hidden */
  30071. _caps: EngineCapabilities;
  30072. private _isStencilEnable;
  30073. protected _colorWrite: boolean;
  30074. private _glVersion;
  30075. private _glRenderer;
  30076. private _glVendor;
  30077. /** @hidden */
  30078. _videoTextureSupported: boolean;
  30079. protected _renderingQueueLaunched: boolean;
  30080. protected _activeRenderLoops: (() => void)[];
  30081. /**
  30082. * Observable signaled when a context lost event is raised
  30083. */
  30084. onContextLostObservable: Observable<ThinEngine>;
  30085. /**
  30086. * Observable signaled when a context restored event is raised
  30087. */
  30088. onContextRestoredObservable: Observable<ThinEngine>;
  30089. private _onContextLost;
  30090. private _onContextRestored;
  30091. protected _contextWasLost: boolean;
  30092. /** @hidden */
  30093. _doNotHandleContextLost: boolean;
  30094. /**
  30095. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30097. */
  30098. doNotHandleContextLost: boolean;
  30099. /**
  30100. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30101. */
  30102. disableVertexArrayObjects: boolean;
  30103. /** @hidden */
  30104. protected _depthCullingState: DepthCullingState;
  30105. /** @hidden */
  30106. protected _stencilState: StencilState;
  30107. /** @hidden */
  30108. protected _alphaState: AlphaState;
  30109. /** @hidden */
  30110. _internalTexturesCache: InternalTexture[];
  30111. /** @hidden */
  30112. protected _activeChannel: number;
  30113. private _currentTextureChannel;
  30114. /** @hidden */
  30115. protected _boundTexturesCache: {
  30116. [key: string]: Nullable<InternalTexture>;
  30117. };
  30118. /** @hidden */
  30119. protected _currentEffect: Nullable<Effect>;
  30120. /** @hidden */
  30121. protected _currentProgram: Nullable<WebGLProgram>;
  30122. private _compiledEffects;
  30123. private _vertexAttribArraysEnabled;
  30124. /** @hidden */
  30125. protected _cachedViewport: Nullable<IViewportLike>;
  30126. private _cachedVertexArrayObject;
  30127. /** @hidden */
  30128. protected _cachedVertexBuffers: any;
  30129. /** @hidden */
  30130. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30131. /** @hidden */
  30132. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30133. /** @hidden */
  30134. _currentRenderTarget: Nullable<InternalTexture>;
  30135. private _uintIndicesCurrentlySet;
  30136. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30137. /** @hidden */
  30138. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30139. private _currentBufferPointers;
  30140. private _currentInstanceLocations;
  30141. private _currentInstanceBuffers;
  30142. private _textureUnits;
  30143. /** @hidden */
  30144. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30145. /** @hidden */
  30146. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30147. /** @hidden */
  30148. _boundRenderFunction: any;
  30149. private _vaoRecordInProgress;
  30150. private _mustWipeVertexAttributes;
  30151. private _emptyTexture;
  30152. private _emptyCubeTexture;
  30153. private _emptyTexture3D;
  30154. /** @hidden */
  30155. _frameHandler: number;
  30156. private _nextFreeTextureSlots;
  30157. private _maxSimultaneousTextures;
  30158. private _activeRequests;
  30159. protected _texturesSupported: string[];
  30160. /** @hidden */
  30161. _textureFormatInUse: Nullable<string>;
  30162. protected readonly _supportsHardwareTextureRescaling: boolean;
  30163. /**
  30164. * Gets the list of texture formats supported
  30165. */
  30166. readonly texturesSupported: Array<string>;
  30167. /**
  30168. * Gets the list of texture formats in use
  30169. */
  30170. readonly textureFormatInUse: Nullable<string>;
  30171. /**
  30172. * Gets the current viewport
  30173. */
  30174. readonly currentViewport: Nullable<IViewportLike>;
  30175. /**
  30176. * Gets the default empty texture
  30177. */
  30178. readonly emptyTexture: InternalTexture;
  30179. /**
  30180. * Gets the default empty 3D texture
  30181. */
  30182. readonly emptyTexture3D: InternalTexture;
  30183. /**
  30184. * Gets the default empty cube texture
  30185. */
  30186. readonly emptyCubeTexture: InternalTexture;
  30187. /**
  30188. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30189. */
  30190. readonly premultipliedAlpha: boolean;
  30191. /**
  30192. * Observable event triggered before each texture is initialized
  30193. */
  30194. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30195. /**
  30196. * Creates a new engine
  30197. * @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
  30198. * @param antialias defines enable antialiasing (default: false)
  30199. * @param options defines further options to be sent to the getContext() function
  30200. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30201. */
  30202. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30203. private _rebuildInternalTextures;
  30204. private _rebuildEffects;
  30205. /**
  30206. * Gets a boolean indicating if all created effects are ready
  30207. * @returns true if all effects are ready
  30208. */
  30209. areAllEffectsReady(): boolean;
  30210. protected _rebuildBuffers(): void;
  30211. private _initGLContext;
  30212. /**
  30213. * Gets version of the current webGL context
  30214. */
  30215. readonly webGLVersion: number;
  30216. /**
  30217. * Gets a string idenfifying the name of the class
  30218. * @returns "Engine" string
  30219. */
  30220. getClassName(): string;
  30221. /**
  30222. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30223. */
  30224. readonly isStencilEnable: boolean;
  30225. /** @hidden */
  30226. _prepareWorkingCanvas(): void;
  30227. /**
  30228. * Reset the texture cache to empty state
  30229. */
  30230. resetTextureCache(): void;
  30231. /**
  30232. * Gets an object containing information about the current webGL context
  30233. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30234. */
  30235. getGlInfo(): {
  30236. vendor: string;
  30237. renderer: string;
  30238. version: string;
  30239. };
  30240. /**
  30241. * Defines the hardware scaling level.
  30242. * By default the hardware scaling level is computed from the window device ratio.
  30243. * 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.
  30244. * @param level defines the level to use
  30245. */
  30246. setHardwareScalingLevel(level: number): void;
  30247. /**
  30248. * Gets the current hardware scaling level.
  30249. * By default the hardware scaling level is computed from the window device ratio.
  30250. * 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.
  30251. * @returns a number indicating the current hardware scaling level
  30252. */
  30253. getHardwareScalingLevel(): number;
  30254. /**
  30255. * Gets the list of loaded textures
  30256. * @returns an array containing all loaded textures
  30257. */
  30258. getLoadedTexturesCache(): InternalTexture[];
  30259. /**
  30260. * Gets the object containing all engine capabilities
  30261. * @returns the EngineCapabilities object
  30262. */
  30263. getCaps(): EngineCapabilities;
  30264. /**
  30265. * stop executing a render loop function and remove it from the execution array
  30266. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30267. */
  30268. stopRenderLoop(renderFunction?: () => void): void;
  30269. /** @hidden */
  30270. _renderLoop(): void;
  30271. /**
  30272. * Gets the HTML canvas attached with the current webGL context
  30273. * @returns a HTML canvas
  30274. */
  30275. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30276. /**
  30277. * Gets host window
  30278. * @returns the host window object
  30279. */
  30280. getHostWindow(): Nullable<Window>;
  30281. /**
  30282. * Gets the current render width
  30283. * @param useScreen defines if screen size must be used (or the current render target if any)
  30284. * @returns a number defining the current render width
  30285. */
  30286. getRenderWidth(useScreen?: boolean): number;
  30287. /**
  30288. * Gets the current render height
  30289. * @param useScreen defines if screen size must be used (or the current render target if any)
  30290. * @returns a number defining the current render height
  30291. */
  30292. getRenderHeight(useScreen?: boolean): number;
  30293. /**
  30294. * Can be used to override the current requestAnimationFrame requester.
  30295. * @hidden
  30296. */
  30297. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30298. /**
  30299. * Register and execute a render loop. The engine can have more than one render function
  30300. * @param renderFunction defines the function to continuously execute
  30301. */
  30302. runRenderLoop(renderFunction: () => void): void;
  30303. /**
  30304. * Clear the current render buffer or the current render target (if any is set up)
  30305. * @param color defines the color to use
  30306. * @param backBuffer defines if the back buffer must be cleared
  30307. * @param depth defines if the depth buffer must be cleared
  30308. * @param stencil defines if the stencil buffer must be cleared
  30309. */
  30310. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30311. private _viewportCached;
  30312. /** @hidden */
  30313. _viewport(x: number, y: number, width: number, height: number): void;
  30314. /**
  30315. * Set the WebGL's viewport
  30316. * @param viewport defines the viewport element to be used
  30317. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30318. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30319. */
  30320. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30321. /**
  30322. * Begin a new frame
  30323. */
  30324. beginFrame(): void;
  30325. /**
  30326. * Enf the current frame
  30327. */
  30328. endFrame(): void;
  30329. /**
  30330. * Resize the view according to the canvas' size
  30331. */
  30332. resize(): void;
  30333. /**
  30334. * Force a specific size of the canvas
  30335. * @param width defines the new canvas' width
  30336. * @param height defines the new canvas' height
  30337. */
  30338. setSize(width: number, height: number): void;
  30339. /**
  30340. * Binds the frame buffer to the specified texture.
  30341. * @param texture The texture to render to or null for the default canvas
  30342. * @param faceIndex The face of the texture to render to in case of cube texture
  30343. * @param requiredWidth The width of the target to render to
  30344. * @param requiredHeight The height of the target to render to
  30345. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30346. * @param depthStencilTexture The depth stencil texture to use to render
  30347. * @param lodLevel defines le lod level to bind to the frame buffer
  30348. */
  30349. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30350. /** @hidden */
  30351. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30352. /**
  30353. * Unbind the current render target texture from the webGL context
  30354. * @param texture defines the render target texture to unbind
  30355. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30356. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30357. */
  30358. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30359. /**
  30360. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30361. */
  30362. flushFramebuffer(): void;
  30363. /**
  30364. * Unbind the current render target and bind the default framebuffer
  30365. */
  30366. restoreDefaultFramebuffer(): void;
  30367. /** @hidden */
  30368. protected _resetVertexBufferBinding(): void;
  30369. /**
  30370. * Creates a vertex buffer
  30371. * @param data the data for the vertex buffer
  30372. * @returns the new WebGL static buffer
  30373. */
  30374. createVertexBuffer(data: DataArray): DataBuffer;
  30375. private _createVertexBuffer;
  30376. /**
  30377. * Creates a dynamic vertex buffer
  30378. * @param data the data for the dynamic vertex buffer
  30379. * @returns the new WebGL dynamic buffer
  30380. */
  30381. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30382. protected _resetIndexBufferBinding(): void;
  30383. /**
  30384. * Creates a new index buffer
  30385. * @param indices defines the content of the index buffer
  30386. * @param updatable defines if the index buffer must be updatable
  30387. * @returns a new webGL buffer
  30388. */
  30389. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30390. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30391. /**
  30392. * Bind a webGL buffer to the webGL context
  30393. * @param buffer defines the buffer to bind
  30394. */
  30395. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30396. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30397. private bindBuffer;
  30398. /**
  30399. * update the bound buffer with the given data
  30400. * @param data defines the data to update
  30401. */
  30402. updateArrayBuffer(data: Float32Array): void;
  30403. private _vertexAttribPointer;
  30404. private _bindIndexBufferWithCache;
  30405. private _bindVertexBuffersAttributes;
  30406. /**
  30407. * Records a vertex array object
  30408. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30409. * @param vertexBuffers defines the list of vertex buffers to store
  30410. * @param indexBuffer defines the index buffer to store
  30411. * @param effect defines the effect to store
  30412. * @returns the new vertex array object
  30413. */
  30414. recordVertexArrayObject(vertexBuffers: {
  30415. [key: string]: VertexBuffer;
  30416. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30417. /**
  30418. * Bind a specific vertex array object
  30419. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30420. * @param vertexArrayObject defines the vertex array object to bind
  30421. * @param indexBuffer defines the index buffer to bind
  30422. */
  30423. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30424. /**
  30425. * Bind webGl buffers directly to the webGL context
  30426. * @param vertexBuffer defines the vertex buffer to bind
  30427. * @param indexBuffer defines the index buffer to bind
  30428. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30429. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30430. * @param effect defines the effect associated with the vertex buffer
  30431. */
  30432. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30433. private _unbindVertexArrayObject;
  30434. /**
  30435. * Bind a list of vertex buffers to the webGL context
  30436. * @param vertexBuffers defines the list of vertex buffers to bind
  30437. * @param indexBuffer defines the index buffer to bind
  30438. * @param effect defines the effect associated with the vertex buffers
  30439. */
  30440. bindBuffers(vertexBuffers: {
  30441. [key: string]: Nullable<VertexBuffer>;
  30442. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30443. /**
  30444. * Unbind all instance attributes
  30445. */
  30446. unbindInstanceAttributes(): void;
  30447. /**
  30448. * Release and free the memory of a vertex array object
  30449. * @param vao defines the vertex array object to delete
  30450. */
  30451. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30452. /** @hidden */
  30453. _releaseBuffer(buffer: DataBuffer): boolean;
  30454. protected _deleteBuffer(buffer: DataBuffer): void;
  30455. /**
  30456. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30457. * @param instancesBuffer defines the webGL buffer to update and bind
  30458. * @param data defines the data to store in the buffer
  30459. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30460. */
  30461. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30462. /**
  30463. * Apply all cached states (depth, culling, stencil and alpha)
  30464. */
  30465. applyStates(): void;
  30466. /**
  30467. * Send a draw order
  30468. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30469. * @param indexStart defines the starting index
  30470. * @param indexCount defines the number of index to draw
  30471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30472. */
  30473. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30474. /**
  30475. * Draw a list of points
  30476. * @param verticesStart defines the index of first vertex to draw
  30477. * @param verticesCount defines the count of vertices to draw
  30478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30479. */
  30480. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30481. /**
  30482. * Draw a list of unindexed primitives
  30483. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30484. * @param verticesStart defines the index of first vertex to draw
  30485. * @param verticesCount defines the count of vertices to draw
  30486. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30487. */
  30488. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30489. /**
  30490. * Draw a list of indexed primitives
  30491. * @param fillMode defines the primitive to use
  30492. * @param indexStart defines the starting index
  30493. * @param indexCount defines the number of index to draw
  30494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30495. */
  30496. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30497. /**
  30498. * Draw a list of unindexed primitives
  30499. * @param fillMode defines the primitive to use
  30500. * @param verticesStart defines the index of first vertex to draw
  30501. * @param verticesCount defines the count of vertices to draw
  30502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30503. */
  30504. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30505. private _drawMode;
  30506. /** @hidden */
  30507. protected _reportDrawCall(): void;
  30508. /** @hidden */
  30509. _releaseEffect(effect: Effect): void;
  30510. /** @hidden */
  30511. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30512. /**
  30513. * Create a new effect (used to store vertex/fragment shaders)
  30514. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30515. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30516. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30517. * @param samplers defines an array of string used to represent textures
  30518. * @param defines defines the string containing the defines to use to compile the shaders
  30519. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30520. * @param onCompiled defines a function to call when the effect creation is successful
  30521. * @param onError defines a function to call when the effect creation has failed
  30522. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30523. * @returns the new Effect
  30524. */
  30525. 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;
  30526. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30527. private _compileShader;
  30528. private _compileRawShader;
  30529. /**
  30530. * Directly creates a webGL program
  30531. * @param pipelineContext defines the pipeline context to attach to
  30532. * @param vertexCode defines the vertex shader code to use
  30533. * @param fragmentCode defines the fragment shader code to use
  30534. * @param context defines the webGL context to use (if not set, the current one will be used)
  30535. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30536. * @returns the new webGL program
  30537. */
  30538. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30539. /**
  30540. * Creates a webGL program
  30541. * @param pipelineContext defines the pipeline context to attach to
  30542. * @param vertexCode defines the vertex shader code to use
  30543. * @param fragmentCode defines the fragment shader code to use
  30544. * @param defines defines the string containing the defines to use to compile the shaders
  30545. * @param context defines the webGL context to use (if not set, the current one will be used)
  30546. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30547. * @returns the new webGL program
  30548. */
  30549. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30550. /**
  30551. * Creates a new pipeline context
  30552. * @returns the new pipeline
  30553. */
  30554. createPipelineContext(): IPipelineContext;
  30555. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30556. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30557. /** @hidden */
  30558. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30559. /** @hidden */
  30560. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30561. /** @hidden */
  30562. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30563. /**
  30564. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30565. * @param pipelineContext defines the pipeline context to use
  30566. * @param uniformsNames defines the list of uniform names
  30567. * @returns an array of webGL uniform locations
  30568. */
  30569. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30570. /**
  30571. * Gets the lsit of active attributes for a given webGL program
  30572. * @param pipelineContext defines the pipeline context to use
  30573. * @param attributesNames defines the list of attribute names to get
  30574. * @returns an array of indices indicating the offset of each attribute
  30575. */
  30576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30577. /**
  30578. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30579. * @param effect defines the effect to activate
  30580. */
  30581. enableEffect(effect: Nullable<Effect>): void;
  30582. /**
  30583. * Set the value of an uniform to a number (int)
  30584. * @param uniform defines the webGL uniform location where to store the value
  30585. * @param value defines the int number to store
  30586. */
  30587. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30588. /**
  30589. * Set the value of an uniform to an array of int32
  30590. * @param uniform defines the webGL uniform location where to store the value
  30591. * @param array defines the array of int32 to store
  30592. */
  30593. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30594. /**
  30595. * Set the value of an uniform to an array of int32 (stored as vec2)
  30596. * @param uniform defines the webGL uniform location where to store the value
  30597. * @param array defines the array of int32 to store
  30598. */
  30599. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30600. /**
  30601. * Set the value of an uniform to an array of int32 (stored as vec3)
  30602. * @param uniform defines the webGL uniform location where to store the value
  30603. * @param array defines the array of int32 to store
  30604. */
  30605. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30606. /**
  30607. * Set the value of an uniform to an array of int32 (stored as vec4)
  30608. * @param uniform defines the webGL uniform location where to store the value
  30609. * @param array defines the array of int32 to store
  30610. */
  30611. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30612. /**
  30613. * Set the value of an uniform to an array of number
  30614. * @param uniform defines the webGL uniform location where to store the value
  30615. * @param array defines the array of number to store
  30616. */
  30617. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30618. /**
  30619. * Set the value of an uniform to an array of number (stored as vec2)
  30620. * @param uniform defines the webGL uniform location where to store the value
  30621. * @param array defines the array of number to store
  30622. */
  30623. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30624. /**
  30625. * Set the value of an uniform to an array of number (stored as vec3)
  30626. * @param uniform defines the webGL uniform location where to store the value
  30627. * @param array defines the array of number to store
  30628. */
  30629. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30630. /**
  30631. * Set the value of an uniform to an array of number (stored as vec4)
  30632. * @param uniform defines the webGL uniform location where to store the value
  30633. * @param array defines the array of number to store
  30634. */
  30635. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30636. /**
  30637. * Set the value of an uniform to an array of float32 (stored as matrices)
  30638. * @param uniform defines the webGL uniform location where to store the value
  30639. * @param matrices defines the array of float32 to store
  30640. */
  30641. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30642. /**
  30643. * Set the value of an uniform to a matrix (3x3)
  30644. * @param uniform defines the webGL uniform location where to store the value
  30645. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30646. */
  30647. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30648. /**
  30649. * Set the value of an uniform to a matrix (2x2)
  30650. * @param uniform defines the webGL uniform location where to store the value
  30651. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30652. */
  30653. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30654. /**
  30655. * Set the value of an uniform to a number (float)
  30656. * @param uniform defines the webGL uniform location where to store the value
  30657. * @param value defines the float number to store
  30658. */
  30659. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30660. /**
  30661. * Set the value of an uniform to a vec2
  30662. * @param uniform defines the webGL uniform location where to store the value
  30663. * @param x defines the 1st component of the value
  30664. * @param y defines the 2nd component of the value
  30665. */
  30666. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30667. /**
  30668. * Set the value of an uniform to a vec3
  30669. * @param uniform defines the webGL uniform location where to store the value
  30670. * @param x defines the 1st component of the value
  30671. * @param y defines the 2nd component of the value
  30672. * @param z defines the 3rd component of the value
  30673. */
  30674. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30675. /**
  30676. * Set the value of an uniform to a vec4
  30677. * @param uniform defines the webGL uniform location where to store the value
  30678. * @param x defines the 1st component of the value
  30679. * @param y defines the 2nd component of the value
  30680. * @param z defines the 3rd component of the value
  30681. * @param w defines the 4th component of the value
  30682. */
  30683. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30684. /**
  30685. * Gets the depth culling state manager
  30686. */
  30687. readonly depthCullingState: DepthCullingState;
  30688. /**
  30689. * Gets the alpha state manager
  30690. */
  30691. readonly alphaState: AlphaState;
  30692. /**
  30693. * Gets the stencil state manager
  30694. */
  30695. readonly stencilState: StencilState;
  30696. /**
  30697. * Clears the list of texture accessible through engine.
  30698. * This can help preventing texture load conflict due to name collision.
  30699. */
  30700. clearInternalTexturesCache(): void;
  30701. /**
  30702. * Force the entire cache to be cleared
  30703. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30704. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30705. */
  30706. wipeCaches(bruteForce?: boolean): void;
  30707. /** @hidden */
  30708. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30709. min: number;
  30710. mag: number;
  30711. };
  30712. /** @hidden */
  30713. _createTexture(): WebGLTexture;
  30714. /**
  30715. * Usually called from Texture.ts.
  30716. * Passed information to create a WebGLTexture
  30717. * @param urlArg defines a value which contains one of the following:
  30718. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30719. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30720. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30721. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30722. * @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)
  30723. * @param scene needed for loading to the correct scene
  30724. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30725. * @param onLoad optional callback to be called upon successful completion
  30726. * @param onError optional callback to be called upon failure
  30727. * @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
  30728. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30729. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30730. * @param forcedExtension defines the extension to use to pick the right loader
  30731. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30732. * @param mimeType defines an optional mime type
  30733. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30734. */
  30735. 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;
  30736. /**
  30737. * @hidden
  30738. */
  30739. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30740. /**
  30741. * Creates a raw texture
  30742. * @param data defines the data to store in the texture
  30743. * @param width defines the width of the texture
  30744. * @param height defines the height of the texture
  30745. * @param format defines the format of the data
  30746. * @param generateMipMaps defines if the engine should generate the mip levels
  30747. * @param invertY defines if data must be stored with Y axis inverted
  30748. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30749. * @param compression defines the compression used (null by default)
  30750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30751. * @returns the raw texture inside an InternalTexture
  30752. */
  30753. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30754. /**
  30755. * Creates a new raw cube texture
  30756. * @param data defines the array of data to use to create each face
  30757. * @param size defines the size of the textures
  30758. * @param format defines the format of the data
  30759. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30760. * @param generateMipMaps defines if the engine should generate the mip levels
  30761. * @param invertY defines if data must be stored with Y axis inverted
  30762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30763. * @param compression defines the compression used (null by default)
  30764. * @returns the cube texture as an InternalTexture
  30765. */
  30766. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30767. /**
  30768. * Creates a new raw 3D texture
  30769. * @param data defines the data used to create the texture
  30770. * @param width defines the width of the texture
  30771. * @param height defines the height of the texture
  30772. * @param depth defines the depth of the texture
  30773. * @param format defines the format of the texture
  30774. * @param generateMipMaps defines if the engine must generate mip levels
  30775. * @param invertY defines if data must be stored with Y axis inverted
  30776. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30777. * @param compression defines the compressed used (can be null)
  30778. * @param textureType defines the compressed used (can be null)
  30779. * @returns a new raw 3D texture (stored in an InternalTexture)
  30780. */
  30781. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30782. private _unpackFlipYCached;
  30783. /**
  30784. * In case you are sharing the context with other applications, it might
  30785. * be interested to not cache the unpack flip y state to ensure a consistent
  30786. * value would be set.
  30787. */
  30788. enableUnpackFlipYCached: boolean;
  30789. /** @hidden */
  30790. _unpackFlipY(value: boolean): void;
  30791. /** @hidden */
  30792. _getUnpackAlignement(): number;
  30793. /**
  30794. * Update the sampling mode of a given texture
  30795. * @param samplingMode defines the required sampling mode
  30796. * @param texture defines the texture to update
  30797. */
  30798. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30799. /** @hidden */
  30800. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30801. width: number;
  30802. height: number;
  30803. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30804. /** @hidden */
  30805. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30806. /** @hidden */
  30807. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30808. /** @hidden */
  30809. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30810. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30811. private _prepareWebGLTexture;
  30812. /** @hidden */
  30813. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30814. /** @hidden */
  30815. _releaseFramebufferObjects(texture: InternalTexture): void;
  30816. /** @hidden */
  30817. _releaseTexture(texture: InternalTexture): void;
  30818. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30819. protected _setProgram(program: WebGLProgram): void;
  30820. protected _boundUniforms: {
  30821. [key: number]: WebGLUniformLocation;
  30822. };
  30823. /**
  30824. * Binds an effect to the webGL context
  30825. * @param effect defines the effect to bind
  30826. */
  30827. bindSamplers(effect: Effect): void;
  30828. private _activateCurrentTexture;
  30829. /** @hidden */
  30830. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30831. /** @hidden */
  30832. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30833. /**
  30834. * Unbind all textures from the webGL context
  30835. */
  30836. unbindAllTextures(): void;
  30837. /**
  30838. * Sets a texture to the according uniform.
  30839. * @param channel The texture channel
  30840. * @param uniform The uniform to set
  30841. * @param texture The texture to apply
  30842. */
  30843. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30844. private _bindSamplerUniformToChannel;
  30845. private _getTextureWrapMode;
  30846. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30847. /**
  30848. * Sets an array of texture to the webGL context
  30849. * @param channel defines the channel where the texture array must be set
  30850. * @param uniform defines the associated uniform location
  30851. * @param textures defines the array of textures to bind
  30852. */
  30853. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30854. /** @hidden */
  30855. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30856. private _setTextureParameterFloat;
  30857. private _setTextureParameterInteger;
  30858. /**
  30859. * Unbind all vertex attributes from the webGL context
  30860. */
  30861. unbindAllAttributes(): void;
  30862. /**
  30863. * 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
  30864. */
  30865. releaseEffects(): void;
  30866. /**
  30867. * Dispose and release all associated resources
  30868. */
  30869. dispose(): void;
  30870. /**
  30871. * Attach a new callback raised when context lost event is fired
  30872. * @param callback defines the callback to call
  30873. */
  30874. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30875. /**
  30876. * Attach a new callback raised when context restored event is fired
  30877. * @param callback defines the callback to call
  30878. */
  30879. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30880. /**
  30881. * Get the current error code of the webGL context
  30882. * @returns the error code
  30883. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30884. */
  30885. getError(): number;
  30886. private _canRenderToFloatFramebuffer;
  30887. private _canRenderToHalfFloatFramebuffer;
  30888. private _canRenderToFramebuffer;
  30889. /** @hidden */
  30890. _getWebGLTextureType(type: number): number;
  30891. /** @hidden */
  30892. _getInternalFormat(format: number): number;
  30893. /** @hidden */
  30894. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30895. /** @hidden */
  30896. _getRGBAMultiSampleBufferFormat(type: number): number;
  30897. /** @hidden */
  30898. _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;
  30899. /**
  30900. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30901. * @returns true if the engine can be created
  30902. * @ignorenaming
  30903. */
  30904. static isSupported(): boolean;
  30905. /**
  30906. * Find the next highest power of two.
  30907. * @param x Number to start search from.
  30908. * @return Next highest power of two.
  30909. */
  30910. static CeilingPOT(x: number): number;
  30911. /**
  30912. * Find the next lowest power of two.
  30913. * @param x Number to start search from.
  30914. * @return Next lowest power of two.
  30915. */
  30916. static FloorPOT(x: number): number;
  30917. /**
  30918. * Find the nearest power of two.
  30919. * @param x Number to start search from.
  30920. * @return Next nearest power of two.
  30921. */
  30922. static NearestPOT(x: number): number;
  30923. /**
  30924. * Get the closest exponent of two
  30925. * @param value defines the value to approximate
  30926. * @param max defines the maximum value to return
  30927. * @param mode defines how to define the closest value
  30928. * @returns closest exponent of two of the given value
  30929. */
  30930. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30931. /**
  30932. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30933. * @param func - the function to be called
  30934. * @param requester - the object that will request the next frame. Falls back to window.
  30935. * @returns frame number
  30936. */
  30937. static QueueNewFrame(func: () => void, requester?: any): number;
  30938. }
  30939. }
  30940. declare module "babylonjs/Maths/sphericalPolynomial" {
  30941. import { Vector3 } from "babylonjs/Maths/math.vector";
  30942. import { Color3 } from "babylonjs/Maths/math.color";
  30943. /**
  30944. * Class representing spherical harmonics coefficients to the 3rd degree
  30945. */
  30946. export class SphericalHarmonics {
  30947. /**
  30948. * Defines whether or not the harmonics have been prescaled for rendering.
  30949. */
  30950. preScaled: boolean;
  30951. /**
  30952. * The l0,0 coefficients of the spherical harmonics
  30953. */
  30954. l00: Vector3;
  30955. /**
  30956. * The l1,-1 coefficients of the spherical harmonics
  30957. */
  30958. l1_1: Vector3;
  30959. /**
  30960. * The l1,0 coefficients of the spherical harmonics
  30961. */
  30962. l10: Vector3;
  30963. /**
  30964. * The l1,1 coefficients of the spherical harmonics
  30965. */
  30966. l11: Vector3;
  30967. /**
  30968. * The l2,-2 coefficients of the spherical harmonics
  30969. */
  30970. l2_2: Vector3;
  30971. /**
  30972. * The l2,-1 coefficients of the spherical harmonics
  30973. */
  30974. l2_1: Vector3;
  30975. /**
  30976. * The l2,0 coefficients of the spherical harmonics
  30977. */
  30978. l20: Vector3;
  30979. /**
  30980. * The l2,1 coefficients of the spherical harmonics
  30981. */
  30982. l21: Vector3;
  30983. /**
  30984. * The l2,2 coefficients of the spherical harmonics
  30985. */
  30986. l22: Vector3;
  30987. /**
  30988. * Adds a light to the spherical harmonics
  30989. * @param direction the direction of the light
  30990. * @param color the color of the light
  30991. * @param deltaSolidAngle the delta solid angle of the light
  30992. */
  30993. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30994. /**
  30995. * Scales the spherical harmonics by the given amount
  30996. * @param scale the amount to scale
  30997. */
  30998. scaleInPlace(scale: number): void;
  30999. /**
  31000. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31001. *
  31002. * ```
  31003. * E_lm = A_l * L_lm
  31004. * ```
  31005. *
  31006. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31007. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31008. * the scaling factors are given in equation 9.
  31009. */
  31010. convertIncidentRadianceToIrradiance(): void;
  31011. /**
  31012. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31013. *
  31014. * ```
  31015. * L = (1/pi) * E * rho
  31016. * ```
  31017. *
  31018. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31019. */
  31020. convertIrradianceToLambertianRadiance(): void;
  31021. /**
  31022. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31023. * required operations at run time.
  31024. *
  31025. * This is simply done by scaling back the SH with Ylm constants parameter.
  31026. * The trigonometric part being applied by the shader at run time.
  31027. */
  31028. preScaleForRendering(): void;
  31029. /**
  31030. * Constructs a spherical harmonics from an array.
  31031. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31032. * @returns the spherical harmonics
  31033. */
  31034. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31035. /**
  31036. * Gets the spherical harmonics from polynomial
  31037. * @param polynomial the spherical polynomial
  31038. * @returns the spherical harmonics
  31039. */
  31040. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31041. }
  31042. /**
  31043. * Class representing spherical polynomial coefficients to the 3rd degree
  31044. */
  31045. export class SphericalPolynomial {
  31046. private _harmonics;
  31047. /**
  31048. * The spherical harmonics used to create the polynomials.
  31049. */
  31050. readonly preScaledHarmonics: SphericalHarmonics;
  31051. /**
  31052. * The x coefficients of the spherical polynomial
  31053. */
  31054. x: Vector3;
  31055. /**
  31056. * The y coefficients of the spherical polynomial
  31057. */
  31058. y: Vector3;
  31059. /**
  31060. * The z coefficients of the spherical polynomial
  31061. */
  31062. z: Vector3;
  31063. /**
  31064. * The xx coefficients of the spherical polynomial
  31065. */
  31066. xx: Vector3;
  31067. /**
  31068. * The yy coefficients of the spherical polynomial
  31069. */
  31070. yy: Vector3;
  31071. /**
  31072. * The zz coefficients of the spherical polynomial
  31073. */
  31074. zz: Vector3;
  31075. /**
  31076. * The xy coefficients of the spherical polynomial
  31077. */
  31078. xy: Vector3;
  31079. /**
  31080. * The yz coefficients of the spherical polynomial
  31081. */
  31082. yz: Vector3;
  31083. /**
  31084. * The zx coefficients of the spherical polynomial
  31085. */
  31086. zx: Vector3;
  31087. /**
  31088. * Adds an ambient color to the spherical polynomial
  31089. * @param color the color to add
  31090. */
  31091. addAmbient(color: Color3): void;
  31092. /**
  31093. * Scales the spherical polynomial by the given amount
  31094. * @param scale the amount to scale
  31095. */
  31096. scaleInPlace(scale: number): void;
  31097. /**
  31098. * Gets the spherical polynomial from harmonics
  31099. * @param harmonics the spherical harmonics
  31100. * @returns the spherical polynomial
  31101. */
  31102. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31103. /**
  31104. * Constructs a spherical polynomial from an array.
  31105. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31106. * @returns the spherical polynomial
  31107. */
  31108. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31109. }
  31110. }
  31111. declare module "babylonjs/Materials/Textures/internalTexture" {
  31112. import { Observable } from "babylonjs/Misc/observable";
  31113. import { Nullable, int } from "babylonjs/types";
  31114. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31116. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31117. /**
  31118. * Defines the source of the internal texture
  31119. */
  31120. export enum InternalTextureSource {
  31121. /**
  31122. * The source of the texture data is unknown
  31123. */
  31124. Unknown = 0,
  31125. /**
  31126. * Texture data comes from an URL
  31127. */
  31128. Url = 1,
  31129. /**
  31130. * Texture data is only used for temporary storage
  31131. */
  31132. Temp = 2,
  31133. /**
  31134. * Texture data comes from raw data (ArrayBuffer)
  31135. */
  31136. Raw = 3,
  31137. /**
  31138. * Texture content is dynamic (video or dynamic texture)
  31139. */
  31140. Dynamic = 4,
  31141. /**
  31142. * Texture content is generated by rendering to it
  31143. */
  31144. RenderTarget = 5,
  31145. /**
  31146. * Texture content is part of a multi render target process
  31147. */
  31148. MultiRenderTarget = 6,
  31149. /**
  31150. * Texture data comes from a cube data file
  31151. */
  31152. Cube = 7,
  31153. /**
  31154. * Texture data comes from a raw cube data
  31155. */
  31156. CubeRaw = 8,
  31157. /**
  31158. * Texture data come from a prefiltered cube data file
  31159. */
  31160. CubePrefiltered = 9,
  31161. /**
  31162. * Texture content is raw 3D data
  31163. */
  31164. Raw3D = 10,
  31165. /**
  31166. * Texture content is a depth texture
  31167. */
  31168. Depth = 11,
  31169. /**
  31170. * Texture data comes from a raw cube data encoded with RGBD
  31171. */
  31172. CubeRawRGBD = 12
  31173. }
  31174. /**
  31175. * Class used to store data associated with WebGL texture data for the engine
  31176. * This class should not be used directly
  31177. */
  31178. export class InternalTexture {
  31179. /** @hidden */
  31180. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31181. /**
  31182. * Defines if the texture is ready
  31183. */
  31184. isReady: boolean;
  31185. /**
  31186. * Defines if the texture is a cube texture
  31187. */
  31188. isCube: boolean;
  31189. /**
  31190. * Defines if the texture contains 3D data
  31191. */
  31192. is3D: boolean;
  31193. /**
  31194. * Defines if the texture contains multiview data
  31195. */
  31196. isMultiview: boolean;
  31197. /**
  31198. * Gets the URL used to load this texture
  31199. */
  31200. url: string;
  31201. /**
  31202. * Gets the sampling mode of the texture
  31203. */
  31204. samplingMode: number;
  31205. /**
  31206. * Gets a boolean indicating if the texture needs mipmaps generation
  31207. */
  31208. generateMipMaps: boolean;
  31209. /**
  31210. * Gets the number of samples used by the texture (WebGL2+ only)
  31211. */
  31212. samples: number;
  31213. /**
  31214. * Gets the type of the texture (int, float...)
  31215. */
  31216. type: number;
  31217. /**
  31218. * Gets the format of the texture (RGB, RGBA...)
  31219. */
  31220. format: number;
  31221. /**
  31222. * Observable called when the texture is loaded
  31223. */
  31224. onLoadedObservable: Observable<InternalTexture>;
  31225. /**
  31226. * Gets the width of the texture
  31227. */
  31228. width: number;
  31229. /**
  31230. * Gets the height of the texture
  31231. */
  31232. height: number;
  31233. /**
  31234. * Gets the depth of the texture
  31235. */
  31236. depth: number;
  31237. /**
  31238. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31239. */
  31240. baseWidth: number;
  31241. /**
  31242. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31243. */
  31244. baseHeight: number;
  31245. /**
  31246. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31247. */
  31248. baseDepth: number;
  31249. /**
  31250. * Gets a boolean indicating if the texture is inverted on Y axis
  31251. */
  31252. invertY: boolean;
  31253. /** @hidden */
  31254. _invertVScale: boolean;
  31255. /** @hidden */
  31256. _associatedChannel: number;
  31257. /** @hidden */
  31258. _source: InternalTextureSource;
  31259. /** @hidden */
  31260. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31261. /** @hidden */
  31262. _bufferView: Nullable<ArrayBufferView>;
  31263. /** @hidden */
  31264. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31265. /** @hidden */
  31266. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31267. /** @hidden */
  31268. _size: number;
  31269. /** @hidden */
  31270. _extension: string;
  31271. /** @hidden */
  31272. _files: Nullable<string[]>;
  31273. /** @hidden */
  31274. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31275. /** @hidden */
  31276. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31277. /** @hidden */
  31278. _framebuffer: Nullable<WebGLFramebuffer>;
  31279. /** @hidden */
  31280. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31281. /** @hidden */
  31282. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31283. /** @hidden */
  31284. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31285. /** @hidden */
  31286. _attachments: Nullable<number[]>;
  31287. /** @hidden */
  31288. _cachedCoordinatesMode: Nullable<number>;
  31289. /** @hidden */
  31290. _cachedWrapU: Nullable<number>;
  31291. /** @hidden */
  31292. _cachedWrapV: Nullable<number>;
  31293. /** @hidden */
  31294. _cachedWrapR: Nullable<number>;
  31295. /** @hidden */
  31296. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31297. /** @hidden */
  31298. _isDisabled: boolean;
  31299. /** @hidden */
  31300. _compression: Nullable<string>;
  31301. /** @hidden */
  31302. _generateStencilBuffer: boolean;
  31303. /** @hidden */
  31304. _generateDepthBuffer: boolean;
  31305. /** @hidden */
  31306. _comparisonFunction: number;
  31307. /** @hidden */
  31308. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31309. /** @hidden */
  31310. _lodGenerationScale: number;
  31311. /** @hidden */
  31312. _lodGenerationOffset: number;
  31313. /** @hidden */
  31314. _colorTextureArray: Nullable<WebGLTexture>;
  31315. /** @hidden */
  31316. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31317. /** @hidden */
  31318. _lodTextureHigh: Nullable<BaseTexture>;
  31319. /** @hidden */
  31320. _lodTextureMid: Nullable<BaseTexture>;
  31321. /** @hidden */
  31322. _lodTextureLow: Nullable<BaseTexture>;
  31323. /** @hidden */
  31324. _isRGBD: boolean;
  31325. /** @hidden */
  31326. _linearSpecularLOD: boolean;
  31327. /** @hidden */
  31328. _irradianceTexture: Nullable<BaseTexture>;
  31329. /** @hidden */
  31330. _webGLTexture: Nullable<WebGLTexture>;
  31331. /** @hidden */
  31332. _references: number;
  31333. private _engine;
  31334. /**
  31335. * Gets the Engine the texture belongs to.
  31336. * @returns The babylon engine
  31337. */
  31338. getEngine(): ThinEngine;
  31339. /**
  31340. * Gets the data source type of the texture
  31341. */
  31342. readonly source: InternalTextureSource;
  31343. /**
  31344. * Creates a new InternalTexture
  31345. * @param engine defines the engine to use
  31346. * @param source defines the type of data that will be used
  31347. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31348. */
  31349. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31350. /**
  31351. * Increments the number of references (ie. the number of Texture that point to it)
  31352. */
  31353. incrementReferences(): void;
  31354. /**
  31355. * Change the size of the texture (not the size of the content)
  31356. * @param width defines the new width
  31357. * @param height defines the new height
  31358. * @param depth defines the new depth (1 by default)
  31359. */
  31360. updateSize(width: int, height: int, depth?: int): void;
  31361. /** @hidden */
  31362. _rebuild(): void;
  31363. /** @hidden */
  31364. _swapAndDie(target: InternalTexture): void;
  31365. /**
  31366. * Dispose the current allocated resources
  31367. */
  31368. dispose(): void;
  31369. }
  31370. }
  31371. declare module "babylonjs/Audio/analyser" {
  31372. import { Scene } from "babylonjs/scene";
  31373. /**
  31374. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31376. */
  31377. export class Analyser {
  31378. /**
  31379. * Gets or sets the smoothing
  31380. * @ignorenaming
  31381. */
  31382. SMOOTHING: number;
  31383. /**
  31384. * Gets or sets the FFT table size
  31385. * @ignorenaming
  31386. */
  31387. FFT_SIZE: number;
  31388. /**
  31389. * Gets or sets the bar graph amplitude
  31390. * @ignorenaming
  31391. */
  31392. BARGRAPHAMPLITUDE: number;
  31393. /**
  31394. * Gets or sets the position of the debug canvas
  31395. * @ignorenaming
  31396. */
  31397. DEBUGCANVASPOS: {
  31398. x: number;
  31399. y: number;
  31400. };
  31401. /**
  31402. * Gets or sets the debug canvas size
  31403. * @ignorenaming
  31404. */
  31405. DEBUGCANVASSIZE: {
  31406. width: number;
  31407. height: number;
  31408. };
  31409. private _byteFreqs;
  31410. private _byteTime;
  31411. private _floatFreqs;
  31412. private _webAudioAnalyser;
  31413. private _debugCanvas;
  31414. private _debugCanvasContext;
  31415. private _scene;
  31416. private _registerFunc;
  31417. private _audioEngine;
  31418. /**
  31419. * Creates a new analyser
  31420. * @param scene defines hosting scene
  31421. */
  31422. constructor(scene: Scene);
  31423. /**
  31424. * Get the number of data values you will have to play with for the visualization
  31425. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31426. * @returns a number
  31427. */
  31428. getFrequencyBinCount(): number;
  31429. /**
  31430. * Gets the current frequency data as a byte array
  31431. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31432. * @returns a Uint8Array
  31433. */
  31434. getByteFrequencyData(): Uint8Array;
  31435. /**
  31436. * Gets the current waveform as a byte array
  31437. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31438. * @returns a Uint8Array
  31439. */
  31440. getByteTimeDomainData(): Uint8Array;
  31441. /**
  31442. * Gets the current frequency data as a float array
  31443. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31444. * @returns a Float32Array
  31445. */
  31446. getFloatFrequencyData(): Float32Array;
  31447. /**
  31448. * Renders the debug canvas
  31449. */
  31450. drawDebugCanvas(): void;
  31451. /**
  31452. * Stops rendering the debug canvas and removes it
  31453. */
  31454. stopDebugCanvas(): void;
  31455. /**
  31456. * Connects two audio nodes
  31457. * @param inputAudioNode defines first node to connect
  31458. * @param outputAudioNode defines second node to connect
  31459. */
  31460. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31461. /**
  31462. * Releases all associated resources
  31463. */
  31464. dispose(): void;
  31465. }
  31466. }
  31467. declare module "babylonjs/Audio/audioEngine" {
  31468. import { IDisposable } from "babylonjs/scene";
  31469. import { Analyser } from "babylonjs/Audio/analyser";
  31470. import { Nullable } from "babylonjs/types";
  31471. import { Observable } from "babylonjs/Misc/observable";
  31472. /**
  31473. * This represents an audio engine and it is responsible
  31474. * to play, synchronize and analyse sounds throughout the application.
  31475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31476. */
  31477. export interface IAudioEngine extends IDisposable {
  31478. /**
  31479. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31480. */
  31481. readonly canUseWebAudio: boolean;
  31482. /**
  31483. * Gets the current AudioContext if available.
  31484. */
  31485. readonly audioContext: Nullable<AudioContext>;
  31486. /**
  31487. * The master gain node defines the global audio volume of your audio engine.
  31488. */
  31489. readonly masterGain: GainNode;
  31490. /**
  31491. * Gets whether or not mp3 are supported by your browser.
  31492. */
  31493. readonly isMP3supported: boolean;
  31494. /**
  31495. * Gets whether or not ogg are supported by your browser.
  31496. */
  31497. readonly isOGGsupported: boolean;
  31498. /**
  31499. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31500. * @ignoreNaming
  31501. */
  31502. WarnedWebAudioUnsupported: boolean;
  31503. /**
  31504. * Defines if the audio engine relies on a custom unlocked button.
  31505. * In this case, the embedded button will not be displayed.
  31506. */
  31507. useCustomUnlockedButton: boolean;
  31508. /**
  31509. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31510. */
  31511. readonly unlocked: boolean;
  31512. /**
  31513. * Event raised when audio has been unlocked on the browser.
  31514. */
  31515. onAudioUnlockedObservable: Observable<AudioEngine>;
  31516. /**
  31517. * Event raised when audio has been locked on the browser.
  31518. */
  31519. onAudioLockedObservable: Observable<AudioEngine>;
  31520. /**
  31521. * Flags the audio engine in Locked state.
  31522. * This happens due to new browser policies preventing audio to autoplay.
  31523. */
  31524. lock(): void;
  31525. /**
  31526. * Unlocks the audio engine once a user action has been done on the dom.
  31527. * This is helpful to resume play once browser policies have been satisfied.
  31528. */
  31529. unlock(): void;
  31530. }
  31531. /**
  31532. * This represents the default audio engine used in babylon.
  31533. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31535. */
  31536. export class AudioEngine implements IAudioEngine {
  31537. private _audioContext;
  31538. private _audioContextInitialized;
  31539. private _muteButton;
  31540. private _hostElement;
  31541. /**
  31542. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31543. */
  31544. canUseWebAudio: boolean;
  31545. /**
  31546. * The master gain node defines the global audio volume of your audio engine.
  31547. */
  31548. masterGain: GainNode;
  31549. /**
  31550. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31551. * @ignoreNaming
  31552. */
  31553. WarnedWebAudioUnsupported: boolean;
  31554. /**
  31555. * Gets whether or not mp3 are supported by your browser.
  31556. */
  31557. isMP3supported: boolean;
  31558. /**
  31559. * Gets whether or not ogg are supported by your browser.
  31560. */
  31561. isOGGsupported: boolean;
  31562. /**
  31563. * Gets whether audio has been unlocked on the device.
  31564. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31565. * a user interaction has happened.
  31566. */
  31567. unlocked: boolean;
  31568. /**
  31569. * Defines if the audio engine relies on a custom unlocked button.
  31570. * In this case, the embedded button will not be displayed.
  31571. */
  31572. useCustomUnlockedButton: boolean;
  31573. /**
  31574. * Event raised when audio has been unlocked on the browser.
  31575. */
  31576. onAudioUnlockedObservable: Observable<AudioEngine>;
  31577. /**
  31578. * Event raised when audio has been locked on the browser.
  31579. */
  31580. onAudioLockedObservable: Observable<AudioEngine>;
  31581. /**
  31582. * Gets the current AudioContext if available.
  31583. */
  31584. readonly audioContext: Nullable<AudioContext>;
  31585. private _connectedAnalyser;
  31586. /**
  31587. * Instantiates a new audio engine.
  31588. *
  31589. * There should be only one per page as some browsers restrict the number
  31590. * of audio contexts you can create.
  31591. * @param hostElement defines the host element where to display the mute icon if necessary
  31592. */
  31593. constructor(hostElement?: Nullable<HTMLElement>);
  31594. /**
  31595. * Flags the audio engine in Locked state.
  31596. * This happens due to new browser policies preventing audio to autoplay.
  31597. */
  31598. lock(): void;
  31599. /**
  31600. * Unlocks the audio engine once a user action has been done on the dom.
  31601. * This is helpful to resume play once browser policies have been satisfied.
  31602. */
  31603. unlock(): void;
  31604. private _resumeAudioContext;
  31605. private _initializeAudioContext;
  31606. private _tryToRun;
  31607. private _triggerRunningState;
  31608. private _triggerSuspendedState;
  31609. private _displayMuteButton;
  31610. private _moveButtonToTopLeft;
  31611. private _onResize;
  31612. private _hideMuteButton;
  31613. /**
  31614. * Destroy and release the resources associated with the audio ccontext.
  31615. */
  31616. dispose(): void;
  31617. /**
  31618. * Gets the global volume sets on the master gain.
  31619. * @returns the global volume if set or -1 otherwise
  31620. */
  31621. getGlobalVolume(): number;
  31622. /**
  31623. * Sets the global volume of your experience (sets on the master gain).
  31624. * @param newVolume Defines the new global volume of the application
  31625. */
  31626. setGlobalVolume(newVolume: number): void;
  31627. /**
  31628. * Connect the audio engine to an audio analyser allowing some amazing
  31629. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31631. * @param analyser The analyser to connect to the engine
  31632. */
  31633. connectToAnalyser(analyser: Analyser): void;
  31634. }
  31635. }
  31636. declare module "babylonjs/Loading/loadingScreen" {
  31637. /**
  31638. * Interface used to present a loading screen while loading a scene
  31639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31640. */
  31641. export interface ILoadingScreen {
  31642. /**
  31643. * Function called to display the loading screen
  31644. */
  31645. displayLoadingUI: () => void;
  31646. /**
  31647. * Function called to hide the loading screen
  31648. */
  31649. hideLoadingUI: () => void;
  31650. /**
  31651. * Gets or sets the color to use for the background
  31652. */
  31653. loadingUIBackgroundColor: string;
  31654. /**
  31655. * Gets or sets the text to display while loading
  31656. */
  31657. loadingUIText: string;
  31658. }
  31659. /**
  31660. * Class used for the default loading screen
  31661. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31662. */
  31663. export class DefaultLoadingScreen implements ILoadingScreen {
  31664. private _renderingCanvas;
  31665. private _loadingText;
  31666. private _loadingDivBackgroundColor;
  31667. private _loadingDiv;
  31668. private _loadingTextDiv;
  31669. /** Gets or sets the logo url to use for the default loading screen */
  31670. static DefaultLogoUrl: string;
  31671. /** Gets or sets the spinner url to use for the default loading screen */
  31672. static DefaultSpinnerUrl: string;
  31673. /**
  31674. * Creates a new default loading screen
  31675. * @param _renderingCanvas defines the canvas used to render the scene
  31676. * @param _loadingText defines the default text to display
  31677. * @param _loadingDivBackgroundColor defines the default background color
  31678. */
  31679. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31680. /**
  31681. * Function called to display the loading screen
  31682. */
  31683. displayLoadingUI(): void;
  31684. /**
  31685. * Function called to hide the loading screen
  31686. */
  31687. hideLoadingUI(): void;
  31688. /**
  31689. * Gets or sets the text to display while loading
  31690. */
  31691. loadingUIText: string;
  31692. /**
  31693. * Gets or sets the color to use for the background
  31694. */
  31695. loadingUIBackgroundColor: string;
  31696. private _resizeLoadingUI;
  31697. }
  31698. }
  31699. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31700. /**
  31701. * Interface for any object that can request an animation frame
  31702. */
  31703. export interface ICustomAnimationFrameRequester {
  31704. /**
  31705. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31706. */
  31707. renderFunction?: Function;
  31708. /**
  31709. * Called to request the next frame to render to
  31710. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31711. */
  31712. requestAnimationFrame: Function;
  31713. /**
  31714. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31715. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31716. */
  31717. requestID?: number;
  31718. }
  31719. }
  31720. declare module "babylonjs/Misc/performanceMonitor" {
  31721. /**
  31722. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31723. */
  31724. export class PerformanceMonitor {
  31725. private _enabled;
  31726. private _rollingFrameTime;
  31727. private _lastFrameTimeMs;
  31728. /**
  31729. * constructor
  31730. * @param frameSampleSize The number of samples required to saturate the sliding window
  31731. */
  31732. constructor(frameSampleSize?: number);
  31733. /**
  31734. * Samples current frame
  31735. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31736. */
  31737. sampleFrame(timeMs?: number): void;
  31738. /**
  31739. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31740. */
  31741. readonly averageFrameTime: number;
  31742. /**
  31743. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31744. */
  31745. readonly averageFrameTimeVariance: number;
  31746. /**
  31747. * Returns the frame time of the most recent frame
  31748. */
  31749. readonly instantaneousFrameTime: number;
  31750. /**
  31751. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31752. */
  31753. readonly averageFPS: number;
  31754. /**
  31755. * Returns the average framerate in frames per second using the most recent frame time
  31756. */
  31757. readonly instantaneousFPS: number;
  31758. /**
  31759. * Returns true if enough samples have been taken to completely fill the sliding window
  31760. */
  31761. readonly isSaturated: boolean;
  31762. /**
  31763. * Enables contributions to the sliding window sample set
  31764. */
  31765. enable(): void;
  31766. /**
  31767. * Disables contributions to the sliding window sample set
  31768. * Samples will not be interpolated over the disabled period
  31769. */
  31770. disable(): void;
  31771. /**
  31772. * Returns true if sampling is enabled
  31773. */
  31774. readonly isEnabled: boolean;
  31775. /**
  31776. * Resets performance monitor
  31777. */
  31778. reset(): void;
  31779. }
  31780. /**
  31781. * RollingAverage
  31782. *
  31783. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31784. */
  31785. export class RollingAverage {
  31786. /**
  31787. * Current average
  31788. */
  31789. average: number;
  31790. /**
  31791. * Current variance
  31792. */
  31793. variance: number;
  31794. protected _samples: Array<number>;
  31795. protected _sampleCount: number;
  31796. protected _pos: number;
  31797. protected _m2: number;
  31798. /**
  31799. * constructor
  31800. * @param length The number of samples required to saturate the sliding window
  31801. */
  31802. constructor(length: number);
  31803. /**
  31804. * Adds a sample to the sample set
  31805. * @param v The sample value
  31806. */
  31807. add(v: number): void;
  31808. /**
  31809. * Returns previously added values or null if outside of history or outside the sliding window domain
  31810. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31811. * @return Value previously recorded with add() or null if outside of range
  31812. */
  31813. history(i: number): number;
  31814. /**
  31815. * Returns true if enough samples have been taken to completely fill the sliding window
  31816. * @return true if sample-set saturated
  31817. */
  31818. isSaturated(): boolean;
  31819. /**
  31820. * Resets the rolling average (equivalent to 0 samples taken so far)
  31821. */
  31822. reset(): void;
  31823. /**
  31824. * Wraps a value around the sample range boundaries
  31825. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31826. * @return Wrapped position in sample range
  31827. */
  31828. protected _wrapPosition(i: number): number;
  31829. }
  31830. }
  31831. declare module "babylonjs/Misc/perfCounter" {
  31832. /**
  31833. * This class is used to track a performance counter which is number based.
  31834. * The user has access to many properties which give statistics of different nature.
  31835. *
  31836. * The implementer can track two kinds of Performance Counter: time and count.
  31837. * 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.
  31838. * 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.
  31839. */
  31840. export class PerfCounter {
  31841. /**
  31842. * Gets or sets a global boolean to turn on and off all the counters
  31843. */
  31844. static Enabled: boolean;
  31845. /**
  31846. * Returns the smallest value ever
  31847. */
  31848. readonly min: number;
  31849. /**
  31850. * Returns the biggest value ever
  31851. */
  31852. readonly max: number;
  31853. /**
  31854. * Returns the average value since the performance counter is running
  31855. */
  31856. readonly average: number;
  31857. /**
  31858. * Returns the average value of the last second the counter was monitored
  31859. */
  31860. readonly lastSecAverage: number;
  31861. /**
  31862. * Returns the current value
  31863. */
  31864. readonly current: number;
  31865. /**
  31866. * Gets the accumulated total
  31867. */
  31868. readonly total: number;
  31869. /**
  31870. * Gets the total value count
  31871. */
  31872. readonly count: number;
  31873. /**
  31874. * Creates a new counter
  31875. */
  31876. constructor();
  31877. /**
  31878. * Call this method to start monitoring a new frame.
  31879. * 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.
  31880. */
  31881. fetchNewFrame(): void;
  31882. /**
  31883. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31884. * @param newCount the count value to add to the monitored count
  31885. * @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.
  31886. */
  31887. addCount(newCount: number, fetchResult: boolean): void;
  31888. /**
  31889. * Start monitoring this performance counter
  31890. */
  31891. beginMonitoring(): void;
  31892. /**
  31893. * Compute the time lapsed since the previous beginMonitoring() call.
  31894. * @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
  31895. */
  31896. endMonitoring(newFrame?: boolean): void;
  31897. private _fetchResult;
  31898. private _startMonitoringTime;
  31899. private _min;
  31900. private _max;
  31901. private _average;
  31902. private _current;
  31903. private _totalValueCount;
  31904. private _totalAccumulated;
  31905. private _lastSecAverage;
  31906. private _lastSecAccumulated;
  31907. private _lastSecTime;
  31908. private _lastSecValueCount;
  31909. }
  31910. }
  31911. declare module "babylonjs/Engines/engine" {
  31912. import { Observable } from "babylonjs/Misc/observable";
  31913. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  31914. import { Scene } from "babylonjs/scene";
  31915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31916. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31917. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31918. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31919. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31920. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31921. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31922. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31923. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31925. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31926. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31927. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31928. import { Material } from "babylonjs/Materials/material";
  31929. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31930. /**
  31931. * Defines the interface used by display changed events
  31932. */
  31933. export interface IDisplayChangedEventArgs {
  31934. /** Gets the vrDisplay object (if any) */
  31935. vrDisplay: Nullable<any>;
  31936. /** Gets a boolean indicating if webVR is supported */
  31937. vrSupported: boolean;
  31938. }
  31939. /**
  31940. * Defines the interface used by objects containing a viewport (like a camera)
  31941. */
  31942. interface IViewportOwnerLike {
  31943. /**
  31944. * Gets or sets the viewport
  31945. */
  31946. viewport: IViewportLike;
  31947. }
  31948. /**
  31949. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31950. */
  31951. export class Engine extends ThinEngine {
  31952. /** Defines that alpha blending is disabled */
  31953. static readonly ALPHA_DISABLE: number;
  31954. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31955. static readonly ALPHA_ADD: number;
  31956. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31957. static readonly ALPHA_COMBINE: number;
  31958. /** Defines that alpha blending to DEST - SRC * DEST */
  31959. static readonly ALPHA_SUBTRACT: number;
  31960. /** Defines that alpha blending to SRC * DEST */
  31961. static readonly ALPHA_MULTIPLY: number;
  31962. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31963. static readonly ALPHA_MAXIMIZED: number;
  31964. /** Defines that alpha blending to SRC + DEST */
  31965. static readonly ALPHA_ONEONE: number;
  31966. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31967. static readonly ALPHA_PREMULTIPLIED: number;
  31968. /**
  31969. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31970. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31971. */
  31972. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31973. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31974. static readonly ALPHA_INTERPOLATE: number;
  31975. /**
  31976. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31977. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31978. */
  31979. static readonly ALPHA_SCREENMODE: number;
  31980. /** Defines that the ressource is not delayed*/
  31981. static readonly DELAYLOADSTATE_NONE: number;
  31982. /** Defines that the ressource was successfully delay loaded */
  31983. static readonly DELAYLOADSTATE_LOADED: number;
  31984. /** Defines that the ressource is currently delay loading */
  31985. static readonly DELAYLOADSTATE_LOADING: number;
  31986. /** Defines that the ressource is delayed and has not started loading */
  31987. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31988. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31989. static readonly NEVER: number;
  31990. /** 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 */
  31991. static readonly ALWAYS: number;
  31992. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31993. static readonly LESS: number;
  31994. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31995. static readonly EQUAL: number;
  31996. /** 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 */
  31997. static readonly LEQUAL: number;
  31998. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31999. static readonly GREATER: number;
  32000. /** 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 */
  32001. static readonly GEQUAL: number;
  32002. /** 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 */
  32003. static readonly NOTEQUAL: number;
  32004. /** Passed to stencilOperation to specify that stencil value must be kept */
  32005. static readonly KEEP: number;
  32006. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32007. static readonly REPLACE: number;
  32008. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32009. static readonly INCR: number;
  32010. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32011. static readonly DECR: number;
  32012. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32013. static readonly INVERT: number;
  32014. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32015. static readonly INCR_WRAP: number;
  32016. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32017. static readonly DECR_WRAP: number;
  32018. /** Texture is not repeating outside of 0..1 UVs */
  32019. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32020. /** Texture is repeating outside of 0..1 UVs */
  32021. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32022. /** Texture is repeating and mirrored */
  32023. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32024. /** ALPHA */
  32025. static readonly TEXTUREFORMAT_ALPHA: number;
  32026. /** LUMINANCE */
  32027. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32028. /** LUMINANCE_ALPHA */
  32029. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32030. /** RGB */
  32031. static readonly TEXTUREFORMAT_RGB: number;
  32032. /** RGBA */
  32033. static readonly TEXTUREFORMAT_RGBA: number;
  32034. /** RED */
  32035. static readonly TEXTUREFORMAT_RED: number;
  32036. /** RED (2nd reference) */
  32037. static readonly TEXTUREFORMAT_R: number;
  32038. /** RG */
  32039. static readonly TEXTUREFORMAT_RG: number;
  32040. /** RED_INTEGER */
  32041. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32042. /** RED_INTEGER (2nd reference) */
  32043. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32044. /** RG_INTEGER */
  32045. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32046. /** RGB_INTEGER */
  32047. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32048. /** RGBA_INTEGER */
  32049. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32050. /** UNSIGNED_BYTE */
  32051. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32052. /** UNSIGNED_BYTE (2nd reference) */
  32053. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32054. /** FLOAT */
  32055. static readonly TEXTURETYPE_FLOAT: number;
  32056. /** HALF_FLOAT */
  32057. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32058. /** BYTE */
  32059. static readonly TEXTURETYPE_BYTE: number;
  32060. /** SHORT */
  32061. static readonly TEXTURETYPE_SHORT: number;
  32062. /** UNSIGNED_SHORT */
  32063. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32064. /** INT */
  32065. static readonly TEXTURETYPE_INT: number;
  32066. /** UNSIGNED_INT */
  32067. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32068. /** UNSIGNED_SHORT_4_4_4_4 */
  32069. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32070. /** UNSIGNED_SHORT_5_5_5_1 */
  32071. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32072. /** UNSIGNED_SHORT_5_6_5 */
  32073. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32074. /** UNSIGNED_INT_2_10_10_10_REV */
  32075. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32076. /** UNSIGNED_INT_24_8 */
  32077. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32078. /** UNSIGNED_INT_10F_11F_11F_REV */
  32079. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32080. /** UNSIGNED_INT_5_9_9_9_REV */
  32081. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32082. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32083. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32084. /** nearest is mag = nearest and min = nearest and mip = linear */
  32085. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32086. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32087. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32088. /** Trilinear is mag = linear and min = linear and mip = linear */
  32089. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32090. /** nearest is mag = nearest and min = nearest and mip = linear */
  32091. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32093. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32094. /** Trilinear is mag = linear and min = linear and mip = linear */
  32095. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32096. /** mag = nearest and min = nearest and mip = nearest */
  32097. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32098. /** mag = nearest and min = linear and mip = nearest */
  32099. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32100. /** mag = nearest and min = linear and mip = linear */
  32101. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32102. /** mag = nearest and min = linear and mip = none */
  32103. static readonly TEXTURE_NEAREST_LINEAR: number;
  32104. /** mag = nearest and min = nearest and mip = none */
  32105. static readonly TEXTURE_NEAREST_NEAREST: number;
  32106. /** mag = linear and min = nearest and mip = nearest */
  32107. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32108. /** mag = linear and min = nearest and mip = linear */
  32109. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32110. /** mag = linear and min = linear and mip = none */
  32111. static readonly TEXTURE_LINEAR_LINEAR: number;
  32112. /** mag = linear and min = nearest and mip = none */
  32113. static readonly TEXTURE_LINEAR_NEAREST: number;
  32114. /** Explicit coordinates mode */
  32115. static readonly TEXTURE_EXPLICIT_MODE: number;
  32116. /** Spherical coordinates mode */
  32117. static readonly TEXTURE_SPHERICAL_MODE: number;
  32118. /** Planar coordinates mode */
  32119. static readonly TEXTURE_PLANAR_MODE: number;
  32120. /** Cubic coordinates mode */
  32121. static readonly TEXTURE_CUBIC_MODE: number;
  32122. /** Projection coordinates mode */
  32123. static readonly TEXTURE_PROJECTION_MODE: number;
  32124. /** Skybox coordinates mode */
  32125. static readonly TEXTURE_SKYBOX_MODE: number;
  32126. /** Inverse Cubic coordinates mode */
  32127. static readonly TEXTURE_INVCUBIC_MODE: number;
  32128. /** Equirectangular coordinates mode */
  32129. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32130. /** Equirectangular Fixed coordinates mode */
  32131. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32132. /** Equirectangular Fixed Mirrored coordinates mode */
  32133. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32134. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32135. static readonly SCALEMODE_FLOOR: number;
  32136. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32137. static readonly SCALEMODE_NEAREST: number;
  32138. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32139. static readonly SCALEMODE_CEILING: number;
  32140. /**
  32141. * Returns the current npm package of the sdk
  32142. */
  32143. static readonly NpmPackage: string;
  32144. /**
  32145. * Returns the current version of the framework
  32146. */
  32147. static readonly Version: string;
  32148. /** Gets the list of created engines */
  32149. static readonly Instances: Engine[];
  32150. /**
  32151. * Gets the latest created engine
  32152. */
  32153. static readonly LastCreatedEngine: Nullable<Engine>;
  32154. /**
  32155. * Gets the latest created scene
  32156. */
  32157. static readonly LastCreatedScene: Nullable<Scene>;
  32158. /**
  32159. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32160. * @param flag defines which part of the materials must be marked as dirty
  32161. * @param predicate defines a predicate used to filter which materials should be affected
  32162. */
  32163. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32164. /**
  32165. * Method called to create the default loading screen.
  32166. * This can be overriden in your own app.
  32167. * @param canvas The rendering canvas element
  32168. * @returns The loading screen
  32169. */
  32170. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32171. /**
  32172. * Method called to create the default rescale post process on each engine.
  32173. */
  32174. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32175. /**
  32176. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32177. **/
  32178. enableOfflineSupport: boolean;
  32179. /**
  32180. * 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)
  32181. **/
  32182. disableManifestCheck: boolean;
  32183. /**
  32184. * Gets the list of created scenes
  32185. */
  32186. scenes: Scene[];
  32187. /**
  32188. * Event raised when a new scene is created
  32189. */
  32190. onNewSceneAddedObservable: Observable<Scene>;
  32191. /**
  32192. * Gets the list of created postprocesses
  32193. */
  32194. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32195. /**
  32196. * Gets a boolean indicating if the pointer is currently locked
  32197. */
  32198. isPointerLock: boolean;
  32199. /**
  32200. * Observable event triggered each time the rendering canvas is resized
  32201. */
  32202. onResizeObservable: Observable<Engine>;
  32203. /**
  32204. * Observable event triggered each time the canvas loses focus
  32205. */
  32206. onCanvasBlurObservable: Observable<Engine>;
  32207. /**
  32208. * Observable event triggered each time the canvas gains focus
  32209. */
  32210. onCanvasFocusObservable: Observable<Engine>;
  32211. /**
  32212. * Observable event triggered each time the canvas receives pointerout event
  32213. */
  32214. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32215. /**
  32216. * Observable raised when the engine begins a new frame
  32217. */
  32218. onBeginFrameObservable: Observable<Engine>;
  32219. /**
  32220. * If set, will be used to request the next animation frame for the render loop
  32221. */
  32222. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32223. /**
  32224. * Observable raised when the engine ends the current frame
  32225. */
  32226. onEndFrameObservable: Observable<Engine>;
  32227. /**
  32228. * Observable raised when the engine is about to compile a shader
  32229. */
  32230. onBeforeShaderCompilationObservable: Observable<Engine>;
  32231. /**
  32232. * Observable raised when the engine has jsut compiled a shader
  32233. */
  32234. onAfterShaderCompilationObservable: Observable<Engine>;
  32235. /**
  32236. * Gets the audio engine
  32237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32238. * @ignorenaming
  32239. */
  32240. static audioEngine: IAudioEngine;
  32241. /**
  32242. * Default AudioEngine factory responsible of creating the Audio Engine.
  32243. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32244. */
  32245. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32246. /**
  32247. * Default offline support factory responsible of creating a tool used to store data locally.
  32248. * By default, this will create a Database object if the workload has been embedded.
  32249. */
  32250. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32251. private _loadingScreen;
  32252. private _pointerLockRequested;
  32253. private _dummyFramebuffer;
  32254. private _rescalePostProcess;
  32255. /** @hidden */
  32256. protected _alphaMode: number;
  32257. /** @hidden */
  32258. protected _alphaEquation: number;
  32259. private _deterministicLockstep;
  32260. private _lockstepMaxSteps;
  32261. protected readonly _supportsHardwareTextureRescaling: boolean;
  32262. private _fps;
  32263. private _deltaTime;
  32264. /** @hidden */
  32265. _drawCalls: PerfCounter;
  32266. /**
  32267. * Turn this value on if you want to pause FPS computation when in background
  32268. */
  32269. disablePerformanceMonitorInBackground: boolean;
  32270. private _performanceMonitor;
  32271. /**
  32272. * Gets the performance monitor attached to this engine
  32273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32274. */
  32275. readonly performanceMonitor: PerformanceMonitor;
  32276. private _onFocus;
  32277. private _onBlur;
  32278. private _onCanvasPointerOut;
  32279. private _onCanvasBlur;
  32280. private _onCanvasFocus;
  32281. private _onFullscreenChange;
  32282. private _onPointerLockChange;
  32283. /**
  32284. * Gets the HTML element used to attach event listeners
  32285. * @returns a HTML element
  32286. */
  32287. getInputElement(): Nullable<HTMLElement>;
  32288. /**
  32289. * Creates a new engine
  32290. * @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
  32291. * @param antialias defines enable antialiasing (default: false)
  32292. * @param options defines further options to be sent to the getContext() function
  32293. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32294. */
  32295. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32296. /**
  32297. * Gets current aspect ratio
  32298. * @param viewportOwner defines the camera to use to get the aspect ratio
  32299. * @param useScreen defines if screen size must be used (or the current render target if any)
  32300. * @returns a number defining the aspect ratio
  32301. */
  32302. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32303. /**
  32304. * Gets current screen aspect ratio
  32305. * @returns a number defining the aspect ratio
  32306. */
  32307. getScreenAspectRatio(): number;
  32308. /**
  32309. * Gets host document
  32310. * @returns the host document object
  32311. */
  32312. getHostDocument(): Document;
  32313. /**
  32314. * Gets the client rect of the HTML canvas attached with the current webGL context
  32315. * @returns a client rectanglee
  32316. */
  32317. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32318. /**
  32319. * Gets the client rect of the HTML element used for events
  32320. * @returns a client rectanglee
  32321. */
  32322. getInputElementClientRect(): Nullable<ClientRect>;
  32323. /**
  32324. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32325. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32326. * @returns true if engine is in deterministic lock step mode
  32327. */
  32328. isDeterministicLockStep(): boolean;
  32329. /**
  32330. * Gets the max steps when engine is running in deterministic lock step
  32331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32332. * @returns the max steps
  32333. */
  32334. getLockstepMaxSteps(): number;
  32335. /**
  32336. * Force the mipmap generation for the given render target texture
  32337. * @param texture defines the render target texture to use
  32338. */
  32339. generateMipMapsForCubemap(texture: InternalTexture): void;
  32340. /** States */
  32341. /**
  32342. * Set various states to the webGL context
  32343. * @param culling defines backface culling state
  32344. * @param zOffset defines the value to apply to zOffset (0 by default)
  32345. * @param force defines if states must be applied even if cache is up to date
  32346. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32347. */
  32348. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32349. /**
  32350. * Set the z offset to apply to current rendering
  32351. * @param value defines the offset to apply
  32352. */
  32353. setZOffset(value: number): void;
  32354. /**
  32355. * Gets the current value of the zOffset
  32356. * @returns the current zOffset state
  32357. */
  32358. getZOffset(): number;
  32359. /**
  32360. * Enable or disable depth buffering
  32361. * @param enable defines the state to set
  32362. */
  32363. setDepthBuffer(enable: boolean): void;
  32364. /**
  32365. * Gets a boolean indicating if depth writing is enabled
  32366. * @returns the current depth writing state
  32367. */
  32368. getDepthWrite(): boolean;
  32369. /**
  32370. * Enable or disable depth writing
  32371. * @param enable defines the state to set
  32372. */
  32373. setDepthWrite(enable: boolean): void;
  32374. /**
  32375. * Enable or disable color writing
  32376. * @param enable defines the state to set
  32377. */
  32378. setColorWrite(enable: boolean): void;
  32379. /**
  32380. * Gets a boolean indicating if color writing is enabled
  32381. * @returns the current color writing state
  32382. */
  32383. getColorWrite(): boolean;
  32384. /**
  32385. * Sets alpha constants used by some alpha blending modes
  32386. * @param r defines the red component
  32387. * @param g defines the green component
  32388. * @param b defines the blue component
  32389. * @param a defines the alpha component
  32390. */
  32391. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32392. /**
  32393. * Sets the current alpha mode
  32394. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32395. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32397. */
  32398. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32399. /**
  32400. * Gets the current alpha mode
  32401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32402. * @returns the current alpha mode
  32403. */
  32404. getAlphaMode(): number;
  32405. /**
  32406. * Sets the current alpha equation
  32407. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32408. */
  32409. setAlphaEquation(equation: number): void;
  32410. /**
  32411. * Gets the current alpha equation.
  32412. * @returns the current alpha equation
  32413. */
  32414. getAlphaEquation(): number;
  32415. /**
  32416. * Gets a boolean indicating if stencil buffer is enabled
  32417. * @returns the current stencil buffer state
  32418. */
  32419. getStencilBuffer(): boolean;
  32420. /**
  32421. * Enable or disable the stencil buffer
  32422. * @param enable defines if the stencil buffer must be enabled or disabled
  32423. */
  32424. setStencilBuffer(enable: boolean): void;
  32425. /**
  32426. * Gets the current stencil mask
  32427. * @returns a number defining the new stencil mask to use
  32428. */
  32429. getStencilMask(): number;
  32430. /**
  32431. * Sets the current stencil mask
  32432. * @param mask defines the new stencil mask to use
  32433. */
  32434. setStencilMask(mask: number): void;
  32435. /**
  32436. * Gets the current stencil function
  32437. * @returns a number defining the stencil function to use
  32438. */
  32439. getStencilFunction(): number;
  32440. /**
  32441. * Gets the current stencil reference value
  32442. * @returns a number defining the stencil reference value to use
  32443. */
  32444. getStencilFunctionReference(): number;
  32445. /**
  32446. * Gets the current stencil mask
  32447. * @returns a number defining the stencil mask to use
  32448. */
  32449. getStencilFunctionMask(): number;
  32450. /**
  32451. * Sets the current stencil function
  32452. * @param stencilFunc defines the new stencil function to use
  32453. */
  32454. setStencilFunction(stencilFunc: number): void;
  32455. /**
  32456. * Sets the current stencil reference
  32457. * @param reference defines the new stencil reference to use
  32458. */
  32459. setStencilFunctionReference(reference: number): void;
  32460. /**
  32461. * Sets the current stencil mask
  32462. * @param mask defines the new stencil mask to use
  32463. */
  32464. setStencilFunctionMask(mask: number): void;
  32465. /**
  32466. * Gets the current stencil operation when stencil fails
  32467. * @returns a number defining stencil operation to use when stencil fails
  32468. */
  32469. getStencilOperationFail(): number;
  32470. /**
  32471. * Gets the current stencil operation when depth fails
  32472. * @returns a number defining stencil operation to use when depth fails
  32473. */
  32474. getStencilOperationDepthFail(): number;
  32475. /**
  32476. * Gets the current stencil operation when stencil passes
  32477. * @returns a number defining stencil operation to use when stencil passes
  32478. */
  32479. getStencilOperationPass(): number;
  32480. /**
  32481. * Sets the stencil operation to use when stencil fails
  32482. * @param operation defines the stencil operation to use when stencil fails
  32483. */
  32484. setStencilOperationFail(operation: number): void;
  32485. /**
  32486. * Sets the stencil operation to use when depth fails
  32487. * @param operation defines the stencil operation to use when depth fails
  32488. */
  32489. setStencilOperationDepthFail(operation: number): void;
  32490. /**
  32491. * Sets the stencil operation to use when stencil passes
  32492. * @param operation defines the stencil operation to use when stencil passes
  32493. */
  32494. setStencilOperationPass(operation: number): void;
  32495. /**
  32496. * Sets a boolean indicating if the dithering state is enabled or disabled
  32497. * @param value defines the dithering state
  32498. */
  32499. setDitheringState(value: boolean): void;
  32500. /**
  32501. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32502. * @param value defines the rasterizer state
  32503. */
  32504. setRasterizerState(value: boolean): void;
  32505. /**
  32506. * Gets the current depth function
  32507. * @returns a number defining the depth function
  32508. */
  32509. getDepthFunction(): Nullable<number>;
  32510. /**
  32511. * Sets the current depth function
  32512. * @param depthFunc defines the function to use
  32513. */
  32514. setDepthFunction(depthFunc: number): void;
  32515. /**
  32516. * Sets the current depth function to GREATER
  32517. */
  32518. setDepthFunctionToGreater(): void;
  32519. /**
  32520. * Sets the current depth function to GEQUAL
  32521. */
  32522. setDepthFunctionToGreaterOrEqual(): void;
  32523. /**
  32524. * Sets the current depth function to LESS
  32525. */
  32526. setDepthFunctionToLess(): void;
  32527. /**
  32528. * Sets the current depth function to LEQUAL
  32529. */
  32530. setDepthFunctionToLessOrEqual(): void;
  32531. private _cachedStencilBuffer;
  32532. private _cachedStencilFunction;
  32533. private _cachedStencilMask;
  32534. private _cachedStencilOperationPass;
  32535. private _cachedStencilOperationFail;
  32536. private _cachedStencilOperationDepthFail;
  32537. private _cachedStencilReference;
  32538. /**
  32539. * Caches the the state of the stencil buffer
  32540. */
  32541. cacheStencilState(): void;
  32542. /**
  32543. * Restores the state of the stencil buffer
  32544. */
  32545. restoreStencilState(): void;
  32546. /**
  32547. * Directly set the WebGL Viewport
  32548. * @param x defines the x coordinate of the viewport (in screen space)
  32549. * @param y defines the y coordinate of the viewport (in screen space)
  32550. * @param width defines the width of the viewport (in screen space)
  32551. * @param height defines the height of the viewport (in screen space)
  32552. * @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
  32553. */
  32554. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32555. /**
  32556. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32557. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32558. * @param y defines the y-coordinate of the corner of the clear rectangle
  32559. * @param width defines the width of the clear rectangle
  32560. * @param height defines the height of the clear rectangle
  32561. * @param clearColor defines the clear color
  32562. */
  32563. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32564. /**
  32565. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32566. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32567. * @param y defines the y-coordinate of the corner of the clear rectangle
  32568. * @param width defines the width of the clear rectangle
  32569. * @param height defines the height of the clear rectangle
  32570. */
  32571. enableScissor(x: number, y: number, width: number, height: number): void;
  32572. /**
  32573. * Disable previously set scissor test rectangle
  32574. */
  32575. disableScissor(): void;
  32576. protected _reportDrawCall(): void;
  32577. /**
  32578. * Initializes a webVR display and starts listening to display change events
  32579. * The onVRDisplayChangedObservable will be notified upon these changes
  32580. * @returns The onVRDisplayChangedObservable
  32581. */
  32582. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32583. /** @hidden */
  32584. _prepareVRComponent(): void;
  32585. /** @hidden */
  32586. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32587. /** @hidden */
  32588. _submitVRFrame(): void;
  32589. /**
  32590. * Call this function to leave webVR mode
  32591. * Will do nothing if webVR is not supported or if there is no webVR device
  32592. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32593. */
  32594. disableVR(): void;
  32595. /**
  32596. * Gets a boolean indicating that the system is in VR mode and is presenting
  32597. * @returns true if VR mode is engaged
  32598. */
  32599. isVRPresenting(): boolean;
  32600. /** @hidden */
  32601. _requestVRFrame(): void;
  32602. /** @hidden */
  32603. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32604. /**
  32605. * Gets the source code of the vertex shader associated with a specific webGL program
  32606. * @param program defines the program to use
  32607. * @returns a string containing the source code of the vertex shader associated with the program
  32608. */
  32609. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32610. /**
  32611. * Gets the source code of the fragment shader associated with a specific webGL program
  32612. * @param program defines the program to use
  32613. * @returns a string containing the source code of the fragment shader associated with the program
  32614. */
  32615. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32616. /**
  32617. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32618. * @param x defines the x coordinate of the rectangle where pixels must be read
  32619. * @param y defines the y coordinate of the rectangle where pixels must be read
  32620. * @param width defines the width of the rectangle where pixels must be read
  32621. * @param height defines the height of the rectangle where pixels must be read
  32622. * @returns a Uint8Array containing RGBA colors
  32623. */
  32624. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32625. /**
  32626. * Sets a depth stencil texture from a render target to the according uniform.
  32627. * @param channel The texture channel
  32628. * @param uniform The uniform to set
  32629. * @param texture The render target texture containing the depth stencil texture to apply
  32630. */
  32631. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32632. /**
  32633. * Sets a texture to the webGL context from a postprocess
  32634. * @param channel defines the channel to use
  32635. * @param postProcess defines the source postprocess
  32636. */
  32637. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32638. /**
  32639. * Binds the output of the passed in post process to the texture channel specified
  32640. * @param channel The channel the texture should be bound to
  32641. * @param postProcess The post process which's output should be bound
  32642. */
  32643. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32644. /** @hidden */
  32645. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32646. protected _rebuildBuffers(): void;
  32647. /** @hidden */
  32648. _renderFrame(): void;
  32649. _renderLoop(): void;
  32650. /** @hidden */
  32651. _renderViews(): boolean;
  32652. /**
  32653. * Toggle full screen mode
  32654. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32655. */
  32656. switchFullscreen(requestPointerLock: boolean): void;
  32657. /**
  32658. * Enters full screen mode
  32659. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32660. */
  32661. enterFullscreen(requestPointerLock: boolean): void;
  32662. /**
  32663. * Exits full screen mode
  32664. */
  32665. exitFullscreen(): void;
  32666. /**
  32667. * Enters Pointerlock mode
  32668. */
  32669. enterPointerlock(): void;
  32670. /**
  32671. * Exits Pointerlock mode
  32672. */
  32673. exitPointerlock(): void;
  32674. /**
  32675. * Begin a new frame
  32676. */
  32677. beginFrame(): void;
  32678. /**
  32679. * Enf the current frame
  32680. */
  32681. endFrame(): void;
  32682. resize(): void;
  32683. /**
  32684. * Set the compressed texture format to use, based on the formats you have, and the formats
  32685. * supported by the hardware / browser.
  32686. *
  32687. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32688. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32689. * to API arguments needed to compressed textures. This puts the burden on the container
  32690. * generator to house the arcane code for determining these for current & future formats.
  32691. *
  32692. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32693. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32694. *
  32695. * Note: The result of this call is not taken into account when a texture is base64.
  32696. *
  32697. * @param formatsAvailable defines the list of those format families you have created
  32698. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32699. *
  32700. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32701. * @returns The extension selected.
  32702. */
  32703. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32704. /**
  32705. * Force a specific size of the canvas
  32706. * @param width defines the new canvas' width
  32707. * @param height defines the new canvas' height
  32708. */
  32709. setSize(width: number, height: number): void;
  32710. /**
  32711. * Updates a dynamic vertex buffer.
  32712. * @param vertexBuffer the vertex buffer to update
  32713. * @param data the data used to update the vertex buffer
  32714. * @param byteOffset the byte offset of the data
  32715. * @param byteLength the byte length of the data
  32716. */
  32717. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32718. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32719. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32720. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32721. _releaseTexture(texture: InternalTexture): void;
  32722. /**
  32723. * @hidden
  32724. * Rescales a texture
  32725. * @param source input texutre
  32726. * @param destination destination texture
  32727. * @param scene scene to use to render the resize
  32728. * @param internalFormat format to use when resizing
  32729. * @param onComplete callback to be called when resize has completed
  32730. */
  32731. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32732. /**
  32733. * Gets the current framerate
  32734. * @returns a number representing the framerate
  32735. */
  32736. getFps(): number;
  32737. /**
  32738. * Gets the time spent between current and previous frame
  32739. * @returns a number representing the delta time in ms
  32740. */
  32741. getDeltaTime(): number;
  32742. private _measureFps;
  32743. /** @hidden */
  32744. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32745. /**
  32746. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32747. * @param renderTarget The render target to set the frame buffer for
  32748. */
  32749. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32750. /**
  32751. * Update a dynamic index buffer
  32752. * @param indexBuffer defines the target index buffer
  32753. * @param indices defines the data to update
  32754. * @param offset defines the offset in the target index buffer where update should start
  32755. */
  32756. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32757. /**
  32758. * Updates the sample count of a render target texture
  32759. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32760. * @param texture defines the texture to update
  32761. * @param samples defines the sample count to set
  32762. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32763. */
  32764. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32765. /**
  32766. * Updates a depth texture Comparison Mode and Function.
  32767. * If the comparison Function is equal to 0, the mode will be set to none.
  32768. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32769. * @param texture The texture to set the comparison function for
  32770. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32771. */
  32772. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32773. /**
  32774. * Creates a webGL buffer to use with instanciation
  32775. * @param capacity defines the size of the buffer
  32776. * @returns the webGL buffer
  32777. */
  32778. createInstancesBuffer(capacity: number): DataBuffer;
  32779. /**
  32780. * Delete a webGL buffer used with instanciation
  32781. * @param buffer defines the webGL buffer to delete
  32782. */
  32783. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32784. /** @hidden */
  32785. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32786. dispose(): void;
  32787. private _disableTouchAction;
  32788. /**
  32789. * Display the loading screen
  32790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32791. */
  32792. displayLoadingUI(): void;
  32793. /**
  32794. * Hide the loading screen
  32795. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32796. */
  32797. hideLoadingUI(): void;
  32798. /**
  32799. * Gets the current loading screen object
  32800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32801. */
  32802. /**
  32803. * Sets the current loading screen object
  32804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32805. */
  32806. loadingScreen: ILoadingScreen;
  32807. /**
  32808. * Sets the current loading screen text
  32809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32810. */
  32811. loadingUIText: string;
  32812. /**
  32813. * Sets the current loading screen background color
  32814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32815. */
  32816. loadingUIBackgroundColor: string;
  32817. /** Pointerlock and fullscreen */
  32818. /**
  32819. * Ask the browser to promote the current element to pointerlock mode
  32820. * @param element defines the DOM element to promote
  32821. */
  32822. static _RequestPointerlock(element: HTMLElement): void;
  32823. /**
  32824. * Asks the browser to exit pointerlock mode
  32825. */
  32826. static _ExitPointerlock(): void;
  32827. /**
  32828. * Ask the browser to promote the current element to fullscreen rendering mode
  32829. * @param element defines the DOM element to promote
  32830. */
  32831. static _RequestFullscreen(element: HTMLElement): void;
  32832. /**
  32833. * Asks the browser to exit fullscreen mode
  32834. */
  32835. static _ExitFullscreen(): void;
  32836. }
  32837. }
  32838. declare module "babylonjs/Engines/engineStore" {
  32839. import { Nullable } from "babylonjs/types";
  32840. import { Engine } from "babylonjs/Engines/engine";
  32841. import { Scene } from "babylonjs/scene";
  32842. /**
  32843. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32844. * during the life time of the application.
  32845. */
  32846. export class EngineStore {
  32847. /** Gets the list of created engines */
  32848. static Instances: import("babylonjs/Engines/engine").Engine[];
  32849. /** @hidden */
  32850. static _LastCreatedScene: Nullable<Scene>;
  32851. /**
  32852. * Gets the latest created engine
  32853. */
  32854. static readonly LastCreatedEngine: Nullable<Engine>;
  32855. /**
  32856. * Gets the latest created scene
  32857. */
  32858. static readonly LastCreatedScene: Nullable<Scene>;
  32859. /**
  32860. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32861. * @ignorenaming
  32862. */
  32863. static UseFallbackTexture: boolean;
  32864. /**
  32865. * Texture content used if a texture cannot loaded
  32866. * @ignorenaming
  32867. */
  32868. static FallbackTexture: string;
  32869. }
  32870. }
  32871. declare module "babylonjs/Misc/promise" {
  32872. /**
  32873. * Helper class that provides a small promise polyfill
  32874. */
  32875. export class PromisePolyfill {
  32876. /**
  32877. * Static function used to check if the polyfill is required
  32878. * If this is the case then the function will inject the polyfill to window.Promise
  32879. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32880. */
  32881. static Apply(force?: boolean): void;
  32882. }
  32883. }
  32884. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32885. /**
  32886. * Interface for screenshot methods with describe argument called `size` as object with options
  32887. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32888. */
  32889. export interface IScreenshotSize {
  32890. /**
  32891. * number in pixels for canvas height
  32892. */
  32893. height?: number;
  32894. /**
  32895. * multiplier allowing render at a higher or lower resolution
  32896. * If value is defined then height and width will be ignored and taken from camera
  32897. */
  32898. precision?: number;
  32899. /**
  32900. * number in pixels for canvas width
  32901. */
  32902. width?: number;
  32903. }
  32904. }
  32905. declare module "babylonjs/Misc/tools" {
  32906. import { Nullable, float } from "babylonjs/types";
  32907. import { DomManagement } from "babylonjs/Misc/domManagement";
  32908. import { WebRequest } from "babylonjs/Misc/webRequest";
  32909. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32910. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32911. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32912. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32913. import { Camera } from "babylonjs/Cameras/camera";
  32914. import { Engine } from "babylonjs/Engines/engine";
  32915. interface IColor4Like {
  32916. r: float;
  32917. g: float;
  32918. b: float;
  32919. a: float;
  32920. }
  32921. /**
  32922. * Class containing a set of static utilities functions
  32923. */
  32924. export class Tools {
  32925. /**
  32926. * Gets or sets the base URL to use to load assets
  32927. */
  32928. static BaseUrl: string;
  32929. /**
  32930. * Enable/Disable Custom HTTP Request Headers globally.
  32931. * default = false
  32932. * @see CustomRequestHeaders
  32933. */
  32934. static UseCustomRequestHeaders: boolean;
  32935. /**
  32936. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32937. * i.e. when loading files, where the server/service expects an Authorization header
  32938. */
  32939. static CustomRequestHeaders: {
  32940. [key: string]: string;
  32941. };
  32942. /**
  32943. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32944. */
  32945. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32946. /**
  32947. * Default behaviour for cors in the application.
  32948. * It can be a string if the expected behavior is identical in the entire app.
  32949. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32950. */
  32951. static CorsBehavior: string | ((url: string | string[]) => string);
  32952. /**
  32953. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32954. * @ignorenaming
  32955. */
  32956. static UseFallbackTexture: boolean;
  32957. /**
  32958. * Use this object to register external classes like custom textures or material
  32959. * to allow the laoders to instantiate them
  32960. */
  32961. static RegisteredExternalClasses: {
  32962. [key: string]: Object;
  32963. };
  32964. /**
  32965. * Texture content used if a texture cannot loaded
  32966. * @ignorenaming
  32967. */
  32968. static fallbackTexture: string;
  32969. /**
  32970. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32971. * @param u defines the coordinate on X axis
  32972. * @param v defines the coordinate on Y axis
  32973. * @param width defines the width of the source data
  32974. * @param height defines the height of the source data
  32975. * @param pixels defines the source byte array
  32976. * @param color defines the output color
  32977. */
  32978. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32979. /**
  32980. * Interpolates between a and b via alpha
  32981. * @param a The lower value (returned when alpha = 0)
  32982. * @param b The upper value (returned when alpha = 1)
  32983. * @param alpha The interpolation-factor
  32984. * @return The mixed value
  32985. */
  32986. static Mix(a: number, b: number, alpha: number): number;
  32987. /**
  32988. * Tries to instantiate a new object from a given class name
  32989. * @param className defines the class name to instantiate
  32990. * @returns the new object or null if the system was not able to do the instantiation
  32991. */
  32992. static Instantiate(className: string): any;
  32993. /**
  32994. * Provides a slice function that will work even on IE
  32995. * @param data defines the array to slice
  32996. * @param start defines the start of the data (optional)
  32997. * @param end defines the end of the data (optional)
  32998. * @returns the new sliced array
  32999. */
  33000. static Slice<T>(data: T, start?: number, end?: number): T;
  33001. /**
  33002. * Polyfill for setImmediate
  33003. * @param action defines the action to execute after the current execution block
  33004. */
  33005. static SetImmediate(action: () => void): void;
  33006. /**
  33007. * Function indicating if a number is an exponent of 2
  33008. * @param value defines the value to test
  33009. * @returns true if the value is an exponent of 2
  33010. */
  33011. static IsExponentOfTwo(value: number): boolean;
  33012. private static _tmpFloatArray;
  33013. /**
  33014. * Returns the nearest 32-bit single precision float representation of a Number
  33015. * @param value A Number. If the parameter is of a different type, it will get converted
  33016. * to a number or to NaN if it cannot be converted
  33017. * @returns number
  33018. */
  33019. static FloatRound(value: number): number;
  33020. /**
  33021. * Extracts the filename from a path
  33022. * @param path defines the path to use
  33023. * @returns the filename
  33024. */
  33025. static GetFilename(path: string): string;
  33026. /**
  33027. * Extracts the "folder" part of a path (everything before the filename).
  33028. * @param uri The URI to extract the info from
  33029. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33030. * @returns The "folder" part of the path
  33031. */
  33032. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33033. /**
  33034. * Extracts text content from a DOM element hierarchy
  33035. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33036. */
  33037. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33038. /**
  33039. * Convert an angle in radians to degrees
  33040. * @param angle defines the angle to convert
  33041. * @returns the angle in degrees
  33042. */
  33043. static ToDegrees(angle: number): number;
  33044. /**
  33045. * Convert an angle in degrees to radians
  33046. * @param angle defines the angle to convert
  33047. * @returns the angle in radians
  33048. */
  33049. static ToRadians(angle: number): number;
  33050. /**
  33051. * Returns an array if obj is not an array
  33052. * @param obj defines the object to evaluate as an array
  33053. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33054. * @returns either obj directly if obj is an array or a new array containing obj
  33055. */
  33056. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33057. /**
  33058. * Gets the pointer prefix to use
  33059. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33060. */
  33061. static GetPointerPrefix(): string;
  33062. /**
  33063. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33064. * @param url define the url we are trying
  33065. * @param element define the dom element where to configure the cors policy
  33066. */
  33067. static SetCorsBehavior(url: string | string[], element: {
  33068. crossOrigin: string | null;
  33069. }): void;
  33070. /**
  33071. * Removes unwanted characters from an url
  33072. * @param url defines the url to clean
  33073. * @returns the cleaned url
  33074. */
  33075. static CleanUrl(url: string): string;
  33076. /**
  33077. * Gets or sets a function used to pre-process url before using them to load assets
  33078. */
  33079. static PreprocessUrl: (url: string) => string;
  33080. /**
  33081. * Loads an image as an HTMLImageElement.
  33082. * @param input url string, ArrayBuffer, or Blob to load
  33083. * @param onLoad callback called when the image successfully loads
  33084. * @param onError callback called when the image fails to load
  33085. * @param offlineProvider offline provider for caching
  33086. * @param mimeType optional mime type
  33087. * @returns the HTMLImageElement of the loaded image
  33088. */
  33089. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33090. /**
  33091. * Loads a file from a url
  33092. * @param url url string, ArrayBuffer, or Blob to load
  33093. * @param onSuccess callback called when the file successfully loads
  33094. * @param onProgress callback called while file is loading (if the server supports this mode)
  33095. * @param offlineProvider defines the offline provider for caching
  33096. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33097. * @param onError callback called when the file fails to load
  33098. * @returns a file request object
  33099. */
  33100. 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;
  33101. /**
  33102. * Loads a file from a url
  33103. * @param url the file url to load
  33104. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33105. */
  33106. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33107. /**
  33108. * Load a script (identified by an url). When the url returns, the
  33109. * content of this file is added into a new script element, attached to the DOM (body element)
  33110. * @param scriptUrl defines the url of the script to laod
  33111. * @param onSuccess defines the callback called when the script is loaded
  33112. * @param onError defines the callback to call if an error occurs
  33113. * @param scriptId defines the id of the script element
  33114. */
  33115. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33116. /**
  33117. * Load an asynchronous script (identified by an url). When the url returns, the
  33118. * content of this file is added into a new script element, attached to the DOM (body element)
  33119. * @param scriptUrl defines the url of the script to laod
  33120. * @param scriptId defines the id of the script element
  33121. * @returns a promise request object
  33122. */
  33123. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33124. /**
  33125. * Loads a file from a blob
  33126. * @param fileToLoad defines the blob to use
  33127. * @param callback defines the callback to call when data is loaded
  33128. * @param progressCallback defines the callback to call during loading process
  33129. * @returns a file request object
  33130. */
  33131. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33132. /**
  33133. * Reads a file from a File object
  33134. * @param file defines the file to load
  33135. * @param onSuccess defines the callback to call when data is loaded
  33136. * @param onProgress defines the callback to call during loading process
  33137. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33138. * @param onError defines the callback to call when an error occurs
  33139. * @returns a file request object
  33140. */
  33141. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33142. /**
  33143. * Creates a data url from a given string content
  33144. * @param content defines the content to convert
  33145. * @returns the new data url link
  33146. */
  33147. static FileAsURL(content: string): string;
  33148. /**
  33149. * Format the given number to a specific decimal format
  33150. * @param value defines the number to format
  33151. * @param decimals defines the number of decimals to use
  33152. * @returns the formatted string
  33153. */
  33154. static Format(value: number, decimals?: number): string;
  33155. /**
  33156. * Tries to copy an object by duplicating every property
  33157. * @param source defines the source object
  33158. * @param destination defines the target object
  33159. * @param doNotCopyList defines a list of properties to avoid
  33160. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33161. */
  33162. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33163. /**
  33164. * Gets a boolean indicating if the given object has no own property
  33165. * @param obj defines the object to test
  33166. * @returns true if object has no own property
  33167. */
  33168. static IsEmpty(obj: any): boolean;
  33169. /**
  33170. * Function used to register events at window level
  33171. * @param windowElement defines the Window object to use
  33172. * @param events defines the events to register
  33173. */
  33174. static RegisterTopRootEvents(windowElement: Window, events: {
  33175. name: string;
  33176. handler: Nullable<(e: FocusEvent) => any>;
  33177. }[]): void;
  33178. /**
  33179. * Function used to unregister events from window level
  33180. * @param windowElement defines the Window object to use
  33181. * @param events defines the events to unregister
  33182. */
  33183. static UnregisterTopRootEvents(windowElement: Window, events: {
  33184. name: string;
  33185. handler: Nullable<(e: FocusEvent) => any>;
  33186. }[]): void;
  33187. /**
  33188. * @ignore
  33189. */
  33190. static _ScreenshotCanvas: HTMLCanvasElement;
  33191. /**
  33192. * Dumps the current bound framebuffer
  33193. * @param width defines the rendering width
  33194. * @param height defines the rendering height
  33195. * @param engine defines the hosting engine
  33196. * @param successCallback defines the callback triggered once the data are available
  33197. * @param mimeType defines the mime type of the result
  33198. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33199. */
  33200. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33201. /**
  33202. * Converts the canvas data to blob.
  33203. * This acts as a polyfill for browsers not supporting the to blob function.
  33204. * @param canvas Defines the canvas to extract the data from
  33205. * @param successCallback Defines the callback triggered once the data are available
  33206. * @param mimeType Defines the mime type of the result
  33207. */
  33208. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33209. /**
  33210. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33211. * @param successCallback defines the callback triggered once the data are available
  33212. * @param mimeType defines the mime type of the result
  33213. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33214. */
  33215. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33216. /**
  33217. * Downloads a blob in the browser
  33218. * @param blob defines the blob to download
  33219. * @param fileName defines the name of the downloaded file
  33220. */
  33221. static Download(blob: Blob, fileName: string): void;
  33222. /**
  33223. * Captures a screenshot of the current rendering
  33224. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33225. * @param engine defines the rendering engine
  33226. * @param camera defines the source camera
  33227. * @param size This parameter can be set to a single number or to an object with the
  33228. * following (optional) properties: precision, width, height. If a single number is passed,
  33229. * it will be used for both width and height. If an object is passed, the screenshot size
  33230. * will be derived from the parameters. The precision property is a multiplier allowing
  33231. * rendering at a higher or lower resolution
  33232. * @param successCallback defines the callback receives a single parameter which contains the
  33233. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33234. * src parameter of an <img> to display it
  33235. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33236. * Check your browser for supported MIME types
  33237. */
  33238. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33239. /**
  33240. * Captures a screenshot of the current rendering
  33241. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33242. * @param engine defines the rendering engine
  33243. * @param camera defines the source camera
  33244. * @param size This parameter can be set to a single number or to an object with the
  33245. * following (optional) properties: precision, width, height. If a single number is passed,
  33246. * it will be used for both width and height. If an object is passed, the screenshot size
  33247. * will be derived from the parameters. The precision property is a multiplier allowing
  33248. * rendering at a higher or lower resolution
  33249. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33250. * Check your browser for supported MIME types
  33251. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33252. * to the src parameter of an <img> to display it
  33253. */
  33254. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33255. /**
  33256. * Generates an image screenshot from the specified camera.
  33257. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33258. * @param engine The engine to use for rendering
  33259. * @param camera The camera to use for rendering
  33260. * @param size This parameter can be set to a single number or to an object with the
  33261. * following (optional) properties: precision, width, height. If a single number is passed,
  33262. * it will be used for both width and height. If an object is passed, the screenshot size
  33263. * will be derived from the parameters. The precision property is a multiplier allowing
  33264. * rendering at a higher or lower resolution
  33265. * @param successCallback The callback receives a single parameter which contains the
  33266. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33267. * src parameter of an <img> to display it
  33268. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33269. * Check your browser for supported MIME types
  33270. * @param samples Texture samples (default: 1)
  33271. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33272. * @param fileName A name for for the downloaded file.
  33273. */
  33274. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33275. /**
  33276. * Generates an image screenshot from the specified camera.
  33277. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33278. * @param engine The engine to use for rendering
  33279. * @param camera The camera to use for rendering
  33280. * @param size This parameter can be set to a single number or to an object with the
  33281. * following (optional) properties: precision, width, height. If a single number is passed,
  33282. * it will be used for both width and height. If an object is passed, the screenshot size
  33283. * will be derived from the parameters. The precision property is a multiplier allowing
  33284. * rendering at a higher or lower resolution
  33285. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33286. * Check your browser for supported MIME types
  33287. * @param samples Texture samples (default: 1)
  33288. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33289. * @param fileName A name for for the downloaded file.
  33290. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33291. * to the src parameter of an <img> to display it
  33292. */
  33293. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33294. /**
  33295. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33296. * Be aware Math.random() could cause collisions, but:
  33297. * "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"
  33298. * @returns a pseudo random id
  33299. */
  33300. static RandomId(): string;
  33301. /**
  33302. * Test if the given uri is a base64 string
  33303. * @param uri The uri to test
  33304. * @return True if the uri is a base64 string or false otherwise
  33305. */
  33306. static IsBase64(uri: string): boolean;
  33307. /**
  33308. * Decode the given base64 uri.
  33309. * @param uri The uri to decode
  33310. * @return The decoded base64 data.
  33311. */
  33312. static DecodeBase64(uri: string): ArrayBuffer;
  33313. /**
  33314. * Gets the absolute url.
  33315. * @param url the input url
  33316. * @return the absolute url
  33317. */
  33318. static GetAbsoluteUrl(url: string): string;
  33319. /**
  33320. * No log
  33321. */
  33322. static readonly NoneLogLevel: number;
  33323. /**
  33324. * Only message logs
  33325. */
  33326. static readonly MessageLogLevel: number;
  33327. /**
  33328. * Only warning logs
  33329. */
  33330. static readonly WarningLogLevel: number;
  33331. /**
  33332. * Only error logs
  33333. */
  33334. static readonly ErrorLogLevel: number;
  33335. /**
  33336. * All logs
  33337. */
  33338. static readonly AllLogLevel: number;
  33339. /**
  33340. * Gets a value indicating the number of loading errors
  33341. * @ignorenaming
  33342. */
  33343. static readonly errorsCount: number;
  33344. /**
  33345. * Callback called when a new log is added
  33346. */
  33347. static OnNewCacheEntry: (entry: string) => void;
  33348. /**
  33349. * Log a message to the console
  33350. * @param message defines the message to log
  33351. */
  33352. static Log(message: string): void;
  33353. /**
  33354. * Write a warning message to the console
  33355. * @param message defines the message to log
  33356. */
  33357. static Warn(message: string): void;
  33358. /**
  33359. * Write an error message to the console
  33360. * @param message defines the message to log
  33361. */
  33362. static Error(message: string): void;
  33363. /**
  33364. * Gets current log cache (list of logs)
  33365. */
  33366. static readonly LogCache: string;
  33367. /**
  33368. * Clears the log cache
  33369. */
  33370. static ClearLogCache(): void;
  33371. /**
  33372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33373. */
  33374. static LogLevels: number;
  33375. /**
  33376. * Checks if the window object exists
  33377. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33378. */
  33379. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33380. /**
  33381. * No performance log
  33382. */
  33383. static readonly PerformanceNoneLogLevel: number;
  33384. /**
  33385. * Use user marks to log performance
  33386. */
  33387. static readonly PerformanceUserMarkLogLevel: number;
  33388. /**
  33389. * Log performance to the console
  33390. */
  33391. static readonly PerformanceConsoleLogLevel: number;
  33392. private static _performance;
  33393. /**
  33394. * Sets the current performance log level
  33395. */
  33396. static PerformanceLogLevel: number;
  33397. private static _StartPerformanceCounterDisabled;
  33398. private static _EndPerformanceCounterDisabled;
  33399. private static _StartUserMark;
  33400. private static _EndUserMark;
  33401. private static _StartPerformanceConsole;
  33402. private static _EndPerformanceConsole;
  33403. /**
  33404. * Starts a performance counter
  33405. */
  33406. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33407. /**
  33408. * Ends a specific performance coutner
  33409. */
  33410. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33411. /**
  33412. * Gets either window.performance.now() if supported or Date.now() else
  33413. */
  33414. static readonly Now: number;
  33415. /**
  33416. * This method will return the name of the class used to create the instance of the given object.
  33417. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33418. * @param object the object to get the class name from
  33419. * @param isType defines if the object is actually a type
  33420. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33421. */
  33422. static GetClassName(object: any, isType?: boolean): string;
  33423. /**
  33424. * Gets the first element of an array satisfying a given predicate
  33425. * @param array defines the array to browse
  33426. * @param predicate defines the predicate to use
  33427. * @returns null if not found or the element
  33428. */
  33429. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33430. /**
  33431. * This method will return the name of the full name of the class, including its owning module (if any).
  33432. * 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).
  33433. * @param object the object to get the class name from
  33434. * @param isType defines if the object is actually a type
  33435. * @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.
  33436. * @ignorenaming
  33437. */
  33438. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33439. /**
  33440. * Returns a promise that resolves after the given amount of time.
  33441. * @param delay Number of milliseconds to delay
  33442. * @returns Promise that resolves after the given amount of time
  33443. */
  33444. static DelayAsync(delay: number): Promise<void>;
  33445. }
  33446. /**
  33447. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33448. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33449. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33450. * @param name The name of the class, case should be preserved
  33451. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33452. */
  33453. export function className(name: string, module?: string): (target: Object) => void;
  33454. /**
  33455. * An implementation of a loop for asynchronous functions.
  33456. */
  33457. export class AsyncLoop {
  33458. /**
  33459. * Defines the number of iterations for the loop
  33460. */
  33461. iterations: number;
  33462. /**
  33463. * Defines the current index of the loop.
  33464. */
  33465. index: number;
  33466. private _done;
  33467. private _fn;
  33468. private _successCallback;
  33469. /**
  33470. * Constructor.
  33471. * @param iterations the number of iterations.
  33472. * @param func the function to run each iteration
  33473. * @param successCallback the callback that will be called upon succesful execution
  33474. * @param offset starting offset.
  33475. */
  33476. constructor(
  33477. /**
  33478. * Defines the number of iterations for the loop
  33479. */
  33480. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33481. /**
  33482. * Execute the next iteration. Must be called after the last iteration was finished.
  33483. */
  33484. executeNext(): void;
  33485. /**
  33486. * Break the loop and run the success callback.
  33487. */
  33488. breakLoop(): void;
  33489. /**
  33490. * Create and run an async loop.
  33491. * @param iterations the number of iterations.
  33492. * @param fn the function to run each iteration
  33493. * @param successCallback the callback that will be called upon succesful execution
  33494. * @param offset starting offset.
  33495. * @returns the created async loop object
  33496. */
  33497. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33498. /**
  33499. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33500. * @param iterations total number of iterations
  33501. * @param syncedIterations number of synchronous iterations in each async iteration.
  33502. * @param fn the function to call each iteration.
  33503. * @param callback a success call back that will be called when iterating stops.
  33504. * @param breakFunction a break condition (optional)
  33505. * @param timeout timeout settings for the setTimeout function. default - 0.
  33506. * @returns the created async loop object
  33507. */
  33508. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33509. }
  33510. }
  33511. declare module "babylonjs/Misc/stringDictionary" {
  33512. import { Nullable } from "babylonjs/types";
  33513. /**
  33514. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33515. * The underlying implementation relies on an associative array to ensure the best performances.
  33516. * The value can be anything including 'null' but except 'undefined'
  33517. */
  33518. export class StringDictionary<T> {
  33519. /**
  33520. * This will clear this dictionary and copy the content from the 'source' one.
  33521. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33522. * @param source the dictionary to take the content from and copy to this dictionary
  33523. */
  33524. copyFrom(source: StringDictionary<T>): void;
  33525. /**
  33526. * Get a value based from its key
  33527. * @param key the given key to get the matching value from
  33528. * @return the value if found, otherwise undefined is returned
  33529. */
  33530. get(key: string): T | undefined;
  33531. /**
  33532. * Get a value from its key or add it if it doesn't exist.
  33533. * This method will ensure you that a given key/data will be present in the dictionary.
  33534. * @param key the given key to get the matching value from
  33535. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33536. * The factory will only be invoked if there's no data for the given key.
  33537. * @return the value corresponding to the key.
  33538. */
  33539. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33540. /**
  33541. * Get a value from its key if present in the dictionary otherwise add it
  33542. * @param key the key to get the value from
  33543. * @param val if there's no such key/value pair in the dictionary add it with this value
  33544. * @return the value corresponding to the key
  33545. */
  33546. getOrAdd(key: string, val: T): T;
  33547. /**
  33548. * Check if there's a given key in the dictionary
  33549. * @param key the key to check for
  33550. * @return true if the key is present, false otherwise
  33551. */
  33552. contains(key: string): boolean;
  33553. /**
  33554. * Add a new key and its corresponding value
  33555. * @param key the key to add
  33556. * @param value the value corresponding to the key
  33557. * @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
  33558. */
  33559. add(key: string, value: T): boolean;
  33560. /**
  33561. * Update a specific value associated to a key
  33562. * @param key defines the key to use
  33563. * @param value defines the value to store
  33564. * @returns true if the value was updated (or false if the key was not found)
  33565. */
  33566. set(key: string, value: T): boolean;
  33567. /**
  33568. * Get the element of the given key and remove it from the dictionary
  33569. * @param key defines the key to search
  33570. * @returns the value associated with the key or null if not found
  33571. */
  33572. getAndRemove(key: string): Nullable<T>;
  33573. /**
  33574. * Remove a key/value from the dictionary.
  33575. * @param key the key to remove
  33576. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33577. */
  33578. remove(key: string): boolean;
  33579. /**
  33580. * Clear the whole content of the dictionary
  33581. */
  33582. clear(): void;
  33583. /**
  33584. * Gets the current count
  33585. */
  33586. readonly count: number;
  33587. /**
  33588. * Execute a callback on each key/val of the dictionary.
  33589. * Note that you can remove any element in this dictionary in the callback implementation
  33590. * @param callback the callback to execute on a given key/value pair
  33591. */
  33592. forEach(callback: (key: string, val: T) => void): void;
  33593. /**
  33594. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33595. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33596. * Note that you can remove any element in this dictionary in the callback implementation
  33597. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33598. * @returns the first item
  33599. */
  33600. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33601. private _count;
  33602. private _data;
  33603. }
  33604. }
  33605. declare module "babylonjs/Collisions/collisionCoordinator" {
  33606. import { Nullable } from "babylonjs/types";
  33607. import { Scene } from "babylonjs/scene";
  33608. import { Vector3 } from "babylonjs/Maths/math.vector";
  33609. import { Collider } from "babylonjs/Collisions/collider";
  33610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33611. /** @hidden */
  33612. export interface ICollisionCoordinator {
  33613. createCollider(): Collider;
  33614. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33615. init(scene: Scene): void;
  33616. }
  33617. /** @hidden */
  33618. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33619. private _scene;
  33620. private _scaledPosition;
  33621. private _scaledVelocity;
  33622. private _finalPosition;
  33623. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33624. createCollider(): Collider;
  33625. init(scene: Scene): void;
  33626. private _collideWithWorld;
  33627. }
  33628. }
  33629. declare module "babylonjs/Inputs/scene.inputManager" {
  33630. import { Nullable } from "babylonjs/types";
  33631. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33632. import { Vector2 } from "babylonjs/Maths/math.vector";
  33633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33634. import { Scene } from "babylonjs/scene";
  33635. /**
  33636. * Class used to manage all inputs for the scene.
  33637. */
  33638. export class InputManager {
  33639. /** The distance in pixel that you have to move to prevent some events */
  33640. static DragMovementThreshold: number;
  33641. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33642. static LongPressDelay: number;
  33643. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33644. static DoubleClickDelay: number;
  33645. /** If you need to check double click without raising a single click at first click, enable this flag */
  33646. static ExclusiveDoubleClickMode: boolean;
  33647. private _wheelEventName;
  33648. private _onPointerMove;
  33649. private _onPointerDown;
  33650. private _onPointerUp;
  33651. private _initClickEvent;
  33652. private _initActionManager;
  33653. private _delayedSimpleClick;
  33654. private _delayedSimpleClickTimeout;
  33655. private _previousDelayedSimpleClickTimeout;
  33656. private _meshPickProceed;
  33657. private _previousButtonPressed;
  33658. private _currentPickResult;
  33659. private _previousPickResult;
  33660. private _totalPointersPressed;
  33661. private _doubleClickOccured;
  33662. private _pointerOverMesh;
  33663. private _pickedDownMesh;
  33664. private _pickedUpMesh;
  33665. private _pointerX;
  33666. private _pointerY;
  33667. private _unTranslatedPointerX;
  33668. private _unTranslatedPointerY;
  33669. private _startingPointerPosition;
  33670. private _previousStartingPointerPosition;
  33671. private _startingPointerTime;
  33672. private _previousStartingPointerTime;
  33673. private _pointerCaptures;
  33674. private _onKeyDown;
  33675. private _onKeyUp;
  33676. private _onCanvasFocusObserver;
  33677. private _onCanvasBlurObserver;
  33678. private _scene;
  33679. /**
  33680. * Creates a new InputManager
  33681. * @param scene defines the hosting scene
  33682. */
  33683. constructor(scene: Scene);
  33684. /**
  33685. * Gets the mesh that is currently under the pointer
  33686. */
  33687. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33688. /**
  33689. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33690. */
  33691. readonly unTranslatedPointer: Vector2;
  33692. /**
  33693. * Gets or sets the current on-screen X position of the pointer
  33694. */
  33695. pointerX: number;
  33696. /**
  33697. * Gets or sets the current on-screen Y position of the pointer
  33698. */
  33699. pointerY: number;
  33700. private _updatePointerPosition;
  33701. private _processPointerMove;
  33702. private _setRayOnPointerInfo;
  33703. private _checkPrePointerObservable;
  33704. /**
  33705. * Use this method to simulate a pointer move on a mesh
  33706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33709. */
  33710. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33711. /**
  33712. * Use this method to simulate a pointer down on a mesh
  33713. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33714. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33715. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33716. */
  33717. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33718. private _processPointerDown;
  33719. /** @hidden */
  33720. _isPointerSwiping(): boolean;
  33721. /**
  33722. * Use this method to simulate a pointer up on a mesh
  33723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33726. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33727. */
  33728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33729. private _processPointerUp;
  33730. /**
  33731. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33732. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33733. * @returns true if the pointer was captured
  33734. */
  33735. isPointerCaptured(pointerId?: number): boolean;
  33736. /**
  33737. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33738. * @param attachUp defines if you want to attach events to pointerup
  33739. * @param attachDown defines if you want to attach events to pointerdown
  33740. * @param attachMove defines if you want to attach events to pointermove
  33741. */
  33742. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33743. /**
  33744. * Detaches all event handlers
  33745. */
  33746. detachControl(): void;
  33747. /**
  33748. * Force the value of meshUnderPointer
  33749. * @param mesh defines the mesh to use
  33750. */
  33751. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33752. /**
  33753. * Gets the mesh under the pointer
  33754. * @returns a Mesh or null if no mesh is under the pointer
  33755. */
  33756. getPointerOverMesh(): Nullable<AbstractMesh>;
  33757. }
  33758. }
  33759. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33760. /**
  33761. * Helper class used to generate session unique ID
  33762. */
  33763. export class UniqueIdGenerator {
  33764. private static _UniqueIdCounter;
  33765. /**
  33766. * Gets an unique (relatively to the current scene) Id
  33767. */
  33768. static readonly UniqueId: number;
  33769. }
  33770. }
  33771. declare module "babylonjs/Animations/animationGroup" {
  33772. import { Animatable } from "babylonjs/Animations/animatable";
  33773. import { Animation } from "babylonjs/Animations/animation";
  33774. import { Scene, IDisposable } from "babylonjs/scene";
  33775. import { Observable } from "babylonjs/Misc/observable";
  33776. import { Nullable } from "babylonjs/types";
  33777. import "babylonjs/Animations/animatable";
  33778. /**
  33779. * This class defines the direct association between an animation and a target
  33780. */
  33781. export class TargetedAnimation {
  33782. /**
  33783. * Animation to perform
  33784. */
  33785. animation: Animation;
  33786. /**
  33787. * Target to animate
  33788. */
  33789. target: any;
  33790. /**
  33791. * Serialize the object
  33792. * @returns the JSON object representing the current entity
  33793. */
  33794. serialize(): any;
  33795. }
  33796. /**
  33797. * Use this class to create coordinated animations on multiple targets
  33798. */
  33799. export class AnimationGroup implements IDisposable {
  33800. /** The name of the animation group */
  33801. name: string;
  33802. private _scene;
  33803. private _targetedAnimations;
  33804. private _animatables;
  33805. private _from;
  33806. private _to;
  33807. private _isStarted;
  33808. private _isPaused;
  33809. private _speedRatio;
  33810. private _loopAnimation;
  33811. /**
  33812. * Gets or sets the unique id of the node
  33813. */
  33814. uniqueId: number;
  33815. /**
  33816. * This observable will notify when one animation have ended
  33817. */
  33818. onAnimationEndObservable: Observable<TargetedAnimation>;
  33819. /**
  33820. * Observer raised when one animation loops
  33821. */
  33822. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33823. /**
  33824. * Observer raised when all animations have looped
  33825. */
  33826. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33827. /**
  33828. * This observable will notify when all animations have ended.
  33829. */
  33830. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33831. /**
  33832. * This observable will notify when all animations have paused.
  33833. */
  33834. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33835. /**
  33836. * This observable will notify when all animations are playing.
  33837. */
  33838. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33839. /**
  33840. * Gets the first frame
  33841. */
  33842. readonly from: number;
  33843. /**
  33844. * Gets the last frame
  33845. */
  33846. readonly to: number;
  33847. /**
  33848. * Define if the animations are started
  33849. */
  33850. readonly isStarted: boolean;
  33851. /**
  33852. * Gets a value indicating that the current group is playing
  33853. */
  33854. readonly isPlaying: boolean;
  33855. /**
  33856. * Gets or sets the speed ratio to use for all animations
  33857. */
  33858. /**
  33859. * Gets or sets the speed ratio to use for all animations
  33860. */
  33861. speedRatio: number;
  33862. /**
  33863. * Gets or sets if all animations should loop or not
  33864. */
  33865. loopAnimation: boolean;
  33866. /**
  33867. * Gets the targeted animations for this animation group
  33868. */
  33869. readonly targetedAnimations: Array<TargetedAnimation>;
  33870. /**
  33871. * returning the list of animatables controlled by this animation group.
  33872. */
  33873. readonly animatables: Array<Animatable>;
  33874. /**
  33875. * Instantiates a new Animation Group.
  33876. * This helps managing several animations at once.
  33877. * @see http://doc.babylonjs.com/how_to/group
  33878. * @param name Defines the name of the group
  33879. * @param scene Defines the scene the group belongs to
  33880. */
  33881. constructor(
  33882. /** The name of the animation group */
  33883. name: string, scene?: Nullable<Scene>);
  33884. /**
  33885. * Add an animation (with its target) in the group
  33886. * @param animation defines the animation we want to add
  33887. * @param target defines the target of the animation
  33888. * @returns the TargetedAnimation object
  33889. */
  33890. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33891. /**
  33892. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33893. * It can add constant keys at begin or end
  33894. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33895. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33896. * @returns the animation group
  33897. */
  33898. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33899. private _animationLoopCount;
  33900. private _animationLoopFlags;
  33901. private _processLoop;
  33902. /**
  33903. * Start all animations on given targets
  33904. * @param loop defines if animations must loop
  33905. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33906. * @param from defines the from key (optional)
  33907. * @param to defines the to key (optional)
  33908. * @returns the current animation group
  33909. */
  33910. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33911. /**
  33912. * Pause all animations
  33913. * @returns the animation group
  33914. */
  33915. pause(): AnimationGroup;
  33916. /**
  33917. * Play all animations to initial state
  33918. * This function will start() the animations if they were not started or will restart() them if they were paused
  33919. * @param loop defines if animations must loop
  33920. * @returns the animation group
  33921. */
  33922. play(loop?: boolean): AnimationGroup;
  33923. /**
  33924. * Reset all animations to initial state
  33925. * @returns the animation group
  33926. */
  33927. reset(): AnimationGroup;
  33928. /**
  33929. * Restart animations from key 0
  33930. * @returns the animation group
  33931. */
  33932. restart(): AnimationGroup;
  33933. /**
  33934. * Stop all animations
  33935. * @returns the animation group
  33936. */
  33937. stop(): AnimationGroup;
  33938. /**
  33939. * Set animation weight for all animatables
  33940. * @param weight defines the weight to use
  33941. * @return the animationGroup
  33942. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33943. */
  33944. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33945. /**
  33946. * Synchronize and normalize all animatables with a source animatable
  33947. * @param root defines the root animatable to synchronize with
  33948. * @return the animationGroup
  33949. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33950. */
  33951. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33952. /**
  33953. * Goes to a specific frame in this animation group
  33954. * @param frame the frame number to go to
  33955. * @return the animationGroup
  33956. */
  33957. goToFrame(frame: number): AnimationGroup;
  33958. /**
  33959. * Dispose all associated resources
  33960. */
  33961. dispose(): void;
  33962. private _checkAnimationGroupEnded;
  33963. /**
  33964. * Clone the current animation group and returns a copy
  33965. * @param newName defines the name of the new group
  33966. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33967. * @returns the new aniamtion group
  33968. */
  33969. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33970. /**
  33971. * Serializes the animationGroup to an object
  33972. * @returns Serialized object
  33973. */
  33974. serialize(): any;
  33975. /**
  33976. * Returns a new AnimationGroup object parsed from the source provided.
  33977. * @param parsedAnimationGroup defines the source
  33978. * @param scene defines the scene that will receive the animationGroup
  33979. * @returns a new AnimationGroup
  33980. */
  33981. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33982. /**
  33983. * Returns the string "AnimationGroup"
  33984. * @returns "AnimationGroup"
  33985. */
  33986. getClassName(): string;
  33987. /**
  33988. * Creates a detailled string about the object
  33989. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33990. * @returns a string representing the object
  33991. */
  33992. toString(fullDetails?: boolean): string;
  33993. }
  33994. }
  33995. declare module "babylonjs/scene" {
  33996. import { Nullable } from "babylonjs/types";
  33997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33998. import { Observable } from "babylonjs/Misc/observable";
  33999. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34000. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34001. import { Geometry } from "babylonjs/Meshes/geometry";
  34002. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34003. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34005. import { Mesh } from "babylonjs/Meshes/mesh";
  34006. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34007. import { Bone } from "babylonjs/Bones/bone";
  34008. import { Skeleton } from "babylonjs/Bones/skeleton";
  34009. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34010. import { Camera } from "babylonjs/Cameras/camera";
  34011. import { AbstractScene } from "babylonjs/abstractScene";
  34012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34014. import { Material } from "babylonjs/Materials/material";
  34015. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34016. import { Effect } from "babylonjs/Materials/effect";
  34017. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34018. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34019. import { Light } from "babylonjs/Lights/light";
  34020. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34021. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34022. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34023. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34025. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34026. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34027. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34028. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34029. import { Engine } from "babylonjs/Engines/engine";
  34030. import { Node } from "babylonjs/node";
  34031. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34032. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34033. import { WebRequest } from "babylonjs/Misc/webRequest";
  34034. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34035. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34036. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34037. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34038. import { Plane } from "babylonjs/Maths/math.plane";
  34039. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34040. import { Ray } from "babylonjs/Culling/ray";
  34041. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34042. import { Animation } from "babylonjs/Animations/animation";
  34043. import { Animatable } from "babylonjs/Animations/animatable";
  34044. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34045. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34046. import { Collider } from "babylonjs/Collisions/collider";
  34047. /**
  34048. * Define an interface for all classes that will hold resources
  34049. */
  34050. export interface IDisposable {
  34051. /**
  34052. * Releases all held resources
  34053. */
  34054. dispose(): void;
  34055. }
  34056. /** Interface defining initialization parameters for Scene class */
  34057. export interface SceneOptions {
  34058. /**
  34059. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34060. * It will improve performance when the number of geometries becomes important.
  34061. */
  34062. useGeometryUniqueIdsMap?: boolean;
  34063. /**
  34064. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34065. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34066. */
  34067. useMaterialMeshMap?: boolean;
  34068. /**
  34069. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34071. */
  34072. useClonedMeshhMap?: boolean;
  34073. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34074. virtual?: boolean;
  34075. }
  34076. /**
  34077. * Represents a scene to be rendered by the engine.
  34078. * @see http://doc.babylonjs.com/features/scene
  34079. */
  34080. export class Scene extends AbstractScene implements IAnimatable {
  34081. /** The fog is deactivated */
  34082. static readonly FOGMODE_NONE: number;
  34083. /** The fog density is following an exponential function */
  34084. static readonly FOGMODE_EXP: number;
  34085. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34086. static readonly FOGMODE_EXP2: number;
  34087. /** The fog density is following a linear function. */
  34088. static readonly FOGMODE_LINEAR: number;
  34089. /**
  34090. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34092. */
  34093. static MinDeltaTime: number;
  34094. /**
  34095. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34097. */
  34098. static MaxDeltaTime: number;
  34099. /**
  34100. * Factory used to create the default material.
  34101. * @param name The name of the material to create
  34102. * @param scene The scene to create the material for
  34103. * @returns The default material
  34104. */
  34105. static DefaultMaterialFactory(scene: Scene): Material;
  34106. /**
  34107. * Factory used to create the a collision coordinator.
  34108. * @returns The collision coordinator
  34109. */
  34110. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34111. /** @hidden */
  34112. _inputManager: InputManager;
  34113. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34114. cameraToUseForPointers: Nullable<Camera>;
  34115. /** @hidden */
  34116. readonly _isScene: boolean;
  34117. /**
  34118. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34119. */
  34120. autoClear: boolean;
  34121. /**
  34122. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34123. */
  34124. autoClearDepthAndStencil: boolean;
  34125. /**
  34126. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34127. */
  34128. clearColor: Color4;
  34129. /**
  34130. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34131. */
  34132. ambientColor: Color3;
  34133. /**
  34134. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34135. * It should only be one of the following (if not the default embedded one):
  34136. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34137. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34138. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34139. * The material properties need to be setup according to the type of texture in use.
  34140. */
  34141. environmentBRDFTexture: BaseTexture;
  34142. /** @hidden */
  34143. protected _environmentTexture: Nullable<BaseTexture>;
  34144. /**
  34145. * Texture used in all pbr material as the reflection texture.
  34146. * As in the majority of the scene they are the same (exception for multi room and so on),
  34147. * this is easier to reference from here than from all the materials.
  34148. */
  34149. /**
  34150. * Texture used in all pbr material as the reflection texture.
  34151. * As in the majority of the scene they are the same (exception for multi room and so on),
  34152. * this is easier to set here than in all the materials.
  34153. */
  34154. environmentTexture: Nullable<BaseTexture>;
  34155. /** @hidden */
  34156. protected _environmentIntensity: number;
  34157. /**
  34158. * Intensity of the environment in all pbr material.
  34159. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34160. * As in the majority of the scene they are the same (exception for multi room and so on),
  34161. * this is easier to reference from here than from all the materials.
  34162. */
  34163. /**
  34164. * Intensity of the environment in all pbr material.
  34165. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34166. * As in the majority of the scene they are the same (exception for multi room and so on),
  34167. * this is easier to set here than in all the materials.
  34168. */
  34169. environmentIntensity: number;
  34170. /** @hidden */
  34171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34172. /**
  34173. * Default image processing configuration used either in the rendering
  34174. * Forward main pass or through the imageProcessingPostProcess if present.
  34175. * As in the majority of the scene they are the same (exception for multi camera),
  34176. * this is easier to reference from here than from all the materials and post process.
  34177. *
  34178. * No setter as we it is a shared configuration, you can set the values instead.
  34179. */
  34180. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34181. private _forceWireframe;
  34182. /**
  34183. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34184. */
  34185. forceWireframe: boolean;
  34186. private _forcePointsCloud;
  34187. /**
  34188. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34189. */
  34190. forcePointsCloud: boolean;
  34191. /**
  34192. * Gets or sets the active clipplane 1
  34193. */
  34194. clipPlane: Nullable<Plane>;
  34195. /**
  34196. * Gets or sets the active clipplane 2
  34197. */
  34198. clipPlane2: Nullable<Plane>;
  34199. /**
  34200. * Gets or sets the active clipplane 3
  34201. */
  34202. clipPlane3: Nullable<Plane>;
  34203. /**
  34204. * Gets or sets the active clipplane 4
  34205. */
  34206. clipPlane4: Nullable<Plane>;
  34207. /**
  34208. * Gets or sets a boolean indicating if animations are enabled
  34209. */
  34210. animationsEnabled: boolean;
  34211. private _animationPropertiesOverride;
  34212. /**
  34213. * Gets or sets the animation properties override
  34214. */
  34215. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34216. /**
  34217. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34218. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34219. */
  34220. useConstantAnimationDeltaTime: boolean;
  34221. /**
  34222. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34223. * Please note that it requires to run a ray cast through the scene on every frame
  34224. */
  34225. constantlyUpdateMeshUnderPointer: boolean;
  34226. /**
  34227. * Defines the HTML cursor to use when hovering over interactive elements
  34228. */
  34229. hoverCursor: string;
  34230. /**
  34231. * Defines the HTML default cursor to use (empty by default)
  34232. */
  34233. defaultCursor: string;
  34234. /**
  34235. * Defines wether cursors are handled by the scene.
  34236. */
  34237. doNotHandleCursors: boolean;
  34238. /**
  34239. * This is used to call preventDefault() on pointer down
  34240. * in order to block unwanted artifacts like system double clicks
  34241. */
  34242. preventDefaultOnPointerDown: boolean;
  34243. /**
  34244. * This is used to call preventDefault() on pointer up
  34245. * in order to block unwanted artifacts like system double clicks
  34246. */
  34247. preventDefaultOnPointerUp: boolean;
  34248. /**
  34249. * Gets or sets user defined metadata
  34250. */
  34251. metadata: any;
  34252. /**
  34253. * For internal use only. Please do not use.
  34254. */
  34255. reservedDataStore: any;
  34256. /**
  34257. * Gets the name of the plugin used to load this scene (null by default)
  34258. */
  34259. loadingPluginName: string;
  34260. /**
  34261. * Use this array to add regular expressions used to disable offline support for specific urls
  34262. */
  34263. disableOfflineSupportExceptionRules: RegExp[];
  34264. /**
  34265. * An event triggered when the scene is disposed.
  34266. */
  34267. onDisposeObservable: Observable<Scene>;
  34268. private _onDisposeObserver;
  34269. /** Sets a function to be executed when this scene is disposed. */
  34270. onDispose: () => void;
  34271. /**
  34272. * An event triggered before rendering the scene (right after animations and physics)
  34273. */
  34274. onBeforeRenderObservable: Observable<Scene>;
  34275. private _onBeforeRenderObserver;
  34276. /** Sets a function to be executed before rendering this scene */
  34277. beforeRender: Nullable<() => void>;
  34278. /**
  34279. * An event triggered after rendering the scene
  34280. */
  34281. onAfterRenderObservable: Observable<Scene>;
  34282. /**
  34283. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34284. */
  34285. onAfterRenderCameraObservable: Observable<Camera>;
  34286. private _onAfterRenderObserver;
  34287. /** Sets a function to be executed after rendering this scene */
  34288. afterRender: Nullable<() => void>;
  34289. /**
  34290. * An event triggered before animating the scene
  34291. */
  34292. onBeforeAnimationsObservable: Observable<Scene>;
  34293. /**
  34294. * An event triggered after animations processing
  34295. */
  34296. onAfterAnimationsObservable: Observable<Scene>;
  34297. /**
  34298. * An event triggered before draw calls are ready to be sent
  34299. */
  34300. onBeforeDrawPhaseObservable: Observable<Scene>;
  34301. /**
  34302. * An event triggered after draw calls have been sent
  34303. */
  34304. onAfterDrawPhaseObservable: Observable<Scene>;
  34305. /**
  34306. * An event triggered when the scene is ready
  34307. */
  34308. onReadyObservable: Observable<Scene>;
  34309. /**
  34310. * An event triggered before rendering a camera
  34311. */
  34312. onBeforeCameraRenderObservable: Observable<Camera>;
  34313. private _onBeforeCameraRenderObserver;
  34314. /** Sets a function to be executed before rendering a camera*/
  34315. beforeCameraRender: () => void;
  34316. /**
  34317. * An event triggered after rendering a camera
  34318. */
  34319. onAfterCameraRenderObservable: Observable<Camera>;
  34320. private _onAfterCameraRenderObserver;
  34321. /** Sets a function to be executed after rendering a camera*/
  34322. afterCameraRender: () => void;
  34323. /**
  34324. * An event triggered when active meshes evaluation is about to start
  34325. */
  34326. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34327. /**
  34328. * An event triggered when active meshes evaluation is done
  34329. */
  34330. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34331. /**
  34332. * An event triggered when particles rendering is about to start
  34333. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34334. */
  34335. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34336. /**
  34337. * An event triggered when particles rendering is done
  34338. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34339. */
  34340. onAfterParticlesRenderingObservable: Observable<Scene>;
  34341. /**
  34342. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34343. */
  34344. onDataLoadedObservable: Observable<Scene>;
  34345. /**
  34346. * An event triggered when a camera is created
  34347. */
  34348. onNewCameraAddedObservable: Observable<Camera>;
  34349. /**
  34350. * An event triggered when a camera is removed
  34351. */
  34352. onCameraRemovedObservable: Observable<Camera>;
  34353. /**
  34354. * An event triggered when a light is created
  34355. */
  34356. onNewLightAddedObservable: Observable<Light>;
  34357. /**
  34358. * An event triggered when a light is removed
  34359. */
  34360. onLightRemovedObservable: Observable<Light>;
  34361. /**
  34362. * An event triggered when a geometry is created
  34363. */
  34364. onNewGeometryAddedObservable: Observable<Geometry>;
  34365. /**
  34366. * An event triggered when a geometry is removed
  34367. */
  34368. onGeometryRemovedObservable: Observable<Geometry>;
  34369. /**
  34370. * An event triggered when a transform node is created
  34371. */
  34372. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34373. /**
  34374. * An event triggered when a transform node is removed
  34375. */
  34376. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34377. /**
  34378. * An event triggered when a mesh is created
  34379. */
  34380. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34381. /**
  34382. * An event triggered when a mesh is removed
  34383. */
  34384. onMeshRemovedObservable: Observable<AbstractMesh>;
  34385. /**
  34386. * An event triggered when a skeleton is created
  34387. */
  34388. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34389. /**
  34390. * An event triggered when a skeleton is removed
  34391. */
  34392. onSkeletonRemovedObservable: Observable<Skeleton>;
  34393. /**
  34394. * An event triggered when a material is created
  34395. */
  34396. onNewMaterialAddedObservable: Observable<Material>;
  34397. /**
  34398. * An event triggered when a material is removed
  34399. */
  34400. onMaterialRemovedObservable: Observable<Material>;
  34401. /**
  34402. * An event triggered when a texture is created
  34403. */
  34404. onNewTextureAddedObservable: Observable<BaseTexture>;
  34405. /**
  34406. * An event triggered when a texture is removed
  34407. */
  34408. onTextureRemovedObservable: Observable<BaseTexture>;
  34409. /**
  34410. * An event triggered when render targets are about to be rendered
  34411. * Can happen multiple times per frame.
  34412. */
  34413. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34414. /**
  34415. * An event triggered when render targets were rendered.
  34416. * Can happen multiple times per frame.
  34417. */
  34418. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34419. /**
  34420. * An event triggered before calculating deterministic simulation step
  34421. */
  34422. onBeforeStepObservable: Observable<Scene>;
  34423. /**
  34424. * An event triggered after calculating deterministic simulation step
  34425. */
  34426. onAfterStepObservable: Observable<Scene>;
  34427. /**
  34428. * An event triggered when the activeCamera property is updated
  34429. */
  34430. onActiveCameraChanged: Observable<Scene>;
  34431. /**
  34432. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34433. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34434. * 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)
  34435. */
  34436. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34437. /**
  34438. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34439. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34440. * 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)
  34441. */
  34442. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34443. /**
  34444. * This Observable will when a mesh has been imported into the scene.
  34445. */
  34446. onMeshImportedObservable: Observable<AbstractMesh>;
  34447. /**
  34448. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34449. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34450. */
  34451. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34452. /** @hidden */
  34453. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34454. /**
  34455. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34456. */
  34457. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34458. /**
  34459. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34460. */
  34461. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34462. /**
  34463. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34464. */
  34465. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34466. /** Callback called when a pointer move is detected */
  34467. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34468. /** Callback called when a pointer down is detected */
  34469. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34470. /** Callback called when a pointer up is detected */
  34471. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34472. /** Callback called when a pointer pick is detected */
  34473. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34474. /**
  34475. * 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).
  34476. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34477. */
  34478. onPrePointerObservable: Observable<PointerInfoPre>;
  34479. /**
  34480. * Observable event triggered each time an input event is received from the rendering canvas
  34481. */
  34482. onPointerObservable: Observable<PointerInfo>;
  34483. /**
  34484. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34485. */
  34486. readonly unTranslatedPointer: Vector2;
  34487. /**
  34488. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34489. */
  34490. static DragMovementThreshold: number;
  34491. /**
  34492. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34493. */
  34494. static LongPressDelay: number;
  34495. /**
  34496. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34497. */
  34498. static DoubleClickDelay: number;
  34499. /** If you need to check double click without raising a single click at first click, enable this flag */
  34500. static ExclusiveDoubleClickMode: boolean;
  34501. /** @hidden */
  34502. _mirroredCameraPosition: Nullable<Vector3>;
  34503. /**
  34504. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34505. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34506. */
  34507. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34508. /**
  34509. * Observable event triggered each time an keyboard event is received from the hosting window
  34510. */
  34511. onKeyboardObservable: Observable<KeyboardInfo>;
  34512. private _useRightHandedSystem;
  34513. /**
  34514. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34515. */
  34516. useRightHandedSystem: boolean;
  34517. private _timeAccumulator;
  34518. private _currentStepId;
  34519. private _currentInternalStep;
  34520. /**
  34521. * Sets the step Id used by deterministic lock step
  34522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34523. * @param newStepId defines the step Id
  34524. */
  34525. setStepId(newStepId: number): void;
  34526. /**
  34527. * Gets the step Id used by deterministic lock step
  34528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34529. * @returns the step Id
  34530. */
  34531. getStepId(): number;
  34532. /**
  34533. * Gets the internal step used by deterministic lock step
  34534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34535. * @returns the internal step
  34536. */
  34537. getInternalStep(): number;
  34538. private _fogEnabled;
  34539. /**
  34540. * Gets or sets a boolean indicating if fog is enabled on this scene
  34541. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34542. * (Default is true)
  34543. */
  34544. fogEnabled: boolean;
  34545. private _fogMode;
  34546. /**
  34547. * Gets or sets the fog mode to use
  34548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34549. * | mode | value |
  34550. * | --- | --- |
  34551. * | FOGMODE_NONE | 0 |
  34552. * | FOGMODE_EXP | 1 |
  34553. * | FOGMODE_EXP2 | 2 |
  34554. * | FOGMODE_LINEAR | 3 |
  34555. */
  34556. fogMode: number;
  34557. /**
  34558. * Gets or sets the fog color to use
  34559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34560. * (Default is Color3(0.2, 0.2, 0.3))
  34561. */
  34562. fogColor: Color3;
  34563. /**
  34564. * Gets or sets the fog density to use
  34565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34566. * (Default is 0.1)
  34567. */
  34568. fogDensity: number;
  34569. /**
  34570. * Gets or sets the fog start distance to use
  34571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34572. * (Default is 0)
  34573. */
  34574. fogStart: number;
  34575. /**
  34576. * Gets or sets the fog end distance to use
  34577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34578. * (Default is 1000)
  34579. */
  34580. fogEnd: number;
  34581. private _shadowsEnabled;
  34582. /**
  34583. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34584. */
  34585. shadowsEnabled: boolean;
  34586. private _lightsEnabled;
  34587. /**
  34588. * Gets or sets a boolean indicating if lights are enabled on this scene
  34589. */
  34590. lightsEnabled: boolean;
  34591. /** All of the active cameras added to this scene. */
  34592. activeCameras: Camera[];
  34593. /** @hidden */
  34594. _activeCamera: Nullable<Camera>;
  34595. /** Gets or sets the current active camera */
  34596. activeCamera: Nullable<Camera>;
  34597. private _defaultMaterial;
  34598. /** The default material used on meshes when no material is affected */
  34599. /** The default material used on meshes when no material is affected */
  34600. defaultMaterial: Material;
  34601. private _texturesEnabled;
  34602. /**
  34603. * Gets or sets a boolean indicating if textures are enabled on this scene
  34604. */
  34605. texturesEnabled: boolean;
  34606. /**
  34607. * Gets or sets a boolean indicating if particles are enabled on this scene
  34608. */
  34609. particlesEnabled: boolean;
  34610. /**
  34611. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34612. */
  34613. spritesEnabled: boolean;
  34614. private _skeletonsEnabled;
  34615. /**
  34616. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34617. */
  34618. skeletonsEnabled: boolean;
  34619. /**
  34620. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34621. */
  34622. lensFlaresEnabled: boolean;
  34623. /**
  34624. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34626. */
  34627. collisionsEnabled: boolean;
  34628. private _collisionCoordinator;
  34629. /** @hidden */
  34630. readonly collisionCoordinator: ICollisionCoordinator;
  34631. /**
  34632. * Defines the gravity applied to this scene (used only for collisions)
  34633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34634. */
  34635. gravity: Vector3;
  34636. /**
  34637. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34638. */
  34639. postProcessesEnabled: boolean;
  34640. /**
  34641. * The list of postprocesses added to the scene
  34642. */
  34643. postProcesses: PostProcess[];
  34644. /**
  34645. * Gets the current postprocess manager
  34646. */
  34647. postProcessManager: PostProcessManager;
  34648. /**
  34649. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34650. */
  34651. renderTargetsEnabled: boolean;
  34652. /**
  34653. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34654. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34655. */
  34656. dumpNextRenderTargets: boolean;
  34657. /**
  34658. * The list of user defined render targets added to the scene
  34659. */
  34660. customRenderTargets: RenderTargetTexture[];
  34661. /**
  34662. * Defines if texture loading must be delayed
  34663. * If true, textures will only be loaded when they need to be rendered
  34664. */
  34665. useDelayedTextureLoading: boolean;
  34666. /**
  34667. * Gets the list of meshes imported to the scene through SceneLoader
  34668. */
  34669. importedMeshesFiles: String[];
  34670. /**
  34671. * Gets or sets a boolean indicating if probes are enabled on this scene
  34672. */
  34673. probesEnabled: boolean;
  34674. /**
  34675. * Gets or sets the current offline provider to use to store scene data
  34676. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34677. */
  34678. offlineProvider: IOfflineProvider;
  34679. /**
  34680. * Gets or sets the action manager associated with the scene
  34681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34682. */
  34683. actionManager: AbstractActionManager;
  34684. private _meshesForIntersections;
  34685. /**
  34686. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34687. */
  34688. proceduralTexturesEnabled: boolean;
  34689. private _engine;
  34690. private _totalVertices;
  34691. /** @hidden */
  34692. _activeIndices: PerfCounter;
  34693. /** @hidden */
  34694. _activeParticles: PerfCounter;
  34695. /** @hidden */
  34696. _activeBones: PerfCounter;
  34697. private _animationRatio;
  34698. /** @hidden */
  34699. _animationTimeLast: number;
  34700. /** @hidden */
  34701. _animationTime: number;
  34702. /**
  34703. * Gets or sets a general scale for animation speed
  34704. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34705. */
  34706. animationTimeScale: number;
  34707. /** @hidden */
  34708. _cachedMaterial: Nullable<Material>;
  34709. /** @hidden */
  34710. _cachedEffect: Nullable<Effect>;
  34711. /** @hidden */
  34712. _cachedVisibility: Nullable<number>;
  34713. private _renderId;
  34714. private _frameId;
  34715. private _executeWhenReadyTimeoutId;
  34716. private _intermediateRendering;
  34717. private _viewUpdateFlag;
  34718. private _projectionUpdateFlag;
  34719. /** @hidden */
  34720. _toBeDisposed: Nullable<IDisposable>[];
  34721. private _activeRequests;
  34722. /** @hidden */
  34723. _pendingData: any[];
  34724. private _isDisposed;
  34725. /**
  34726. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34727. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34728. */
  34729. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34730. private _activeMeshes;
  34731. private _processedMaterials;
  34732. private _renderTargets;
  34733. /** @hidden */
  34734. _activeParticleSystems: SmartArray<IParticleSystem>;
  34735. private _activeSkeletons;
  34736. private _softwareSkinnedMeshes;
  34737. private _renderingManager;
  34738. /** @hidden */
  34739. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34740. private _transformMatrix;
  34741. private _sceneUbo;
  34742. /** @hidden */
  34743. _viewMatrix: Matrix;
  34744. private _projectionMatrix;
  34745. /** @hidden */
  34746. _forcedViewPosition: Nullable<Vector3>;
  34747. /** @hidden */
  34748. _frustumPlanes: Plane[];
  34749. /**
  34750. * Gets the list of frustum planes (built from the active camera)
  34751. */
  34752. readonly frustumPlanes: Plane[];
  34753. /**
  34754. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34755. * This is useful if there are more lights that the maximum simulteanous authorized
  34756. */
  34757. requireLightSorting: boolean;
  34758. /** @hidden */
  34759. readonly useMaterialMeshMap: boolean;
  34760. /** @hidden */
  34761. readonly useClonedMeshhMap: boolean;
  34762. private _externalData;
  34763. private _uid;
  34764. /**
  34765. * @hidden
  34766. * Backing store of defined scene components.
  34767. */
  34768. _components: ISceneComponent[];
  34769. /**
  34770. * @hidden
  34771. * Backing store of defined scene components.
  34772. */
  34773. _serializableComponents: ISceneSerializableComponent[];
  34774. /**
  34775. * List of components to register on the next registration step.
  34776. */
  34777. private _transientComponents;
  34778. /**
  34779. * Registers the transient components if needed.
  34780. */
  34781. private _registerTransientComponents;
  34782. /**
  34783. * @hidden
  34784. * Add a component to the scene.
  34785. * Note that the ccomponent could be registered on th next frame if this is called after
  34786. * the register component stage.
  34787. * @param component Defines the component to add to the scene
  34788. */
  34789. _addComponent(component: ISceneComponent): void;
  34790. /**
  34791. * @hidden
  34792. * Gets a component from the scene.
  34793. * @param name defines the name of the component to retrieve
  34794. * @returns the component or null if not present
  34795. */
  34796. _getComponent(name: string): Nullable<ISceneComponent>;
  34797. /**
  34798. * @hidden
  34799. * Defines the actions happening before camera updates.
  34800. */
  34801. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34802. /**
  34803. * @hidden
  34804. * Defines the actions happening before clear the canvas.
  34805. */
  34806. _beforeClearStage: Stage<SimpleStageAction>;
  34807. /**
  34808. * @hidden
  34809. * Defines the actions when collecting render targets for the frame.
  34810. */
  34811. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34812. /**
  34813. * @hidden
  34814. * Defines the actions happening for one camera in the frame.
  34815. */
  34816. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34817. /**
  34818. * @hidden
  34819. * Defines the actions happening during the per mesh ready checks.
  34820. */
  34821. _isReadyForMeshStage: Stage<MeshStageAction>;
  34822. /**
  34823. * @hidden
  34824. * Defines the actions happening before evaluate active mesh checks.
  34825. */
  34826. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34827. /**
  34828. * @hidden
  34829. * Defines the actions happening during the evaluate sub mesh checks.
  34830. */
  34831. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34832. /**
  34833. * @hidden
  34834. * Defines the actions happening during the active mesh stage.
  34835. */
  34836. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34837. /**
  34838. * @hidden
  34839. * Defines the actions happening during the per camera render target step.
  34840. */
  34841. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34842. /**
  34843. * @hidden
  34844. * Defines the actions happening just before the active camera is drawing.
  34845. */
  34846. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34847. /**
  34848. * @hidden
  34849. * Defines the actions happening just before a render target is drawing.
  34850. */
  34851. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34852. /**
  34853. * @hidden
  34854. * Defines the actions happening just before a rendering group is drawing.
  34855. */
  34856. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34857. /**
  34858. * @hidden
  34859. * Defines the actions happening just before a mesh is drawing.
  34860. */
  34861. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34862. /**
  34863. * @hidden
  34864. * Defines the actions happening just after a mesh has been drawn.
  34865. */
  34866. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34867. /**
  34868. * @hidden
  34869. * Defines the actions happening just after a rendering group has been drawn.
  34870. */
  34871. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34872. /**
  34873. * @hidden
  34874. * Defines the actions happening just after the active camera has been drawn.
  34875. */
  34876. _afterCameraDrawStage: Stage<CameraStageAction>;
  34877. /**
  34878. * @hidden
  34879. * Defines the actions happening just after a render target has been drawn.
  34880. */
  34881. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34882. /**
  34883. * @hidden
  34884. * Defines the actions happening just after rendering all cameras and computing intersections.
  34885. */
  34886. _afterRenderStage: Stage<SimpleStageAction>;
  34887. /**
  34888. * @hidden
  34889. * Defines the actions happening when a pointer move event happens.
  34890. */
  34891. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34892. /**
  34893. * @hidden
  34894. * Defines the actions happening when a pointer down event happens.
  34895. */
  34896. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34897. /**
  34898. * @hidden
  34899. * Defines the actions happening when a pointer up event happens.
  34900. */
  34901. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34902. /**
  34903. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34904. */
  34905. private geometriesByUniqueId;
  34906. /**
  34907. * Creates a new Scene
  34908. * @param engine defines the engine to use to render this scene
  34909. * @param options defines the scene options
  34910. */
  34911. constructor(engine: Engine, options?: SceneOptions);
  34912. /**
  34913. * Gets a string idenfifying the name of the class
  34914. * @returns "Scene" string
  34915. */
  34916. getClassName(): string;
  34917. private _defaultMeshCandidates;
  34918. /**
  34919. * @hidden
  34920. */
  34921. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34922. private _defaultSubMeshCandidates;
  34923. /**
  34924. * @hidden
  34925. */
  34926. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34927. /**
  34928. * Sets the default candidate providers for the scene.
  34929. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34930. * and getCollidingSubMeshCandidates to their default function
  34931. */
  34932. setDefaultCandidateProviders(): void;
  34933. /**
  34934. * Gets the mesh that is currently under the pointer
  34935. */
  34936. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34937. /**
  34938. * Gets or sets the current on-screen X position of the pointer
  34939. */
  34940. pointerX: number;
  34941. /**
  34942. * Gets or sets the current on-screen Y position of the pointer
  34943. */
  34944. pointerY: number;
  34945. /**
  34946. * Gets the cached material (ie. the latest rendered one)
  34947. * @returns the cached material
  34948. */
  34949. getCachedMaterial(): Nullable<Material>;
  34950. /**
  34951. * Gets the cached effect (ie. the latest rendered one)
  34952. * @returns the cached effect
  34953. */
  34954. getCachedEffect(): Nullable<Effect>;
  34955. /**
  34956. * Gets the cached visibility state (ie. the latest rendered one)
  34957. * @returns the cached visibility state
  34958. */
  34959. getCachedVisibility(): Nullable<number>;
  34960. /**
  34961. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34962. * @param material defines the current material
  34963. * @param effect defines the current effect
  34964. * @param visibility defines the current visibility state
  34965. * @returns true if one parameter is not cached
  34966. */
  34967. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34968. /**
  34969. * Gets the engine associated with the scene
  34970. * @returns an Engine
  34971. */
  34972. getEngine(): Engine;
  34973. /**
  34974. * Gets the total number of vertices rendered per frame
  34975. * @returns the total number of vertices rendered per frame
  34976. */
  34977. getTotalVertices(): number;
  34978. /**
  34979. * Gets the performance counter for total vertices
  34980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34981. */
  34982. readonly totalVerticesPerfCounter: PerfCounter;
  34983. /**
  34984. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34985. * @returns the total number of active indices rendered per frame
  34986. */
  34987. getActiveIndices(): number;
  34988. /**
  34989. * Gets the performance counter for active indices
  34990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34991. */
  34992. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34993. /**
  34994. * Gets the total number of active particles rendered per frame
  34995. * @returns the total number of active particles rendered per frame
  34996. */
  34997. getActiveParticles(): number;
  34998. /**
  34999. * Gets the performance counter for active particles
  35000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35001. */
  35002. readonly activeParticlesPerfCounter: PerfCounter;
  35003. /**
  35004. * Gets the total number of active bones rendered per frame
  35005. * @returns the total number of active bones rendered per frame
  35006. */
  35007. getActiveBones(): number;
  35008. /**
  35009. * Gets the performance counter for active bones
  35010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35011. */
  35012. readonly activeBonesPerfCounter: PerfCounter;
  35013. /**
  35014. * Gets the array of active meshes
  35015. * @returns an array of AbstractMesh
  35016. */
  35017. getActiveMeshes(): SmartArray<AbstractMesh>;
  35018. /**
  35019. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35020. * @returns a number
  35021. */
  35022. getAnimationRatio(): number;
  35023. /**
  35024. * Gets an unique Id for the current render phase
  35025. * @returns a number
  35026. */
  35027. getRenderId(): number;
  35028. /**
  35029. * Gets an unique Id for the current frame
  35030. * @returns a number
  35031. */
  35032. getFrameId(): number;
  35033. /** Call this function if you want to manually increment the render Id*/
  35034. incrementRenderId(): void;
  35035. private _createUbo;
  35036. /**
  35037. * Use this method to simulate a pointer move on a mesh
  35038. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35039. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35040. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35041. * @returns the current scene
  35042. */
  35043. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35044. /**
  35045. * Use this method to simulate a pointer down on a mesh
  35046. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35047. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35048. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35049. * @returns the current scene
  35050. */
  35051. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35052. /**
  35053. * Use this method to simulate a pointer up on a mesh
  35054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35057. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35058. * @returns the current scene
  35059. */
  35060. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35061. /**
  35062. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35063. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35064. * @returns true if the pointer was captured
  35065. */
  35066. isPointerCaptured(pointerId?: number): boolean;
  35067. /**
  35068. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35069. * @param attachUp defines if you want to attach events to pointerup
  35070. * @param attachDown defines if you want to attach events to pointerdown
  35071. * @param attachMove defines if you want to attach events to pointermove
  35072. */
  35073. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35074. /** Detaches all event handlers*/
  35075. detachControl(): void;
  35076. /**
  35077. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35078. * Delay loaded resources are not taking in account
  35079. * @return true if all required resources are ready
  35080. */
  35081. isReady(): boolean;
  35082. /** Resets all cached information relative to material (including effect and visibility) */
  35083. resetCachedMaterial(): void;
  35084. /**
  35085. * Registers a function to be called before every frame render
  35086. * @param func defines the function to register
  35087. */
  35088. registerBeforeRender(func: () => void): void;
  35089. /**
  35090. * Unregisters a function called before every frame render
  35091. * @param func defines the function to unregister
  35092. */
  35093. unregisterBeforeRender(func: () => void): void;
  35094. /**
  35095. * Registers a function to be called after every frame render
  35096. * @param func defines the function to register
  35097. */
  35098. registerAfterRender(func: () => void): void;
  35099. /**
  35100. * Unregisters a function called after every frame render
  35101. * @param func defines the function to unregister
  35102. */
  35103. unregisterAfterRender(func: () => void): void;
  35104. private _executeOnceBeforeRender;
  35105. /**
  35106. * The provided function will run before render once and will be disposed afterwards.
  35107. * A timeout delay can be provided so that the function will be executed in N ms.
  35108. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35109. * @param func The function to be executed.
  35110. * @param timeout optional delay in ms
  35111. */
  35112. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35113. /** @hidden */
  35114. _addPendingData(data: any): void;
  35115. /** @hidden */
  35116. _removePendingData(data: any): void;
  35117. /**
  35118. * Returns the number of items waiting to be loaded
  35119. * @returns the number of items waiting to be loaded
  35120. */
  35121. getWaitingItemsCount(): number;
  35122. /**
  35123. * Returns a boolean indicating if the scene is still loading data
  35124. */
  35125. readonly isLoading: boolean;
  35126. /**
  35127. * Registers a function to be executed when the scene is ready
  35128. * @param {Function} func - the function to be executed
  35129. */
  35130. executeWhenReady(func: () => void): void;
  35131. /**
  35132. * Returns a promise that resolves when the scene is ready
  35133. * @returns A promise that resolves when the scene is ready
  35134. */
  35135. whenReadyAsync(): Promise<void>;
  35136. /** @hidden */
  35137. _checkIsReady(): void;
  35138. /**
  35139. * Gets all animatable attached to the scene
  35140. */
  35141. readonly animatables: Animatable[];
  35142. /**
  35143. * Resets the last animation time frame.
  35144. * Useful to override when animations start running when loading a scene for the first time.
  35145. */
  35146. resetLastAnimationTimeFrame(): void;
  35147. /**
  35148. * Gets the current view matrix
  35149. * @returns a Matrix
  35150. */
  35151. getViewMatrix(): Matrix;
  35152. /**
  35153. * Gets the current projection matrix
  35154. * @returns a Matrix
  35155. */
  35156. getProjectionMatrix(): Matrix;
  35157. /**
  35158. * Gets the current transform matrix
  35159. * @returns a Matrix made of View * Projection
  35160. */
  35161. getTransformMatrix(): Matrix;
  35162. /**
  35163. * Sets the current transform matrix
  35164. * @param viewL defines the View matrix to use
  35165. * @param projectionL defines the Projection matrix to use
  35166. * @param viewR defines the right View matrix to use (if provided)
  35167. * @param projectionR defines the right Projection matrix to use (if provided)
  35168. */
  35169. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35170. /**
  35171. * Gets the uniform buffer used to store scene data
  35172. * @returns a UniformBuffer
  35173. */
  35174. getSceneUniformBuffer(): UniformBuffer;
  35175. /**
  35176. * Gets an unique (relatively to the current scene) Id
  35177. * @returns an unique number for the scene
  35178. */
  35179. getUniqueId(): number;
  35180. /**
  35181. * Add a mesh to the list of scene's meshes
  35182. * @param newMesh defines the mesh to add
  35183. * @param recursive if all child meshes should also be added to the scene
  35184. */
  35185. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35186. /**
  35187. * Remove a mesh for the list of scene's meshes
  35188. * @param toRemove defines the mesh to remove
  35189. * @param recursive if all child meshes should also be removed from the scene
  35190. * @returns the index where the mesh was in the mesh list
  35191. */
  35192. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35193. /**
  35194. * Add a transform node to the list of scene's transform nodes
  35195. * @param newTransformNode defines the transform node to add
  35196. */
  35197. addTransformNode(newTransformNode: TransformNode): void;
  35198. /**
  35199. * Remove a transform node for the list of scene's transform nodes
  35200. * @param toRemove defines the transform node to remove
  35201. * @returns the index where the transform node was in the transform node list
  35202. */
  35203. removeTransformNode(toRemove: TransformNode): number;
  35204. /**
  35205. * Remove a skeleton for the list of scene's skeletons
  35206. * @param toRemove defines the skeleton to remove
  35207. * @returns the index where the skeleton was in the skeleton list
  35208. */
  35209. removeSkeleton(toRemove: Skeleton): number;
  35210. /**
  35211. * Remove a morph target for the list of scene's morph targets
  35212. * @param toRemove defines the morph target to remove
  35213. * @returns the index where the morph target was in the morph target list
  35214. */
  35215. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35216. /**
  35217. * Remove a light for the list of scene's lights
  35218. * @param toRemove defines the light to remove
  35219. * @returns the index where the light was in the light list
  35220. */
  35221. removeLight(toRemove: Light): number;
  35222. /**
  35223. * Remove a camera for the list of scene's cameras
  35224. * @param toRemove defines the camera to remove
  35225. * @returns the index where the camera was in the camera list
  35226. */
  35227. removeCamera(toRemove: Camera): number;
  35228. /**
  35229. * Remove a particle system for the list of scene's particle systems
  35230. * @param toRemove defines the particle system to remove
  35231. * @returns the index where the particle system was in the particle system list
  35232. */
  35233. removeParticleSystem(toRemove: IParticleSystem): number;
  35234. /**
  35235. * Remove a animation for the list of scene's animations
  35236. * @param toRemove defines the animation to remove
  35237. * @returns the index where the animation was in the animation list
  35238. */
  35239. removeAnimation(toRemove: Animation): number;
  35240. /**
  35241. * Will stop the animation of the given target
  35242. * @param target - the target
  35243. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35244. * @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)
  35245. */
  35246. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35247. /**
  35248. * Removes the given animation group from this scene.
  35249. * @param toRemove The animation group to remove
  35250. * @returns The index of the removed animation group
  35251. */
  35252. removeAnimationGroup(toRemove: AnimationGroup): number;
  35253. /**
  35254. * Removes the given multi-material from this scene.
  35255. * @param toRemove The multi-material to remove
  35256. * @returns The index of the removed multi-material
  35257. */
  35258. removeMultiMaterial(toRemove: MultiMaterial): number;
  35259. /**
  35260. * Removes the given material from this scene.
  35261. * @param toRemove The material to remove
  35262. * @returns The index of the removed material
  35263. */
  35264. removeMaterial(toRemove: Material): number;
  35265. /**
  35266. * Removes the given action manager from this scene.
  35267. * @param toRemove The action manager to remove
  35268. * @returns The index of the removed action manager
  35269. */
  35270. removeActionManager(toRemove: AbstractActionManager): number;
  35271. /**
  35272. * Removes the given texture from this scene.
  35273. * @param toRemove The texture to remove
  35274. * @returns The index of the removed texture
  35275. */
  35276. removeTexture(toRemove: BaseTexture): number;
  35277. /**
  35278. * Adds the given light to this scene
  35279. * @param newLight The light to add
  35280. */
  35281. addLight(newLight: Light): void;
  35282. /**
  35283. * Sorts the list list based on light priorities
  35284. */
  35285. sortLightsByPriority(): void;
  35286. /**
  35287. * Adds the given camera to this scene
  35288. * @param newCamera The camera to add
  35289. */
  35290. addCamera(newCamera: Camera): void;
  35291. /**
  35292. * Adds the given skeleton to this scene
  35293. * @param newSkeleton The skeleton to add
  35294. */
  35295. addSkeleton(newSkeleton: Skeleton): void;
  35296. /**
  35297. * Adds the given particle system to this scene
  35298. * @param newParticleSystem The particle system to add
  35299. */
  35300. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35301. /**
  35302. * Adds the given animation to this scene
  35303. * @param newAnimation The animation to add
  35304. */
  35305. addAnimation(newAnimation: Animation): void;
  35306. /**
  35307. * Adds the given animation group to this scene.
  35308. * @param newAnimationGroup The animation group to add
  35309. */
  35310. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35311. /**
  35312. * Adds the given multi-material to this scene
  35313. * @param newMultiMaterial The multi-material to add
  35314. */
  35315. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35316. /**
  35317. * Adds the given material to this scene
  35318. * @param newMaterial The material to add
  35319. */
  35320. addMaterial(newMaterial: Material): void;
  35321. /**
  35322. * Adds the given morph target to this scene
  35323. * @param newMorphTargetManager The morph target to add
  35324. */
  35325. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35326. /**
  35327. * Adds the given geometry to this scene
  35328. * @param newGeometry The geometry to add
  35329. */
  35330. addGeometry(newGeometry: Geometry): void;
  35331. /**
  35332. * Adds the given action manager to this scene
  35333. * @param newActionManager The action manager to add
  35334. */
  35335. addActionManager(newActionManager: AbstractActionManager): void;
  35336. /**
  35337. * Adds the given texture to this scene.
  35338. * @param newTexture The texture to add
  35339. */
  35340. addTexture(newTexture: BaseTexture): void;
  35341. /**
  35342. * Switch active camera
  35343. * @param newCamera defines the new active camera
  35344. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35345. */
  35346. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35347. /**
  35348. * sets the active camera of the scene using its ID
  35349. * @param id defines the camera's ID
  35350. * @return the new active camera or null if none found.
  35351. */
  35352. setActiveCameraByID(id: string): Nullable<Camera>;
  35353. /**
  35354. * sets the active camera of the scene using its name
  35355. * @param name defines the camera's name
  35356. * @returns the new active camera or null if none found.
  35357. */
  35358. setActiveCameraByName(name: string): Nullable<Camera>;
  35359. /**
  35360. * get an animation group using its name
  35361. * @param name defines the material's name
  35362. * @return the animation group or null if none found.
  35363. */
  35364. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35365. /**
  35366. * Get a material using its unique id
  35367. * @param uniqueId defines the material's unique id
  35368. * @return the material or null if none found.
  35369. */
  35370. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35371. /**
  35372. * get a material using its id
  35373. * @param id defines the material's ID
  35374. * @return the material or null if none found.
  35375. */
  35376. getMaterialByID(id: string): Nullable<Material>;
  35377. /**
  35378. * Gets a the last added material using a given id
  35379. * @param id defines the material's ID
  35380. * @return the last material with the given id or null if none found.
  35381. */
  35382. getLastMaterialByID(id: string): Nullable<Material>;
  35383. /**
  35384. * Gets a material using its name
  35385. * @param name defines the material's name
  35386. * @return the material or null if none found.
  35387. */
  35388. getMaterialByName(name: string): Nullable<Material>;
  35389. /**
  35390. * Get a texture using its unique id
  35391. * @param uniqueId defines the texture's unique id
  35392. * @return the texture or null if none found.
  35393. */
  35394. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35395. /**
  35396. * Gets a camera using its id
  35397. * @param id defines the id to look for
  35398. * @returns the camera or null if not found
  35399. */
  35400. getCameraByID(id: string): Nullable<Camera>;
  35401. /**
  35402. * Gets a camera using its unique id
  35403. * @param uniqueId defines the unique id to look for
  35404. * @returns the camera or null if not found
  35405. */
  35406. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35407. /**
  35408. * Gets a camera using its name
  35409. * @param name defines the camera's name
  35410. * @return the camera or null if none found.
  35411. */
  35412. getCameraByName(name: string): Nullable<Camera>;
  35413. /**
  35414. * Gets a bone using its id
  35415. * @param id defines the bone's id
  35416. * @return the bone or null if not found
  35417. */
  35418. getBoneByID(id: string): Nullable<Bone>;
  35419. /**
  35420. * Gets a bone using its id
  35421. * @param name defines the bone's name
  35422. * @return the bone or null if not found
  35423. */
  35424. getBoneByName(name: string): Nullable<Bone>;
  35425. /**
  35426. * Gets a light node using its name
  35427. * @param name defines the the light's name
  35428. * @return the light or null if none found.
  35429. */
  35430. getLightByName(name: string): Nullable<Light>;
  35431. /**
  35432. * Gets a light node using its id
  35433. * @param id defines the light's id
  35434. * @return the light or null if none found.
  35435. */
  35436. getLightByID(id: string): Nullable<Light>;
  35437. /**
  35438. * Gets a light node using its scene-generated unique ID
  35439. * @param uniqueId defines the light's unique id
  35440. * @return the light or null if none found.
  35441. */
  35442. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35443. /**
  35444. * Gets a particle system by id
  35445. * @param id defines the particle system id
  35446. * @return the corresponding system or null if none found
  35447. */
  35448. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35449. /**
  35450. * Gets a geometry using its ID
  35451. * @param id defines the geometry's id
  35452. * @return the geometry or null if none found.
  35453. */
  35454. getGeometryByID(id: string): Nullable<Geometry>;
  35455. private _getGeometryByUniqueID;
  35456. /**
  35457. * Add a new geometry to this scene
  35458. * @param geometry defines the geometry to be added to the scene.
  35459. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35460. * @return a boolean defining if the geometry was added or not
  35461. */
  35462. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35463. /**
  35464. * Removes an existing geometry
  35465. * @param geometry defines the geometry to be removed from the scene
  35466. * @return a boolean defining if the geometry was removed or not
  35467. */
  35468. removeGeometry(geometry: Geometry): boolean;
  35469. /**
  35470. * Gets the list of geometries attached to the scene
  35471. * @returns an array of Geometry
  35472. */
  35473. getGeometries(): Geometry[];
  35474. /**
  35475. * Gets the first added mesh found of a given ID
  35476. * @param id defines the id to search for
  35477. * @return the mesh found or null if not found at all
  35478. */
  35479. getMeshByID(id: string): Nullable<AbstractMesh>;
  35480. /**
  35481. * Gets a list of meshes using their id
  35482. * @param id defines the id to search for
  35483. * @returns a list of meshes
  35484. */
  35485. getMeshesByID(id: string): Array<AbstractMesh>;
  35486. /**
  35487. * Gets the first added transform node found of a given ID
  35488. * @param id defines the id to search for
  35489. * @return the found transform node or null if not found at all.
  35490. */
  35491. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35492. /**
  35493. * Gets a transform node with its auto-generated unique id
  35494. * @param uniqueId efines the unique id to search for
  35495. * @return the found transform node or null if not found at all.
  35496. */
  35497. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35498. /**
  35499. * Gets a list of transform nodes using their id
  35500. * @param id defines the id to search for
  35501. * @returns a list of transform nodes
  35502. */
  35503. getTransformNodesByID(id: string): Array<TransformNode>;
  35504. /**
  35505. * Gets a mesh with its auto-generated unique id
  35506. * @param uniqueId defines the unique id to search for
  35507. * @return the found mesh or null if not found at all.
  35508. */
  35509. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35510. /**
  35511. * Gets a the last added mesh using a given id
  35512. * @param id defines the id to search for
  35513. * @return the found mesh or null if not found at all.
  35514. */
  35515. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35516. /**
  35517. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35518. * @param id defines the id to search for
  35519. * @return the found node or null if not found at all
  35520. */
  35521. getLastEntryByID(id: string): Nullable<Node>;
  35522. /**
  35523. * Gets a node (Mesh, Camera, Light) using a given id
  35524. * @param id defines the id to search for
  35525. * @return the found node or null if not found at all
  35526. */
  35527. getNodeByID(id: string): Nullable<Node>;
  35528. /**
  35529. * Gets a node (Mesh, Camera, Light) using a given name
  35530. * @param name defines the name to search for
  35531. * @return the found node or null if not found at all.
  35532. */
  35533. getNodeByName(name: string): Nullable<Node>;
  35534. /**
  35535. * Gets a mesh using a given name
  35536. * @param name defines the name to search for
  35537. * @return the found mesh or null if not found at all.
  35538. */
  35539. getMeshByName(name: string): Nullable<AbstractMesh>;
  35540. /**
  35541. * Gets a transform node using a given name
  35542. * @param name defines the name to search for
  35543. * @return the found transform node or null if not found at all.
  35544. */
  35545. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35546. /**
  35547. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35548. * @param id defines the id to search for
  35549. * @return the found skeleton or null if not found at all.
  35550. */
  35551. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35552. /**
  35553. * Gets a skeleton using a given auto generated unique id
  35554. * @param uniqueId defines the unique id to search for
  35555. * @return the found skeleton or null if not found at all.
  35556. */
  35557. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35558. /**
  35559. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35560. * @param id defines the id to search for
  35561. * @return the found skeleton or null if not found at all.
  35562. */
  35563. getSkeletonById(id: string): Nullable<Skeleton>;
  35564. /**
  35565. * Gets a skeleton using a given name
  35566. * @param name defines the name to search for
  35567. * @return the found skeleton or null if not found at all.
  35568. */
  35569. getSkeletonByName(name: string): Nullable<Skeleton>;
  35570. /**
  35571. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35572. * @param id defines the id to search for
  35573. * @return the found morph target manager or null if not found at all.
  35574. */
  35575. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35576. /**
  35577. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35578. * @param id defines the id to search for
  35579. * @return the found morph target or null if not found at all.
  35580. */
  35581. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35582. /**
  35583. * Gets a boolean indicating if the given mesh is active
  35584. * @param mesh defines the mesh to look for
  35585. * @returns true if the mesh is in the active list
  35586. */
  35587. isActiveMesh(mesh: AbstractMesh): boolean;
  35588. /**
  35589. * Return a unique id as a string which can serve as an identifier for the scene
  35590. */
  35591. readonly uid: string;
  35592. /**
  35593. * Add an externaly attached data from its key.
  35594. * This method call will fail and return false, if such key already exists.
  35595. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35596. * @param key the unique key that identifies the data
  35597. * @param data the data object to associate to the key for this Engine instance
  35598. * @return true if no such key were already present and the data was added successfully, false otherwise
  35599. */
  35600. addExternalData<T>(key: string, data: T): boolean;
  35601. /**
  35602. * Get an externaly attached data from its key
  35603. * @param key the unique key that identifies the data
  35604. * @return the associated data, if present (can be null), or undefined if not present
  35605. */
  35606. getExternalData<T>(key: string): Nullable<T>;
  35607. /**
  35608. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35609. * @param key the unique key that identifies the data
  35610. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35611. * @return the associated data, can be null if the factory returned null.
  35612. */
  35613. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35614. /**
  35615. * Remove an externaly attached data from the Engine instance
  35616. * @param key the unique key that identifies the data
  35617. * @return true if the data was successfully removed, false if it doesn't exist
  35618. */
  35619. removeExternalData(key: string): boolean;
  35620. private _evaluateSubMesh;
  35621. /**
  35622. * Clear the processed materials smart array preventing retention point in material dispose.
  35623. */
  35624. freeProcessedMaterials(): void;
  35625. private _preventFreeActiveMeshesAndRenderingGroups;
  35626. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35627. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35628. * when disposing several meshes in a row or a hierarchy of meshes.
  35629. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35630. */
  35631. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35632. /**
  35633. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35634. */
  35635. freeActiveMeshes(): void;
  35636. /**
  35637. * Clear the info related to rendering groups preventing retention points during dispose.
  35638. */
  35639. freeRenderingGroups(): void;
  35640. /** @hidden */
  35641. _isInIntermediateRendering(): boolean;
  35642. /**
  35643. * Lambda returning the list of potentially active meshes.
  35644. */
  35645. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35646. /**
  35647. * Lambda returning the list of potentially active sub meshes.
  35648. */
  35649. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35650. /**
  35651. * Lambda returning the list of potentially intersecting sub meshes.
  35652. */
  35653. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35654. /**
  35655. * Lambda returning the list of potentially colliding sub meshes.
  35656. */
  35657. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35658. private _activeMeshesFrozen;
  35659. /**
  35660. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35661. * @returns the current scene
  35662. */
  35663. freezeActiveMeshes(): Scene;
  35664. /**
  35665. * Use this function to restart evaluating active meshes on every frame
  35666. * @returns the current scene
  35667. */
  35668. unfreezeActiveMeshes(): Scene;
  35669. private _evaluateActiveMeshes;
  35670. private _activeMesh;
  35671. /**
  35672. * Update the transform matrix to update from the current active camera
  35673. * @param force defines a boolean used to force the update even if cache is up to date
  35674. */
  35675. updateTransformMatrix(force?: boolean): void;
  35676. private _bindFrameBuffer;
  35677. /** @hidden */
  35678. _allowPostProcessClearColor: boolean;
  35679. /** @hidden */
  35680. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35681. private _processSubCameras;
  35682. private _checkIntersections;
  35683. /** @hidden */
  35684. _advancePhysicsEngineStep(step: number): void;
  35685. /**
  35686. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35687. */
  35688. getDeterministicFrameTime: () => number;
  35689. /** @hidden */
  35690. _animate(): void;
  35691. /** Execute all animations (for a frame) */
  35692. animate(): void;
  35693. /**
  35694. * Render the scene
  35695. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35696. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35697. */
  35698. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35699. /**
  35700. * Freeze all materials
  35701. * A frozen material will not be updatable but should be faster to render
  35702. */
  35703. freezeMaterials(): void;
  35704. /**
  35705. * Unfreeze all materials
  35706. * A frozen material will not be updatable but should be faster to render
  35707. */
  35708. unfreezeMaterials(): void;
  35709. /**
  35710. * Releases all held ressources
  35711. */
  35712. dispose(): void;
  35713. /**
  35714. * Gets if the scene is already disposed
  35715. */
  35716. readonly isDisposed: boolean;
  35717. /**
  35718. * Call this function to reduce memory footprint of the scene.
  35719. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35720. */
  35721. clearCachedVertexData(): void;
  35722. /**
  35723. * This function will remove the local cached buffer data from texture.
  35724. * It will save memory but will prevent the texture from being rebuilt
  35725. */
  35726. cleanCachedTextureBuffer(): void;
  35727. /**
  35728. * Get the world extend vectors with an optional filter
  35729. *
  35730. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35731. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35732. */
  35733. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35734. min: Vector3;
  35735. max: Vector3;
  35736. };
  35737. /**
  35738. * Creates a ray that can be used to pick in the scene
  35739. * @param x defines the x coordinate of the origin (on-screen)
  35740. * @param y defines the y coordinate of the origin (on-screen)
  35741. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35742. * @param camera defines the camera to use for the picking
  35743. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35744. * @returns a Ray
  35745. */
  35746. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35747. /**
  35748. * Creates a ray that can be used to pick in the scene
  35749. * @param x defines the x coordinate of the origin (on-screen)
  35750. * @param y defines the y coordinate of the origin (on-screen)
  35751. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35752. * @param result defines the ray where to store the picking ray
  35753. * @param camera defines the camera to use for the picking
  35754. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35755. * @returns the current scene
  35756. */
  35757. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35758. /**
  35759. * Creates a ray that can be used to pick in the scene
  35760. * @param x defines the x coordinate of the origin (on-screen)
  35761. * @param y defines the y coordinate of the origin (on-screen)
  35762. * @param camera defines the camera to use for the picking
  35763. * @returns a Ray
  35764. */
  35765. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35766. /**
  35767. * Creates a ray that can be used to pick in the scene
  35768. * @param x defines the x coordinate of the origin (on-screen)
  35769. * @param y defines the y coordinate of the origin (on-screen)
  35770. * @param result defines the ray where to store the picking ray
  35771. * @param camera defines the camera to use for the picking
  35772. * @returns the current scene
  35773. */
  35774. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35775. /** Launch a ray to try to pick a mesh in the scene
  35776. * @param x position on screen
  35777. * @param y position on screen
  35778. * @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
  35779. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35780. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35781. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35782. * @returns a PickingInfo
  35783. */
  35784. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35785. /** Use the given ray to pick a mesh in the scene
  35786. * @param ray The ray to use to pick meshes
  35787. * @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
  35788. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35790. * @returns a PickingInfo
  35791. */
  35792. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35793. /**
  35794. * Launch a ray to try to pick a mesh in the scene
  35795. * @param x X position on screen
  35796. * @param y Y position on screen
  35797. * @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
  35798. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35799. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35800. * @returns an array of PickingInfo
  35801. */
  35802. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35803. /**
  35804. * Launch a ray to try to pick a mesh in the scene
  35805. * @param ray Ray to use
  35806. * @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
  35807. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35808. * @returns an array of PickingInfo
  35809. */
  35810. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35811. /**
  35812. * Force the value of meshUnderPointer
  35813. * @param mesh defines the mesh to use
  35814. */
  35815. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35816. /**
  35817. * Gets the mesh under the pointer
  35818. * @returns a Mesh or null if no mesh is under the pointer
  35819. */
  35820. getPointerOverMesh(): Nullable<AbstractMesh>;
  35821. /** @hidden */
  35822. _rebuildGeometries(): void;
  35823. /** @hidden */
  35824. _rebuildTextures(): void;
  35825. private _getByTags;
  35826. /**
  35827. * Get a list of meshes by tags
  35828. * @param tagsQuery defines the tags query to use
  35829. * @param forEach defines a predicate used to filter results
  35830. * @returns an array of Mesh
  35831. */
  35832. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35833. /**
  35834. * Get a list of cameras by tags
  35835. * @param tagsQuery defines the tags query to use
  35836. * @param forEach defines a predicate used to filter results
  35837. * @returns an array of Camera
  35838. */
  35839. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35840. /**
  35841. * Get a list of lights by tags
  35842. * @param tagsQuery defines the tags query to use
  35843. * @param forEach defines a predicate used to filter results
  35844. * @returns an array of Light
  35845. */
  35846. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35847. /**
  35848. * Get a list of materials by tags
  35849. * @param tagsQuery defines the tags query to use
  35850. * @param forEach defines a predicate used to filter results
  35851. * @returns an array of Material
  35852. */
  35853. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35854. /**
  35855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35856. * This allowed control for front to back rendering or reversly depending of the special needs.
  35857. *
  35858. * @param renderingGroupId The rendering group id corresponding to its index
  35859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35862. */
  35863. 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;
  35864. /**
  35865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35866. *
  35867. * @param renderingGroupId The rendering group id corresponding to its index
  35868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35869. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35870. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35871. */
  35872. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35873. /**
  35874. * Gets the current auto clear configuration for one rendering group of the rendering
  35875. * manager.
  35876. * @param index the rendering group index to get the information for
  35877. * @returns The auto clear setup for the requested rendering group
  35878. */
  35879. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35880. private _blockMaterialDirtyMechanism;
  35881. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35882. blockMaterialDirtyMechanism: boolean;
  35883. /**
  35884. * Will flag all materials as dirty to trigger new shader compilation
  35885. * @param flag defines the flag used to specify which material part must be marked as dirty
  35886. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35887. */
  35888. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35889. /** @hidden */
  35890. _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;
  35891. /** @hidden */
  35892. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35893. /** @hidden */
  35894. _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;
  35895. /** @hidden */
  35896. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35897. /** @hidden */
  35898. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35899. /** @hidden */
  35900. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35901. }
  35902. }
  35903. declare module "babylonjs/assetContainer" {
  35904. import { AbstractScene } from "babylonjs/abstractScene";
  35905. import { Scene } from "babylonjs/scene";
  35906. import { Mesh } from "babylonjs/Meshes/mesh";
  35907. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35908. import { Skeleton } from "babylonjs/Bones/skeleton";
  35909. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35910. /**
  35911. * Set of assets to keep when moving a scene into an asset container.
  35912. */
  35913. export class KeepAssets extends AbstractScene {
  35914. }
  35915. /**
  35916. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35917. */
  35918. export class InstantiatedEntries {
  35919. /**
  35920. * List of new root nodes (eg. nodes with no parent)
  35921. */
  35922. rootNodes: TransformNode[];
  35923. /**
  35924. * List of new skeletons
  35925. */
  35926. skeletons: Skeleton[];
  35927. /**
  35928. * List of new animation groups
  35929. */
  35930. animationGroups: AnimationGroup[];
  35931. }
  35932. /**
  35933. * Container with a set of assets that can be added or removed from a scene.
  35934. */
  35935. export class AssetContainer extends AbstractScene {
  35936. /**
  35937. * The scene the AssetContainer belongs to.
  35938. */
  35939. scene: Scene;
  35940. /**
  35941. * Instantiates an AssetContainer.
  35942. * @param scene The scene the AssetContainer belongs to.
  35943. */
  35944. constructor(scene: Scene);
  35945. /**
  35946. * Instantiate or clone all meshes and add the new ones to the scene.
  35947. * Skeletons and animation groups will all be cloned
  35948. * @param nameFunction defines an optional function used to get new names for clones
  35949. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35950. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35951. */
  35952. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35953. /**
  35954. * Adds all the assets from the container to the scene.
  35955. */
  35956. addAllToScene(): void;
  35957. /**
  35958. * Removes all the assets in the container from the scene
  35959. */
  35960. removeAllFromScene(): void;
  35961. /**
  35962. * Disposes all the assets in the container
  35963. */
  35964. dispose(): void;
  35965. private _moveAssets;
  35966. /**
  35967. * Removes all the assets contained in the scene and adds them to the container.
  35968. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35969. */
  35970. moveAllFromScene(keepAssets?: KeepAssets): void;
  35971. /**
  35972. * 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.
  35973. * @returns the root mesh
  35974. */
  35975. createRootMesh(): Mesh;
  35976. }
  35977. }
  35978. declare module "babylonjs/abstractScene" {
  35979. import { Scene } from "babylonjs/scene";
  35980. import { Nullable } from "babylonjs/types";
  35981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35982. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35983. import { Geometry } from "babylonjs/Meshes/geometry";
  35984. import { Skeleton } from "babylonjs/Bones/skeleton";
  35985. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35986. import { AssetContainer } from "babylonjs/assetContainer";
  35987. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35988. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35990. import { Material } from "babylonjs/Materials/material";
  35991. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35992. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35993. import { Camera } from "babylonjs/Cameras/camera";
  35994. import { Light } from "babylonjs/Lights/light";
  35995. import { Node } from "babylonjs/node";
  35996. import { Animation } from "babylonjs/Animations/animation";
  35997. /**
  35998. * Defines how the parser contract is defined.
  35999. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36000. */
  36001. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36002. /**
  36003. * Defines how the individual parser contract is defined.
  36004. * These parser can parse an individual asset
  36005. */
  36006. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36007. /**
  36008. * Base class of the scene acting as a container for the different elements composing a scene.
  36009. * This class is dynamically extended by the different components of the scene increasing
  36010. * flexibility and reducing coupling
  36011. */
  36012. export abstract class AbstractScene {
  36013. /**
  36014. * Stores the list of available parsers in the application.
  36015. */
  36016. private static _BabylonFileParsers;
  36017. /**
  36018. * Stores the list of available individual parsers in the application.
  36019. */
  36020. private static _IndividualBabylonFileParsers;
  36021. /**
  36022. * Adds a parser in the list of available ones
  36023. * @param name Defines the name of the parser
  36024. * @param parser Defines the parser to add
  36025. */
  36026. static AddParser(name: string, parser: BabylonFileParser): void;
  36027. /**
  36028. * Gets a general parser from the list of avaialble ones
  36029. * @param name Defines the name of the parser
  36030. * @returns the requested parser or null
  36031. */
  36032. static GetParser(name: string): Nullable<BabylonFileParser>;
  36033. /**
  36034. * Adds n individual parser in the list of available ones
  36035. * @param name Defines the name of the parser
  36036. * @param parser Defines the parser to add
  36037. */
  36038. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36039. /**
  36040. * Gets an individual parser from the list of avaialble ones
  36041. * @param name Defines the name of the parser
  36042. * @returns the requested parser or null
  36043. */
  36044. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36045. /**
  36046. * Parser json data and populate both a scene and its associated container object
  36047. * @param jsonData Defines the data to parse
  36048. * @param scene Defines the scene to parse the data for
  36049. * @param container Defines the container attached to the parsing sequence
  36050. * @param rootUrl Defines the root url of the data
  36051. */
  36052. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36053. /**
  36054. * Gets the list of root nodes (ie. nodes with no parent)
  36055. */
  36056. rootNodes: Node[];
  36057. /** All of the cameras added to this scene
  36058. * @see http://doc.babylonjs.com/babylon101/cameras
  36059. */
  36060. cameras: Camera[];
  36061. /**
  36062. * All of the lights added to this scene
  36063. * @see http://doc.babylonjs.com/babylon101/lights
  36064. */
  36065. lights: Light[];
  36066. /**
  36067. * All of the (abstract) meshes added to this scene
  36068. */
  36069. meshes: AbstractMesh[];
  36070. /**
  36071. * The list of skeletons added to the scene
  36072. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36073. */
  36074. skeletons: Skeleton[];
  36075. /**
  36076. * All of the particle systems added to this scene
  36077. * @see http://doc.babylonjs.com/babylon101/particles
  36078. */
  36079. particleSystems: IParticleSystem[];
  36080. /**
  36081. * Gets a list of Animations associated with the scene
  36082. */
  36083. animations: Animation[];
  36084. /**
  36085. * All of the animation groups added to this scene
  36086. * @see http://doc.babylonjs.com/how_to/group
  36087. */
  36088. animationGroups: AnimationGroup[];
  36089. /**
  36090. * All of the multi-materials added to this scene
  36091. * @see http://doc.babylonjs.com/how_to/multi_materials
  36092. */
  36093. multiMaterials: MultiMaterial[];
  36094. /**
  36095. * All of the materials added to this scene
  36096. * In the context of a Scene, it is not supposed to be modified manually.
  36097. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36098. * Note also that the order of the Material within the array is not significant and might change.
  36099. * @see http://doc.babylonjs.com/babylon101/materials
  36100. */
  36101. materials: Material[];
  36102. /**
  36103. * The list of morph target managers added to the scene
  36104. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36105. */
  36106. morphTargetManagers: MorphTargetManager[];
  36107. /**
  36108. * The list of geometries used in the scene.
  36109. */
  36110. geometries: Geometry[];
  36111. /**
  36112. * All of the tranform nodes added to this scene
  36113. * In the context of a Scene, it is not supposed to be modified manually.
  36114. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36115. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36116. * @see http://doc.babylonjs.com/how_to/transformnode
  36117. */
  36118. transformNodes: TransformNode[];
  36119. /**
  36120. * ActionManagers available on the scene.
  36121. */
  36122. actionManagers: AbstractActionManager[];
  36123. /**
  36124. * Textures to keep.
  36125. */
  36126. textures: BaseTexture[];
  36127. /**
  36128. * Environment texture for the scene
  36129. */
  36130. environmentTexture: Nullable<BaseTexture>;
  36131. }
  36132. }
  36133. declare module "babylonjs/Audio/sound" {
  36134. import { Observable } from "babylonjs/Misc/observable";
  36135. import { Vector3 } from "babylonjs/Maths/math.vector";
  36136. import { Nullable } from "babylonjs/types";
  36137. import { Scene } from "babylonjs/scene";
  36138. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36139. /**
  36140. * Interface used to define options for Sound class
  36141. */
  36142. export interface ISoundOptions {
  36143. /**
  36144. * Does the sound autoplay once loaded.
  36145. */
  36146. autoplay?: boolean;
  36147. /**
  36148. * Does the sound loop after it finishes playing once.
  36149. */
  36150. loop?: boolean;
  36151. /**
  36152. * Sound's volume
  36153. */
  36154. volume?: number;
  36155. /**
  36156. * Is it a spatial sound?
  36157. */
  36158. spatialSound?: boolean;
  36159. /**
  36160. * Maximum distance to hear that sound
  36161. */
  36162. maxDistance?: number;
  36163. /**
  36164. * Uses user defined attenuation function
  36165. */
  36166. useCustomAttenuation?: boolean;
  36167. /**
  36168. * Define the roll off factor of spatial sounds.
  36169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36170. */
  36171. rolloffFactor?: number;
  36172. /**
  36173. * Define the reference distance the sound should be heard perfectly.
  36174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36175. */
  36176. refDistance?: number;
  36177. /**
  36178. * Define the distance attenuation model the sound will follow.
  36179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36180. */
  36181. distanceModel?: string;
  36182. /**
  36183. * Defines the playback speed (1 by default)
  36184. */
  36185. playbackRate?: number;
  36186. /**
  36187. * Defines if the sound is from a streaming source
  36188. */
  36189. streaming?: boolean;
  36190. /**
  36191. * Defines an optional length (in seconds) inside the sound file
  36192. */
  36193. length?: number;
  36194. /**
  36195. * Defines an optional offset (in seconds) inside the sound file
  36196. */
  36197. offset?: number;
  36198. /**
  36199. * If true, URLs will not be required to state the audio file codec to use.
  36200. */
  36201. skipCodecCheck?: boolean;
  36202. }
  36203. /**
  36204. * Defines a sound that can be played in the application.
  36205. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36207. */
  36208. export class Sound {
  36209. /**
  36210. * The name of the sound in the scene.
  36211. */
  36212. name: string;
  36213. /**
  36214. * Does the sound autoplay once loaded.
  36215. */
  36216. autoplay: boolean;
  36217. /**
  36218. * Does the sound loop after it finishes playing once.
  36219. */
  36220. loop: boolean;
  36221. /**
  36222. * Does the sound use a custom attenuation curve to simulate the falloff
  36223. * happening when the source gets further away from the camera.
  36224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36225. */
  36226. useCustomAttenuation: boolean;
  36227. /**
  36228. * The sound track id this sound belongs to.
  36229. */
  36230. soundTrackId: number;
  36231. /**
  36232. * Is this sound currently played.
  36233. */
  36234. isPlaying: boolean;
  36235. /**
  36236. * Is this sound currently paused.
  36237. */
  36238. isPaused: boolean;
  36239. /**
  36240. * Does this sound enables spatial sound.
  36241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36242. */
  36243. spatialSound: boolean;
  36244. /**
  36245. * Define the reference distance the sound should be heard perfectly.
  36246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36247. */
  36248. refDistance: number;
  36249. /**
  36250. * Define the roll off factor of spatial sounds.
  36251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36252. */
  36253. rolloffFactor: number;
  36254. /**
  36255. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36257. */
  36258. maxDistance: number;
  36259. /**
  36260. * Define the distance attenuation model the sound will follow.
  36261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36262. */
  36263. distanceModel: string;
  36264. /**
  36265. * @hidden
  36266. * Back Compat
  36267. **/
  36268. onended: () => any;
  36269. /**
  36270. * Observable event when the current playing sound finishes.
  36271. */
  36272. onEndedObservable: Observable<Sound>;
  36273. private _panningModel;
  36274. private _playbackRate;
  36275. private _streaming;
  36276. private _startTime;
  36277. private _startOffset;
  36278. private _position;
  36279. /** @hidden */
  36280. _positionInEmitterSpace: boolean;
  36281. private _localDirection;
  36282. private _volume;
  36283. private _isReadyToPlay;
  36284. private _isDirectional;
  36285. private _readyToPlayCallback;
  36286. private _audioBuffer;
  36287. private _soundSource;
  36288. private _streamingSource;
  36289. private _soundPanner;
  36290. private _soundGain;
  36291. private _inputAudioNode;
  36292. private _outputAudioNode;
  36293. private _coneInnerAngle;
  36294. private _coneOuterAngle;
  36295. private _coneOuterGain;
  36296. private _scene;
  36297. private _connectedTransformNode;
  36298. private _customAttenuationFunction;
  36299. private _registerFunc;
  36300. private _isOutputConnected;
  36301. private _htmlAudioElement;
  36302. private _urlType;
  36303. private _length?;
  36304. private _offset?;
  36305. /** @hidden */
  36306. static _SceneComponentInitialization: (scene: Scene) => void;
  36307. /**
  36308. * Create a sound and attach it to a scene
  36309. * @param name Name of your sound
  36310. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36311. * @param scene defines the scene the sound belongs to
  36312. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36313. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36314. */
  36315. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36316. /**
  36317. * Release the sound and its associated resources
  36318. */
  36319. dispose(): void;
  36320. /**
  36321. * Gets if the sounds is ready to be played or not.
  36322. * @returns true if ready, otherwise false
  36323. */
  36324. isReady(): boolean;
  36325. private _soundLoaded;
  36326. /**
  36327. * Sets the data of the sound from an audiobuffer
  36328. * @param audioBuffer The audioBuffer containing the data
  36329. */
  36330. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36331. /**
  36332. * Updates the current sounds options such as maxdistance, loop...
  36333. * @param options A JSON object containing values named as the object properties
  36334. */
  36335. updateOptions(options: ISoundOptions): void;
  36336. private _createSpatialParameters;
  36337. private _updateSpatialParameters;
  36338. /**
  36339. * Switch the panning model to HRTF:
  36340. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36342. */
  36343. switchPanningModelToHRTF(): void;
  36344. /**
  36345. * Switch the panning model to Equal Power:
  36346. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36348. */
  36349. switchPanningModelToEqualPower(): void;
  36350. private _switchPanningModel;
  36351. /**
  36352. * Connect this sound to a sound track audio node like gain...
  36353. * @param soundTrackAudioNode the sound track audio node to connect to
  36354. */
  36355. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36356. /**
  36357. * Transform this sound into a directional source
  36358. * @param coneInnerAngle Size of the inner cone in degree
  36359. * @param coneOuterAngle Size of the outer cone in degree
  36360. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36361. */
  36362. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36363. /**
  36364. * Gets or sets the inner angle for the directional cone.
  36365. */
  36366. /**
  36367. * Gets or sets the inner angle for the directional cone.
  36368. */
  36369. directionalConeInnerAngle: number;
  36370. /**
  36371. * Gets or sets the outer angle for the directional cone.
  36372. */
  36373. /**
  36374. * Gets or sets the outer angle for the directional cone.
  36375. */
  36376. directionalConeOuterAngle: number;
  36377. /**
  36378. * Sets the position of the emitter if spatial sound is enabled
  36379. * @param newPosition Defines the new posisiton
  36380. */
  36381. setPosition(newPosition: Vector3): void;
  36382. /**
  36383. * Sets the local direction of the emitter if spatial sound is enabled
  36384. * @param newLocalDirection Defines the new local direction
  36385. */
  36386. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36387. private _updateDirection;
  36388. /** @hidden */
  36389. updateDistanceFromListener(): void;
  36390. /**
  36391. * Sets a new custom attenuation function for the sound.
  36392. * @param callback Defines the function used for the attenuation
  36393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36394. */
  36395. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36396. /**
  36397. * Play the sound
  36398. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36399. * @param offset (optional) Start the sound at a specific time in seconds
  36400. * @param length (optional) Sound duration (in seconds)
  36401. */
  36402. play(time?: number, offset?: number, length?: number): void;
  36403. private _onended;
  36404. /**
  36405. * Stop the sound
  36406. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36407. */
  36408. stop(time?: number): void;
  36409. /**
  36410. * Put the sound in pause
  36411. */
  36412. pause(): void;
  36413. /**
  36414. * Sets a dedicated volume for this sounds
  36415. * @param newVolume Define the new volume of the sound
  36416. * @param time Define time for gradual change to new volume
  36417. */
  36418. setVolume(newVolume: number, time?: number): void;
  36419. /**
  36420. * Set the sound play back rate
  36421. * @param newPlaybackRate Define the playback rate the sound should be played at
  36422. */
  36423. setPlaybackRate(newPlaybackRate: number): void;
  36424. /**
  36425. * Gets the volume of the sound.
  36426. * @returns the volume of the sound
  36427. */
  36428. getVolume(): number;
  36429. /**
  36430. * Attach the sound to a dedicated mesh
  36431. * @param transformNode The transform node to connect the sound with
  36432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36433. */
  36434. attachToMesh(transformNode: TransformNode): void;
  36435. /**
  36436. * Detach the sound from the previously attached mesh
  36437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36438. */
  36439. detachFromMesh(): void;
  36440. private _onRegisterAfterWorldMatrixUpdate;
  36441. /**
  36442. * Clone the current sound in the scene.
  36443. * @returns the new sound clone
  36444. */
  36445. clone(): Nullable<Sound>;
  36446. /**
  36447. * Gets the current underlying audio buffer containing the data
  36448. * @returns the audio buffer
  36449. */
  36450. getAudioBuffer(): Nullable<AudioBuffer>;
  36451. /**
  36452. * Serializes the Sound in a JSON representation
  36453. * @returns the JSON representation of the sound
  36454. */
  36455. serialize(): any;
  36456. /**
  36457. * Parse a JSON representation of a sound to innstantiate in a given scene
  36458. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36459. * @param scene Define the scene the new parsed sound should be created in
  36460. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36461. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36462. * @returns the newly parsed sound
  36463. */
  36464. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36465. }
  36466. }
  36467. declare module "babylonjs/Actions/directAudioActions" {
  36468. import { Action } from "babylonjs/Actions/action";
  36469. import { Condition } from "babylonjs/Actions/condition";
  36470. import { Sound } from "babylonjs/Audio/sound";
  36471. /**
  36472. * This defines an action helpful to play a defined sound on a triggered action.
  36473. */
  36474. export class PlaySoundAction extends Action {
  36475. private _sound;
  36476. /**
  36477. * Instantiate the action
  36478. * @param triggerOptions defines the trigger options
  36479. * @param sound defines the sound to play
  36480. * @param condition defines the trigger related conditions
  36481. */
  36482. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36483. /** @hidden */
  36484. _prepare(): void;
  36485. /**
  36486. * Execute the action and play the sound.
  36487. */
  36488. execute(): void;
  36489. /**
  36490. * Serializes the actions and its related information.
  36491. * @param parent defines the object to serialize in
  36492. * @returns the serialized object
  36493. */
  36494. serialize(parent: any): any;
  36495. }
  36496. /**
  36497. * This defines an action helpful to stop a defined sound on a triggered action.
  36498. */
  36499. export class StopSoundAction extends Action {
  36500. private _sound;
  36501. /**
  36502. * Instantiate the action
  36503. * @param triggerOptions defines the trigger options
  36504. * @param sound defines the sound to stop
  36505. * @param condition defines the trigger related conditions
  36506. */
  36507. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36508. /** @hidden */
  36509. _prepare(): void;
  36510. /**
  36511. * Execute the action and stop the sound.
  36512. */
  36513. execute(): void;
  36514. /**
  36515. * Serializes the actions and its related information.
  36516. * @param parent defines the object to serialize in
  36517. * @returns the serialized object
  36518. */
  36519. serialize(parent: any): any;
  36520. }
  36521. }
  36522. declare module "babylonjs/Actions/interpolateValueAction" {
  36523. import { Action } from "babylonjs/Actions/action";
  36524. import { Condition } from "babylonjs/Actions/condition";
  36525. import { Observable } from "babylonjs/Misc/observable";
  36526. /**
  36527. * This defines an action responsible to change the value of a property
  36528. * by interpolating between its current value and the newly set one once triggered.
  36529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36530. */
  36531. export class InterpolateValueAction extends Action {
  36532. /**
  36533. * Defines the path of the property where the value should be interpolated
  36534. */
  36535. propertyPath: string;
  36536. /**
  36537. * Defines the target value at the end of the interpolation.
  36538. */
  36539. value: any;
  36540. /**
  36541. * Defines the time it will take for the property to interpolate to the value.
  36542. */
  36543. duration: number;
  36544. /**
  36545. * Defines if the other scene animations should be stopped when the action has been triggered
  36546. */
  36547. stopOtherAnimations?: boolean;
  36548. /**
  36549. * Defines a callback raised once the interpolation animation has been done.
  36550. */
  36551. onInterpolationDone?: () => void;
  36552. /**
  36553. * Observable triggered once the interpolation animation has been done.
  36554. */
  36555. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36556. private _target;
  36557. private _effectiveTarget;
  36558. private _property;
  36559. /**
  36560. * Instantiate the action
  36561. * @param triggerOptions defines the trigger options
  36562. * @param target defines the object containing the value to interpolate
  36563. * @param propertyPath defines the path to the property in the target object
  36564. * @param value defines the target value at the end of the interpolation
  36565. * @param duration deines the time it will take for the property to interpolate to the value.
  36566. * @param condition defines the trigger related conditions
  36567. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36568. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36569. */
  36570. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36571. /** @hidden */
  36572. _prepare(): void;
  36573. /**
  36574. * Execute the action starts the value interpolation.
  36575. */
  36576. execute(): void;
  36577. /**
  36578. * Serializes the actions and its related information.
  36579. * @param parent defines the object to serialize in
  36580. * @returns the serialized object
  36581. */
  36582. serialize(parent: any): any;
  36583. }
  36584. }
  36585. declare module "babylonjs/Actions/index" {
  36586. export * from "babylonjs/Actions/abstractActionManager";
  36587. export * from "babylonjs/Actions/action";
  36588. export * from "babylonjs/Actions/actionEvent";
  36589. export * from "babylonjs/Actions/actionManager";
  36590. export * from "babylonjs/Actions/condition";
  36591. export * from "babylonjs/Actions/directActions";
  36592. export * from "babylonjs/Actions/directAudioActions";
  36593. export * from "babylonjs/Actions/interpolateValueAction";
  36594. }
  36595. declare module "babylonjs/Animations/index" {
  36596. export * from "babylonjs/Animations/animatable";
  36597. export * from "babylonjs/Animations/animation";
  36598. export * from "babylonjs/Animations/animationGroup";
  36599. export * from "babylonjs/Animations/animationPropertiesOverride";
  36600. export * from "babylonjs/Animations/easing";
  36601. export * from "babylonjs/Animations/runtimeAnimation";
  36602. export * from "babylonjs/Animations/animationEvent";
  36603. export * from "babylonjs/Animations/animationGroup";
  36604. export * from "babylonjs/Animations/animationKey";
  36605. export * from "babylonjs/Animations/animationRange";
  36606. export * from "babylonjs/Animations/animatable.interface";
  36607. }
  36608. declare module "babylonjs/Audio/soundTrack" {
  36609. import { Sound } from "babylonjs/Audio/sound";
  36610. import { Analyser } from "babylonjs/Audio/analyser";
  36611. import { Scene } from "babylonjs/scene";
  36612. /**
  36613. * Options allowed during the creation of a sound track.
  36614. */
  36615. export interface ISoundTrackOptions {
  36616. /**
  36617. * The volume the sound track should take during creation
  36618. */
  36619. volume?: number;
  36620. /**
  36621. * Define if the sound track is the main sound track of the scene
  36622. */
  36623. mainTrack?: boolean;
  36624. }
  36625. /**
  36626. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36627. * It will be also used in a future release to apply effects on a specific track.
  36628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36629. */
  36630. export class SoundTrack {
  36631. /**
  36632. * The unique identifier of the sound track in the scene.
  36633. */
  36634. id: number;
  36635. /**
  36636. * The list of sounds included in the sound track.
  36637. */
  36638. soundCollection: Array<Sound>;
  36639. private _outputAudioNode;
  36640. private _scene;
  36641. private _isMainTrack;
  36642. private _connectedAnalyser;
  36643. private _options;
  36644. private _isInitialized;
  36645. /**
  36646. * Creates a new sound track.
  36647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36648. * @param scene Define the scene the sound track belongs to
  36649. * @param options
  36650. */
  36651. constructor(scene: Scene, options?: ISoundTrackOptions);
  36652. private _initializeSoundTrackAudioGraph;
  36653. /**
  36654. * Release the sound track and its associated resources
  36655. */
  36656. dispose(): void;
  36657. /**
  36658. * Adds a sound to this sound track
  36659. * @param sound define the cound to add
  36660. * @ignoreNaming
  36661. */
  36662. AddSound(sound: Sound): void;
  36663. /**
  36664. * Removes a sound to this sound track
  36665. * @param sound define the cound to remove
  36666. * @ignoreNaming
  36667. */
  36668. RemoveSound(sound: Sound): void;
  36669. /**
  36670. * Set a global volume for the full sound track.
  36671. * @param newVolume Define the new volume of the sound track
  36672. */
  36673. setVolume(newVolume: number): void;
  36674. /**
  36675. * Switch the panning model to HRTF:
  36676. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36678. */
  36679. switchPanningModelToHRTF(): void;
  36680. /**
  36681. * Switch the panning model to Equal Power:
  36682. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36684. */
  36685. switchPanningModelToEqualPower(): void;
  36686. /**
  36687. * Connect the sound track to an audio analyser allowing some amazing
  36688. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36690. * @param analyser The analyser to connect to the engine
  36691. */
  36692. connectToAnalyser(analyser: Analyser): void;
  36693. }
  36694. }
  36695. declare module "babylonjs/Audio/audioSceneComponent" {
  36696. import { Sound } from "babylonjs/Audio/sound";
  36697. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36698. import { Nullable } from "babylonjs/types";
  36699. import { Vector3 } from "babylonjs/Maths/math.vector";
  36700. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36701. import { Scene } from "babylonjs/scene";
  36702. import { AbstractScene } from "babylonjs/abstractScene";
  36703. import "babylonjs/Audio/audioEngine";
  36704. module "babylonjs/abstractScene" {
  36705. interface AbstractScene {
  36706. /**
  36707. * The list of sounds used in the scene.
  36708. */
  36709. sounds: Nullable<Array<Sound>>;
  36710. }
  36711. }
  36712. module "babylonjs/scene" {
  36713. interface Scene {
  36714. /**
  36715. * @hidden
  36716. * Backing field
  36717. */
  36718. _mainSoundTrack: SoundTrack;
  36719. /**
  36720. * The main sound track played by the scene.
  36721. * It cotains your primary collection of sounds.
  36722. */
  36723. mainSoundTrack: SoundTrack;
  36724. /**
  36725. * The list of sound tracks added to the scene
  36726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36727. */
  36728. soundTracks: Nullable<Array<SoundTrack>>;
  36729. /**
  36730. * Gets a sound using a given name
  36731. * @param name defines the name to search for
  36732. * @return the found sound or null if not found at all.
  36733. */
  36734. getSoundByName(name: string): Nullable<Sound>;
  36735. /**
  36736. * Gets or sets if audio support is enabled
  36737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36738. */
  36739. audioEnabled: boolean;
  36740. /**
  36741. * Gets or sets if audio will be output to headphones
  36742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36743. */
  36744. headphone: boolean;
  36745. /**
  36746. * Gets or sets custom audio listener position provider
  36747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36748. */
  36749. audioListenerPositionProvider: Nullable<() => Vector3>;
  36750. /**
  36751. * Gets or sets a refresh rate when using 3D audio positioning
  36752. */
  36753. audioPositioningRefreshRate: number;
  36754. }
  36755. }
  36756. /**
  36757. * Defines the sound scene component responsible to manage any sounds
  36758. * in a given scene.
  36759. */
  36760. export class AudioSceneComponent implements ISceneSerializableComponent {
  36761. /**
  36762. * The component name helpfull to identify the component in the list of scene components.
  36763. */
  36764. readonly name: string;
  36765. /**
  36766. * The scene the component belongs to.
  36767. */
  36768. scene: Scene;
  36769. private _audioEnabled;
  36770. /**
  36771. * Gets whether audio is enabled or not.
  36772. * Please use related enable/disable method to switch state.
  36773. */
  36774. readonly audioEnabled: boolean;
  36775. private _headphone;
  36776. /**
  36777. * Gets whether audio is outputing to headphone or not.
  36778. * Please use the according Switch methods to change output.
  36779. */
  36780. readonly headphone: boolean;
  36781. /**
  36782. * Gets or sets a refresh rate when using 3D audio positioning
  36783. */
  36784. audioPositioningRefreshRate: number;
  36785. private _audioListenerPositionProvider;
  36786. /**
  36787. * Gets the current audio listener position provider
  36788. */
  36789. /**
  36790. * Sets a custom listener position for all sounds in the scene
  36791. * By default, this is the position of the first active camera
  36792. */
  36793. audioListenerPositionProvider: Nullable<() => Vector3>;
  36794. /**
  36795. * Creates a new instance of the component for the given scene
  36796. * @param scene Defines the scene to register the component in
  36797. */
  36798. constructor(scene: Scene);
  36799. /**
  36800. * Registers the component in a given scene
  36801. */
  36802. register(): void;
  36803. /**
  36804. * Rebuilds the elements related to this component in case of
  36805. * context lost for instance.
  36806. */
  36807. rebuild(): void;
  36808. /**
  36809. * Serializes the component data to the specified json object
  36810. * @param serializationObject The object to serialize to
  36811. */
  36812. serialize(serializationObject: any): void;
  36813. /**
  36814. * Adds all the elements from the container to the scene
  36815. * @param container the container holding the elements
  36816. */
  36817. addFromContainer(container: AbstractScene): void;
  36818. /**
  36819. * Removes all the elements in the container from the scene
  36820. * @param container contains the elements to remove
  36821. * @param dispose if the removed element should be disposed (default: false)
  36822. */
  36823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36824. /**
  36825. * Disposes the component and the associated ressources.
  36826. */
  36827. dispose(): void;
  36828. /**
  36829. * Disables audio in the associated scene.
  36830. */
  36831. disableAudio(): void;
  36832. /**
  36833. * Enables audio in the associated scene.
  36834. */
  36835. enableAudio(): void;
  36836. /**
  36837. * Switch audio to headphone output.
  36838. */
  36839. switchAudioModeForHeadphones(): void;
  36840. /**
  36841. * Switch audio to normal speakers.
  36842. */
  36843. switchAudioModeForNormalSpeakers(): void;
  36844. private _cachedCameraDirection;
  36845. private _cachedCameraPosition;
  36846. private _lastCheck;
  36847. private _afterRender;
  36848. }
  36849. }
  36850. declare module "babylonjs/Audio/weightedsound" {
  36851. import { Sound } from "babylonjs/Audio/sound";
  36852. /**
  36853. * Wraps one or more Sound objects and selects one with random weight for playback.
  36854. */
  36855. export class WeightedSound {
  36856. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36857. loop: boolean;
  36858. private _coneInnerAngle;
  36859. private _coneOuterAngle;
  36860. private _volume;
  36861. /** A Sound is currently playing. */
  36862. isPlaying: boolean;
  36863. /** A Sound is currently paused. */
  36864. isPaused: boolean;
  36865. private _sounds;
  36866. private _weights;
  36867. private _currentIndex?;
  36868. /**
  36869. * Creates a new WeightedSound from the list of sounds given.
  36870. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36871. * @param sounds Array of Sounds that will be selected from.
  36872. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36873. */
  36874. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36875. /**
  36876. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36877. */
  36878. /**
  36879. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36880. */
  36881. directionalConeInnerAngle: number;
  36882. /**
  36883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36885. */
  36886. /**
  36887. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36888. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36889. */
  36890. directionalConeOuterAngle: number;
  36891. /**
  36892. * Playback volume.
  36893. */
  36894. /**
  36895. * Playback volume.
  36896. */
  36897. volume: number;
  36898. private _onended;
  36899. /**
  36900. * Suspend playback
  36901. */
  36902. pause(): void;
  36903. /**
  36904. * Stop playback
  36905. */
  36906. stop(): void;
  36907. /**
  36908. * Start playback.
  36909. * @param startOffset Position the clip head at a specific time in seconds.
  36910. */
  36911. play(startOffset?: number): void;
  36912. }
  36913. }
  36914. declare module "babylonjs/Audio/index" {
  36915. export * from "babylonjs/Audio/analyser";
  36916. export * from "babylonjs/Audio/audioEngine";
  36917. export * from "babylonjs/Audio/audioSceneComponent";
  36918. export * from "babylonjs/Audio/sound";
  36919. export * from "babylonjs/Audio/soundTrack";
  36920. export * from "babylonjs/Audio/weightedsound";
  36921. }
  36922. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36923. import { Behavior } from "babylonjs/Behaviors/behavior";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BackEase } from "babylonjs/Animations/easing";
  36926. /**
  36927. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36928. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36929. */
  36930. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36931. /**
  36932. * Gets the name of the behavior.
  36933. */
  36934. readonly name: string;
  36935. /**
  36936. * The easing function used by animations
  36937. */
  36938. static EasingFunction: BackEase;
  36939. /**
  36940. * The easing mode used by animations
  36941. */
  36942. static EasingMode: number;
  36943. /**
  36944. * The duration of the animation, in milliseconds
  36945. */
  36946. transitionDuration: number;
  36947. /**
  36948. * Length of the distance animated by the transition when lower radius is reached
  36949. */
  36950. lowerRadiusTransitionRange: number;
  36951. /**
  36952. * Length of the distance animated by the transition when upper radius is reached
  36953. */
  36954. upperRadiusTransitionRange: number;
  36955. private _autoTransitionRange;
  36956. /**
  36957. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36958. */
  36959. /**
  36960. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36961. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36962. */
  36963. autoTransitionRange: boolean;
  36964. private _attachedCamera;
  36965. private _onAfterCheckInputsObserver;
  36966. private _onMeshTargetChangedObserver;
  36967. /**
  36968. * Initializes the behavior.
  36969. */
  36970. init(): void;
  36971. /**
  36972. * Attaches the behavior to its arc rotate camera.
  36973. * @param camera Defines the camera to attach the behavior to
  36974. */
  36975. attach(camera: ArcRotateCamera): void;
  36976. /**
  36977. * Detaches the behavior from its current arc rotate camera.
  36978. */
  36979. detach(): void;
  36980. private _radiusIsAnimating;
  36981. private _radiusBounceTransition;
  36982. private _animatables;
  36983. private _cachedWheelPrecision;
  36984. /**
  36985. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36986. * @param radiusLimit The limit to check against.
  36987. * @return Bool to indicate if at limit.
  36988. */
  36989. private _isRadiusAtLimit;
  36990. /**
  36991. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36992. * @param radiusDelta The delta by which to animate to. Can be negative.
  36993. */
  36994. private _applyBoundRadiusAnimation;
  36995. /**
  36996. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36997. */
  36998. protected _clearAnimationLocks(): void;
  36999. /**
  37000. * Stops and removes all animations that have been applied to the camera
  37001. */
  37002. stopAllAnimations(): void;
  37003. }
  37004. }
  37005. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37006. import { Behavior } from "babylonjs/Behaviors/behavior";
  37007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37008. import { ExponentialEase } from "babylonjs/Animations/easing";
  37009. import { Nullable } from "babylonjs/types";
  37010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37011. import { Vector3 } from "babylonjs/Maths/math.vector";
  37012. /**
  37013. * 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.
  37014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37015. */
  37016. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37017. /**
  37018. * Gets the name of the behavior.
  37019. */
  37020. readonly name: string;
  37021. private _mode;
  37022. private _radiusScale;
  37023. private _positionScale;
  37024. private _defaultElevation;
  37025. private _elevationReturnTime;
  37026. private _elevationReturnWaitTime;
  37027. private _zoomStopsAnimation;
  37028. private _framingTime;
  37029. /**
  37030. * The easing function used by animations
  37031. */
  37032. static EasingFunction: ExponentialEase;
  37033. /**
  37034. * The easing mode used by animations
  37035. */
  37036. static EasingMode: number;
  37037. /**
  37038. * Sets the current mode used by the behavior
  37039. */
  37040. /**
  37041. * Gets current mode used by the behavior.
  37042. */
  37043. mode: number;
  37044. /**
  37045. * Sets the scale applied to the radius (1 by default)
  37046. */
  37047. /**
  37048. * Gets the scale applied to the radius
  37049. */
  37050. radiusScale: number;
  37051. /**
  37052. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37053. */
  37054. /**
  37055. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37056. */
  37057. positionScale: number;
  37058. /**
  37059. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37060. * behaviour is triggered, in radians.
  37061. */
  37062. /**
  37063. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37064. * behaviour is triggered, in radians.
  37065. */
  37066. defaultElevation: number;
  37067. /**
  37068. * Sets the time (in milliseconds) taken to return to the default beta position.
  37069. * Negative value indicates camera should not return to default.
  37070. */
  37071. /**
  37072. * Gets the time (in milliseconds) taken to return to the default beta position.
  37073. * Negative value indicates camera should not return to default.
  37074. */
  37075. elevationReturnTime: number;
  37076. /**
  37077. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37078. */
  37079. /**
  37080. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37081. */
  37082. elevationReturnWaitTime: number;
  37083. /**
  37084. * Sets the flag that indicates if user zooming should stop animation.
  37085. */
  37086. /**
  37087. * Gets the flag that indicates if user zooming should stop animation.
  37088. */
  37089. zoomStopsAnimation: boolean;
  37090. /**
  37091. * Sets the transition time when framing the mesh, in milliseconds
  37092. */
  37093. /**
  37094. * Gets the transition time when framing the mesh, in milliseconds
  37095. */
  37096. framingTime: number;
  37097. /**
  37098. * Define if the behavior should automatically change the configured
  37099. * camera limits and sensibilities.
  37100. */
  37101. autoCorrectCameraLimitsAndSensibility: boolean;
  37102. private _onPrePointerObservableObserver;
  37103. private _onAfterCheckInputsObserver;
  37104. private _onMeshTargetChangedObserver;
  37105. private _attachedCamera;
  37106. private _isPointerDown;
  37107. private _lastInteractionTime;
  37108. /**
  37109. * Initializes the behavior.
  37110. */
  37111. init(): void;
  37112. /**
  37113. * Attaches the behavior to its arc rotate camera.
  37114. * @param camera Defines the camera to attach the behavior to
  37115. */
  37116. attach(camera: ArcRotateCamera): void;
  37117. /**
  37118. * Detaches the behavior from its current arc rotate camera.
  37119. */
  37120. detach(): void;
  37121. private _animatables;
  37122. private _betaIsAnimating;
  37123. private _betaTransition;
  37124. private _radiusTransition;
  37125. private _vectorTransition;
  37126. /**
  37127. * Targets the given mesh and updates zoom level accordingly.
  37128. * @param mesh The mesh to target.
  37129. * @param radius Optional. If a cached radius position already exists, overrides default.
  37130. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37131. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37132. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37133. */
  37134. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37135. /**
  37136. * Targets the given mesh with its children and updates zoom level accordingly.
  37137. * @param mesh The mesh to target.
  37138. * @param radius Optional. If a cached radius position already exists, overrides default.
  37139. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37140. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37141. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37142. */
  37143. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37144. /**
  37145. * Targets the given meshes with their children and updates zoom level accordingly.
  37146. * @param meshes The mesh to target.
  37147. * @param radius Optional. If a cached radius position already exists, overrides default.
  37148. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37151. */
  37152. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37153. /**
  37154. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37155. * @param minimumWorld Determines the smaller position of the bounding box extend
  37156. * @param maximumWorld Determines the bigger position of the bounding box extend
  37157. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37158. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37159. */
  37160. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37161. /**
  37162. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37163. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37164. * frustum width.
  37165. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37166. * to fully enclose the mesh in the viewing frustum.
  37167. */
  37168. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37169. /**
  37170. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37171. * is automatically returned to its default position (expected to be above ground plane).
  37172. */
  37173. private _maintainCameraAboveGround;
  37174. /**
  37175. * Returns the frustum slope based on the canvas ratio and camera FOV
  37176. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37177. */
  37178. private _getFrustumSlope;
  37179. /**
  37180. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37181. */
  37182. private _clearAnimationLocks;
  37183. /**
  37184. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37185. */
  37186. private _applyUserInteraction;
  37187. /**
  37188. * Stops and removes all animations that have been applied to the camera
  37189. */
  37190. stopAllAnimations(): void;
  37191. /**
  37192. * Gets a value indicating if the user is moving the camera
  37193. */
  37194. readonly isUserIsMoving: boolean;
  37195. /**
  37196. * The camera can move all the way towards the mesh.
  37197. */
  37198. static IgnoreBoundsSizeMode: number;
  37199. /**
  37200. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37201. */
  37202. static FitFrustumSidesMode: number;
  37203. }
  37204. }
  37205. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37206. import { Nullable } from "babylonjs/types";
  37207. import { Camera } from "babylonjs/Cameras/camera";
  37208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37209. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37210. /**
  37211. * Base class for Camera Pointer Inputs.
  37212. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37213. * for example usage.
  37214. */
  37215. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37216. /**
  37217. * Defines the camera the input is attached to.
  37218. */
  37219. abstract camera: Camera;
  37220. /**
  37221. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37222. */
  37223. protected _altKey: boolean;
  37224. protected _ctrlKey: boolean;
  37225. protected _metaKey: boolean;
  37226. protected _shiftKey: boolean;
  37227. /**
  37228. * Which mouse buttons were pressed at time of last mouse event.
  37229. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37230. */
  37231. protected _buttonsPressed: number;
  37232. /**
  37233. * Defines the buttons associated with the input to handle camera move.
  37234. */
  37235. buttons: number[];
  37236. /**
  37237. * Attach the input controls to a specific dom element to get the input from.
  37238. * @param element Defines the element the controls should be listened from
  37239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37240. */
  37241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37242. /**
  37243. * Detach the current controls from the specified dom element.
  37244. * @param element Defines the element to stop listening the inputs from
  37245. */
  37246. detachControl(element: Nullable<HTMLElement>): void;
  37247. /**
  37248. * Gets the class name of the current input.
  37249. * @returns the class name
  37250. */
  37251. getClassName(): string;
  37252. /**
  37253. * Get the friendly name associated with the input class.
  37254. * @returns the input friendly name
  37255. */
  37256. getSimpleName(): string;
  37257. /**
  37258. * Called on pointer POINTERDOUBLETAP event.
  37259. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37260. */
  37261. protected onDoubleTap(type: string): void;
  37262. /**
  37263. * Called on pointer POINTERMOVE event if only a single touch is active.
  37264. * Override this method to provide functionality.
  37265. */
  37266. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37267. /**
  37268. * Called on pointer POINTERMOVE event if multiple touches are active.
  37269. * Override this method to provide functionality.
  37270. */
  37271. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37272. /**
  37273. * Called on JS contextmenu event.
  37274. * Override this method to provide functionality.
  37275. */
  37276. protected onContextMenu(evt: PointerEvent): void;
  37277. /**
  37278. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37279. * press.
  37280. * Override this method to provide functionality.
  37281. */
  37282. protected onButtonDown(evt: PointerEvent): void;
  37283. /**
  37284. * Called each time a new POINTERUP event occurs. Ie, for each button
  37285. * release.
  37286. * Override this method to provide functionality.
  37287. */
  37288. protected onButtonUp(evt: PointerEvent): void;
  37289. /**
  37290. * Called when window becomes inactive.
  37291. * Override this method to provide functionality.
  37292. */
  37293. protected onLostFocus(): void;
  37294. private _pointerInput;
  37295. private _observer;
  37296. private _onLostFocus;
  37297. private pointA;
  37298. private pointB;
  37299. }
  37300. }
  37301. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37302. import { Nullable } from "babylonjs/types";
  37303. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37304. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37305. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37306. /**
  37307. * Manage the pointers inputs to control an arc rotate camera.
  37308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37309. */
  37310. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37311. /**
  37312. * Defines the camera the input is attached to.
  37313. */
  37314. camera: ArcRotateCamera;
  37315. /**
  37316. * Gets the class name of the current input.
  37317. * @returns the class name
  37318. */
  37319. getClassName(): string;
  37320. /**
  37321. * Defines the buttons associated with the input to handle camera move.
  37322. */
  37323. buttons: number[];
  37324. /**
  37325. * Defines the pointer angular sensibility along the X axis or how fast is
  37326. * the camera rotating.
  37327. */
  37328. angularSensibilityX: number;
  37329. /**
  37330. * Defines the pointer angular sensibility along the Y axis or how fast is
  37331. * the camera rotating.
  37332. */
  37333. angularSensibilityY: number;
  37334. /**
  37335. * Defines the pointer pinch precision or how fast is the camera zooming.
  37336. */
  37337. pinchPrecision: number;
  37338. /**
  37339. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37340. * from 0.
  37341. * It defines the percentage of current camera.radius to use as delta when
  37342. * pinch zoom is used.
  37343. */
  37344. pinchDeltaPercentage: number;
  37345. /**
  37346. * Defines the pointer panning sensibility or how fast is the camera moving.
  37347. */
  37348. panningSensibility: number;
  37349. /**
  37350. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37351. */
  37352. multiTouchPanning: boolean;
  37353. /**
  37354. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37355. * zoom (pinch) through multitouch.
  37356. */
  37357. multiTouchPanAndZoom: boolean;
  37358. /**
  37359. * Revers pinch action direction.
  37360. */
  37361. pinchInwards: boolean;
  37362. private _isPanClick;
  37363. private _twoFingerActivityCount;
  37364. private _isPinching;
  37365. /**
  37366. * Called on pointer POINTERMOVE event if only a single touch is active.
  37367. */
  37368. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37369. /**
  37370. * Called on pointer POINTERDOUBLETAP event.
  37371. */
  37372. protected onDoubleTap(type: string): void;
  37373. /**
  37374. * Called on pointer POINTERMOVE event if multiple touches are active.
  37375. */
  37376. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37377. /**
  37378. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37379. * press.
  37380. */
  37381. protected onButtonDown(evt: PointerEvent): void;
  37382. /**
  37383. * Called each time a new POINTERUP event occurs. Ie, for each button
  37384. * release.
  37385. */
  37386. protected onButtonUp(evt: PointerEvent): void;
  37387. /**
  37388. * Called when window becomes inactive.
  37389. */
  37390. protected onLostFocus(): void;
  37391. }
  37392. }
  37393. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37394. import { Nullable } from "babylonjs/types";
  37395. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37396. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37397. /**
  37398. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37400. */
  37401. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37402. /**
  37403. * Defines the camera the input is attached to.
  37404. */
  37405. camera: ArcRotateCamera;
  37406. /**
  37407. * Defines the list of key codes associated with the up action (increase alpha)
  37408. */
  37409. keysUp: number[];
  37410. /**
  37411. * Defines the list of key codes associated with the down action (decrease alpha)
  37412. */
  37413. keysDown: number[];
  37414. /**
  37415. * Defines the list of key codes associated with the left action (increase beta)
  37416. */
  37417. keysLeft: number[];
  37418. /**
  37419. * Defines the list of key codes associated with the right action (decrease beta)
  37420. */
  37421. keysRight: number[];
  37422. /**
  37423. * Defines the list of key codes associated with the reset action.
  37424. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37425. */
  37426. keysReset: number[];
  37427. /**
  37428. * Defines the panning sensibility of the inputs.
  37429. * (How fast is the camera paning)
  37430. */
  37431. panningSensibility: number;
  37432. /**
  37433. * Defines the zooming sensibility of the inputs.
  37434. * (How fast is the camera zooming)
  37435. */
  37436. zoomingSensibility: number;
  37437. /**
  37438. * Defines wether maintaining the alt key down switch the movement mode from
  37439. * orientation to zoom.
  37440. */
  37441. useAltToZoom: boolean;
  37442. /**
  37443. * Rotation speed of the camera
  37444. */
  37445. angularSpeed: number;
  37446. private _keys;
  37447. private _ctrlPressed;
  37448. private _altPressed;
  37449. private _onCanvasBlurObserver;
  37450. private _onKeyboardObserver;
  37451. private _engine;
  37452. private _scene;
  37453. /**
  37454. * Attach the input controls to a specific dom element to get the input from.
  37455. * @param element Defines the element the controls should be listened from
  37456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37457. */
  37458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37459. /**
  37460. * Detach the current controls from the specified dom element.
  37461. * @param element Defines the element to stop listening the inputs from
  37462. */
  37463. detachControl(element: Nullable<HTMLElement>): void;
  37464. /**
  37465. * Update the current camera state depending on the inputs that have been used this frame.
  37466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37467. */
  37468. checkInputs(): void;
  37469. /**
  37470. * Gets the class name of the current intput.
  37471. * @returns the class name
  37472. */
  37473. getClassName(): string;
  37474. /**
  37475. * Get the friendly name associated with the input class.
  37476. * @returns the input friendly name
  37477. */
  37478. getSimpleName(): string;
  37479. }
  37480. }
  37481. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37482. import { Nullable } from "babylonjs/types";
  37483. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37484. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37485. /**
  37486. * Manage the mouse wheel inputs to control an arc rotate camera.
  37487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37488. */
  37489. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37490. /**
  37491. * Defines the camera the input is attached to.
  37492. */
  37493. camera: ArcRotateCamera;
  37494. /**
  37495. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37496. */
  37497. wheelPrecision: number;
  37498. /**
  37499. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37500. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37501. */
  37502. wheelDeltaPercentage: number;
  37503. private _wheel;
  37504. private _observer;
  37505. private computeDeltaFromMouseWheelLegacyEvent;
  37506. /**
  37507. * Attach the input controls to a specific dom element to get the input from.
  37508. * @param element Defines the element the controls should be listened from
  37509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37510. */
  37511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37512. /**
  37513. * Detach the current controls from the specified dom element.
  37514. * @param element Defines the element to stop listening the inputs from
  37515. */
  37516. detachControl(element: Nullable<HTMLElement>): void;
  37517. /**
  37518. * Gets the class name of the current intput.
  37519. * @returns the class name
  37520. */
  37521. getClassName(): string;
  37522. /**
  37523. * Get the friendly name associated with the input class.
  37524. * @returns the input friendly name
  37525. */
  37526. getSimpleName(): string;
  37527. }
  37528. }
  37529. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37530. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37531. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37532. /**
  37533. * Default Inputs manager for the ArcRotateCamera.
  37534. * It groups all the default supported inputs for ease of use.
  37535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37536. */
  37537. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37538. /**
  37539. * Instantiates a new ArcRotateCameraInputsManager.
  37540. * @param camera Defines the camera the inputs belong to
  37541. */
  37542. constructor(camera: ArcRotateCamera);
  37543. /**
  37544. * Add mouse wheel input support to the input manager.
  37545. * @returns the current input manager
  37546. */
  37547. addMouseWheel(): ArcRotateCameraInputsManager;
  37548. /**
  37549. * Add pointers input support to the input manager.
  37550. * @returns the current input manager
  37551. */
  37552. addPointers(): ArcRotateCameraInputsManager;
  37553. /**
  37554. * Add keyboard input support to the input manager.
  37555. * @returns the current input manager
  37556. */
  37557. addKeyboard(): ArcRotateCameraInputsManager;
  37558. }
  37559. }
  37560. declare module "babylonjs/Cameras/arcRotateCamera" {
  37561. import { Observable } from "babylonjs/Misc/observable";
  37562. import { Nullable } from "babylonjs/types";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37566. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37567. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37568. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37569. import { Camera } from "babylonjs/Cameras/camera";
  37570. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37571. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37572. import { Collider } from "babylonjs/Collisions/collider";
  37573. /**
  37574. * This represents an orbital type of camera.
  37575. *
  37576. * 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.
  37577. * 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.
  37578. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37579. */
  37580. export class ArcRotateCamera extends TargetCamera {
  37581. /**
  37582. * Defines the rotation angle of the camera along the longitudinal axis.
  37583. */
  37584. alpha: number;
  37585. /**
  37586. * Defines the rotation angle of the camera along the latitudinal axis.
  37587. */
  37588. beta: number;
  37589. /**
  37590. * Defines the radius of the camera from it s target point.
  37591. */
  37592. radius: number;
  37593. protected _target: Vector3;
  37594. protected _targetHost: Nullable<AbstractMesh>;
  37595. /**
  37596. * Defines the target point of the camera.
  37597. * The camera looks towards it form the radius distance.
  37598. */
  37599. target: Vector3;
  37600. /**
  37601. * Define the current local position of the camera in the scene
  37602. */
  37603. position: Vector3;
  37604. protected _upVector: Vector3;
  37605. protected _upToYMatrix: Matrix;
  37606. protected _YToUpMatrix: Matrix;
  37607. /**
  37608. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37609. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37610. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37611. */
  37612. upVector: Vector3;
  37613. /**
  37614. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37615. */
  37616. setMatUp(): void;
  37617. /**
  37618. * Current inertia value on the longitudinal axis.
  37619. * The bigger this number the longer it will take for the camera to stop.
  37620. */
  37621. inertialAlphaOffset: number;
  37622. /**
  37623. * Current inertia value on the latitudinal axis.
  37624. * The bigger this number the longer it will take for the camera to stop.
  37625. */
  37626. inertialBetaOffset: number;
  37627. /**
  37628. * Current inertia value on the radius axis.
  37629. * The bigger this number the longer it will take for the camera to stop.
  37630. */
  37631. inertialRadiusOffset: number;
  37632. /**
  37633. * Minimum allowed angle on the longitudinal axis.
  37634. * This can help limiting how the Camera is able to move in the scene.
  37635. */
  37636. lowerAlphaLimit: Nullable<number>;
  37637. /**
  37638. * Maximum allowed angle on the longitudinal axis.
  37639. * This can help limiting how the Camera is able to move in the scene.
  37640. */
  37641. upperAlphaLimit: Nullable<number>;
  37642. /**
  37643. * Minimum allowed angle on the latitudinal axis.
  37644. * This can help limiting how the Camera is able to move in the scene.
  37645. */
  37646. lowerBetaLimit: number;
  37647. /**
  37648. * Maximum allowed angle on the latitudinal axis.
  37649. * This can help limiting how the Camera is able to move in the scene.
  37650. */
  37651. upperBetaLimit: number;
  37652. /**
  37653. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37654. * This can help limiting how the Camera is able to move in the scene.
  37655. */
  37656. lowerRadiusLimit: Nullable<number>;
  37657. /**
  37658. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37659. * This can help limiting how the Camera is able to move in the scene.
  37660. */
  37661. upperRadiusLimit: Nullable<number>;
  37662. /**
  37663. * Defines the current inertia value used during panning of the camera along the X axis.
  37664. */
  37665. inertialPanningX: number;
  37666. /**
  37667. * Defines the current inertia value used during panning of the camera along the Y axis.
  37668. */
  37669. inertialPanningY: number;
  37670. /**
  37671. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37672. * Basically if your fingers moves away from more than this distance you will be considered
  37673. * in pinch mode.
  37674. */
  37675. pinchToPanMaxDistance: number;
  37676. /**
  37677. * Defines the maximum distance the camera can pan.
  37678. * This could help keeping the cammera always in your scene.
  37679. */
  37680. panningDistanceLimit: Nullable<number>;
  37681. /**
  37682. * Defines the target of the camera before paning.
  37683. */
  37684. panningOriginTarget: Vector3;
  37685. /**
  37686. * Defines the value of the inertia used during panning.
  37687. * 0 would mean stop inertia and one would mean no decelleration at all.
  37688. */
  37689. panningInertia: number;
  37690. /**
  37691. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37692. */
  37693. angularSensibilityX: number;
  37694. /**
  37695. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37696. */
  37697. angularSensibilityY: number;
  37698. /**
  37699. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37700. */
  37701. pinchPrecision: number;
  37702. /**
  37703. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37704. * It will be used instead of pinchDeltaPrecision if different from 0.
  37705. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37706. */
  37707. pinchDeltaPercentage: number;
  37708. /**
  37709. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37710. */
  37711. panningSensibility: number;
  37712. /**
  37713. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37714. */
  37715. keysUp: number[];
  37716. /**
  37717. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37718. */
  37719. keysDown: number[];
  37720. /**
  37721. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37722. */
  37723. keysLeft: number[];
  37724. /**
  37725. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37726. */
  37727. keysRight: number[];
  37728. /**
  37729. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37730. */
  37731. wheelPrecision: number;
  37732. /**
  37733. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37734. * It will be used instead of pinchDeltaPrecision if different from 0.
  37735. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37736. */
  37737. wheelDeltaPercentage: number;
  37738. /**
  37739. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37740. */
  37741. zoomOnFactor: number;
  37742. /**
  37743. * Defines a screen offset for the camera position.
  37744. */
  37745. targetScreenOffset: Vector2;
  37746. /**
  37747. * Allows the camera to be completely reversed.
  37748. * If false the camera can not arrive upside down.
  37749. */
  37750. allowUpsideDown: boolean;
  37751. /**
  37752. * Define if double tap/click is used to restore the previously saved state of the camera.
  37753. */
  37754. useInputToRestoreState: boolean;
  37755. /** @hidden */
  37756. _viewMatrix: Matrix;
  37757. /** @hidden */
  37758. _useCtrlForPanning: boolean;
  37759. /** @hidden */
  37760. _panningMouseButton: number;
  37761. /**
  37762. * Defines the input associated to the camera.
  37763. */
  37764. inputs: ArcRotateCameraInputsManager;
  37765. /** @hidden */
  37766. _reset: () => void;
  37767. /**
  37768. * Defines the allowed panning axis.
  37769. */
  37770. panningAxis: Vector3;
  37771. protected _localDirection: Vector3;
  37772. protected _transformedDirection: Vector3;
  37773. private _bouncingBehavior;
  37774. /**
  37775. * Gets the bouncing behavior of the camera if it has been enabled.
  37776. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37777. */
  37778. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37779. /**
  37780. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37781. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37782. */
  37783. useBouncingBehavior: boolean;
  37784. private _framingBehavior;
  37785. /**
  37786. * Gets the framing behavior of the camera if it has been enabled.
  37787. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37788. */
  37789. readonly framingBehavior: Nullable<FramingBehavior>;
  37790. /**
  37791. * Defines if the framing behavior of the camera is enabled on the camera.
  37792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37793. */
  37794. useFramingBehavior: boolean;
  37795. private _autoRotationBehavior;
  37796. /**
  37797. * Gets the auto rotation behavior of the camera if it has been enabled.
  37798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37799. */
  37800. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37801. /**
  37802. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37803. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37804. */
  37805. useAutoRotationBehavior: boolean;
  37806. /**
  37807. * Observable triggered when the mesh target has been changed on the camera.
  37808. */
  37809. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37810. /**
  37811. * Event raised when the camera is colliding with a mesh.
  37812. */
  37813. onCollide: (collidedMesh: AbstractMesh) => void;
  37814. /**
  37815. * Defines whether the camera should check collision with the objects oh the scene.
  37816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37817. */
  37818. checkCollisions: boolean;
  37819. /**
  37820. * Defines the collision radius of the camera.
  37821. * This simulates a sphere around the camera.
  37822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37823. */
  37824. collisionRadius: Vector3;
  37825. protected _collider: Collider;
  37826. protected _previousPosition: Vector3;
  37827. protected _collisionVelocity: Vector3;
  37828. protected _newPosition: Vector3;
  37829. protected _previousAlpha: number;
  37830. protected _previousBeta: number;
  37831. protected _previousRadius: number;
  37832. protected _collisionTriggered: boolean;
  37833. protected _targetBoundingCenter: Nullable<Vector3>;
  37834. private _computationVector;
  37835. /**
  37836. * Instantiates a new ArcRotateCamera in a given scene
  37837. * @param name Defines the name of the camera
  37838. * @param alpha Defines the camera rotation along the logitudinal axis
  37839. * @param beta Defines the camera rotation along the latitudinal axis
  37840. * @param radius Defines the camera distance from its target
  37841. * @param target Defines the camera target
  37842. * @param scene Defines the scene the camera belongs to
  37843. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37844. */
  37845. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37846. /** @hidden */
  37847. _initCache(): void;
  37848. /** @hidden */
  37849. _updateCache(ignoreParentClass?: boolean): void;
  37850. protected _getTargetPosition(): Vector3;
  37851. private _storedAlpha;
  37852. private _storedBeta;
  37853. private _storedRadius;
  37854. private _storedTarget;
  37855. private _storedTargetScreenOffset;
  37856. /**
  37857. * Stores the current state of the camera (alpha, beta, radius and target)
  37858. * @returns the camera itself
  37859. */
  37860. storeState(): Camera;
  37861. /**
  37862. * @hidden
  37863. * Restored camera state. You must call storeState() first
  37864. */
  37865. _restoreStateValues(): boolean;
  37866. /** @hidden */
  37867. _isSynchronizedViewMatrix(): boolean;
  37868. /**
  37869. * Attached controls to the current camera.
  37870. * @param element Defines the element the controls should be listened from
  37871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37872. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37873. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37874. */
  37875. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37876. /**
  37877. * Detach the current controls from the camera.
  37878. * The camera will stop reacting to inputs.
  37879. * @param element Defines the element to stop listening the inputs from
  37880. */
  37881. detachControl(element: HTMLElement): void;
  37882. /** @hidden */
  37883. _checkInputs(): void;
  37884. protected _checkLimits(): void;
  37885. /**
  37886. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37887. */
  37888. rebuildAnglesAndRadius(): void;
  37889. /**
  37890. * Use a position to define the current camera related information like alpha, beta and radius
  37891. * @param position Defines the position to set the camera at
  37892. */
  37893. setPosition(position: Vector3): void;
  37894. /**
  37895. * Defines the target the camera should look at.
  37896. * This will automatically adapt alpha beta and radius to fit within the new target.
  37897. * @param target Defines the new target as a Vector or a mesh
  37898. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37899. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37900. */
  37901. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37902. /** @hidden */
  37903. _getViewMatrix(): Matrix;
  37904. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37905. /**
  37906. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37907. * @param meshes Defines the mesh to zoom on
  37908. * @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)
  37909. */
  37910. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37911. /**
  37912. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37913. * The target will be changed but the radius
  37914. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37915. * @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)
  37916. */
  37917. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37918. min: Vector3;
  37919. max: Vector3;
  37920. distance: number;
  37921. }, doNotUpdateMaxZ?: boolean): void;
  37922. /**
  37923. * @override
  37924. * Override Camera.createRigCamera
  37925. */
  37926. createRigCamera(name: string, cameraIndex: number): Camera;
  37927. /**
  37928. * @hidden
  37929. * @override
  37930. * Override Camera._updateRigCameras
  37931. */
  37932. _updateRigCameras(): void;
  37933. /**
  37934. * Destroy the camera and release the current resources hold by it.
  37935. */
  37936. dispose(): void;
  37937. /**
  37938. * Gets the current object class name.
  37939. * @return the class name
  37940. */
  37941. getClassName(): string;
  37942. }
  37943. }
  37944. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37945. import { Behavior } from "babylonjs/Behaviors/behavior";
  37946. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37947. /**
  37948. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37950. */
  37951. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37952. /**
  37953. * Gets the name of the behavior.
  37954. */
  37955. readonly name: string;
  37956. private _zoomStopsAnimation;
  37957. private _idleRotationSpeed;
  37958. private _idleRotationWaitTime;
  37959. private _idleRotationSpinupTime;
  37960. /**
  37961. * Sets the flag that indicates if user zooming should stop animation.
  37962. */
  37963. /**
  37964. * Gets the flag that indicates if user zooming should stop animation.
  37965. */
  37966. zoomStopsAnimation: boolean;
  37967. /**
  37968. * Sets the default speed at which the camera rotates around the model.
  37969. */
  37970. /**
  37971. * Gets the default speed at which the camera rotates around the model.
  37972. */
  37973. idleRotationSpeed: number;
  37974. /**
  37975. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37976. */
  37977. /**
  37978. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37979. */
  37980. idleRotationWaitTime: number;
  37981. /**
  37982. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37983. */
  37984. /**
  37985. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37986. */
  37987. idleRotationSpinupTime: number;
  37988. /**
  37989. * Gets a value indicating if the camera is currently rotating because of this behavior
  37990. */
  37991. readonly rotationInProgress: boolean;
  37992. private _onPrePointerObservableObserver;
  37993. private _onAfterCheckInputsObserver;
  37994. private _attachedCamera;
  37995. private _isPointerDown;
  37996. private _lastFrameTime;
  37997. private _lastInteractionTime;
  37998. private _cameraRotationSpeed;
  37999. /**
  38000. * Initializes the behavior.
  38001. */
  38002. init(): void;
  38003. /**
  38004. * Attaches the behavior to its arc rotate camera.
  38005. * @param camera Defines the camera to attach the behavior to
  38006. */
  38007. attach(camera: ArcRotateCamera): void;
  38008. /**
  38009. * Detaches the behavior from its current arc rotate camera.
  38010. */
  38011. detach(): void;
  38012. /**
  38013. * Returns true if user is scrolling.
  38014. * @return true if user is scrolling.
  38015. */
  38016. private _userIsZooming;
  38017. private _lastFrameRadius;
  38018. private _shouldAnimationStopForInteraction;
  38019. /**
  38020. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38021. */
  38022. private _applyUserInteraction;
  38023. private _userIsMoving;
  38024. }
  38025. }
  38026. declare module "babylonjs/Behaviors/Cameras/index" {
  38027. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38028. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38029. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38030. }
  38031. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38032. import { Mesh } from "babylonjs/Meshes/mesh";
  38033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38034. import { Behavior } from "babylonjs/Behaviors/behavior";
  38035. /**
  38036. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38037. */
  38038. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38039. private ui;
  38040. /**
  38041. * The name of the behavior
  38042. */
  38043. name: string;
  38044. /**
  38045. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38046. */
  38047. distanceAwayFromFace: number;
  38048. /**
  38049. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38050. */
  38051. distanceAwayFromBottomOfFace: number;
  38052. private _faceVectors;
  38053. private _target;
  38054. private _scene;
  38055. private _onRenderObserver;
  38056. private _tmpMatrix;
  38057. private _tmpVector;
  38058. /**
  38059. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38060. * @param ui The transform node that should be attched to the mesh
  38061. */
  38062. constructor(ui: TransformNode);
  38063. /**
  38064. * Initializes the behavior
  38065. */
  38066. init(): void;
  38067. private _closestFace;
  38068. private _zeroVector;
  38069. private _lookAtTmpMatrix;
  38070. private _lookAtToRef;
  38071. /**
  38072. * Attaches the AttachToBoxBehavior to the passed in mesh
  38073. * @param target The mesh that the specified node will be attached to
  38074. */
  38075. attach(target: Mesh): void;
  38076. /**
  38077. * Detaches the behavior from the mesh
  38078. */
  38079. detach(): void;
  38080. }
  38081. }
  38082. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38083. import { Behavior } from "babylonjs/Behaviors/behavior";
  38084. import { Mesh } from "babylonjs/Meshes/mesh";
  38085. /**
  38086. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38087. */
  38088. export class FadeInOutBehavior implements Behavior<Mesh> {
  38089. /**
  38090. * Time in milliseconds to delay before fading in (Default: 0)
  38091. */
  38092. delay: number;
  38093. /**
  38094. * Time in milliseconds for the mesh to fade in (Default: 300)
  38095. */
  38096. fadeInTime: number;
  38097. private _millisecondsPerFrame;
  38098. private _hovered;
  38099. private _hoverValue;
  38100. private _ownerNode;
  38101. /**
  38102. * Instatiates the FadeInOutBehavior
  38103. */
  38104. constructor();
  38105. /**
  38106. * The name of the behavior
  38107. */
  38108. readonly name: string;
  38109. /**
  38110. * Initializes the behavior
  38111. */
  38112. init(): void;
  38113. /**
  38114. * Attaches the fade behavior on the passed in mesh
  38115. * @param ownerNode The mesh that will be faded in/out once attached
  38116. */
  38117. attach(ownerNode: Mesh): void;
  38118. /**
  38119. * Detaches the behavior from the mesh
  38120. */
  38121. detach(): void;
  38122. /**
  38123. * Triggers the mesh to begin fading in or out
  38124. * @param value if the object should fade in or out (true to fade in)
  38125. */
  38126. fadeIn(value: boolean): void;
  38127. private _update;
  38128. private _setAllVisibility;
  38129. }
  38130. }
  38131. declare module "babylonjs/Misc/pivotTools" {
  38132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38133. /**
  38134. * Class containing a set of static utilities functions for managing Pivots
  38135. * @hidden
  38136. */
  38137. export class PivotTools {
  38138. private static _PivotCached;
  38139. private static _OldPivotPoint;
  38140. private static _PivotTranslation;
  38141. private static _PivotTmpVector;
  38142. /** @hidden */
  38143. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38144. /** @hidden */
  38145. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38146. }
  38147. }
  38148. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38149. import { Scene } from "babylonjs/scene";
  38150. import { Vector4 } from "babylonjs/Maths/math.vector";
  38151. import { Mesh } from "babylonjs/Meshes/mesh";
  38152. import { Nullable } from "babylonjs/types";
  38153. import { Plane } from "babylonjs/Maths/math.plane";
  38154. /**
  38155. * Class containing static functions to help procedurally build meshes
  38156. */
  38157. export class PlaneBuilder {
  38158. /**
  38159. * Creates a plane mesh
  38160. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38161. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38162. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38166. * @param name defines the name of the mesh
  38167. * @param options defines the options used to create the mesh
  38168. * @param scene defines the hosting scene
  38169. * @returns the plane mesh
  38170. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38171. */
  38172. static CreatePlane(name: string, options: {
  38173. size?: number;
  38174. width?: number;
  38175. height?: number;
  38176. sideOrientation?: number;
  38177. frontUVs?: Vector4;
  38178. backUVs?: Vector4;
  38179. updatable?: boolean;
  38180. sourcePlane?: Plane;
  38181. }, scene?: Nullable<Scene>): Mesh;
  38182. }
  38183. }
  38184. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38185. import { Behavior } from "babylonjs/Behaviors/behavior";
  38186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38187. import { Observable } from "babylonjs/Misc/observable";
  38188. import { Vector3 } from "babylonjs/Maths/math.vector";
  38189. import { Ray } from "babylonjs/Culling/ray";
  38190. import "babylonjs/Meshes/Builders/planeBuilder";
  38191. /**
  38192. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38193. */
  38194. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38195. private static _AnyMouseID;
  38196. /**
  38197. * Abstract mesh the behavior is set on
  38198. */
  38199. attachedNode: AbstractMesh;
  38200. private _dragPlane;
  38201. private _scene;
  38202. private _pointerObserver;
  38203. private _beforeRenderObserver;
  38204. private static _planeScene;
  38205. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38206. /**
  38207. * 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)
  38208. */
  38209. maxDragAngle: number;
  38210. /**
  38211. * @hidden
  38212. */
  38213. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38214. /**
  38215. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38216. */
  38217. currentDraggingPointerID: number;
  38218. /**
  38219. * The last position where the pointer hit the drag plane in world space
  38220. */
  38221. lastDragPosition: Vector3;
  38222. /**
  38223. * If the behavior is currently in a dragging state
  38224. */
  38225. dragging: boolean;
  38226. /**
  38227. * 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)
  38228. */
  38229. dragDeltaRatio: number;
  38230. /**
  38231. * If the drag plane orientation should be updated during the dragging (Default: true)
  38232. */
  38233. updateDragPlane: boolean;
  38234. private _debugMode;
  38235. private _moving;
  38236. /**
  38237. * Fires each time the attached mesh is dragged with the pointer
  38238. * * delta between last drag position and current drag position in world space
  38239. * * dragDistance along the drag axis
  38240. * * dragPlaneNormal normal of the current drag plane used during the drag
  38241. * * dragPlanePoint in world space where the drag intersects the drag plane
  38242. */
  38243. onDragObservable: Observable<{
  38244. delta: Vector3;
  38245. dragPlanePoint: Vector3;
  38246. dragPlaneNormal: Vector3;
  38247. dragDistance: number;
  38248. pointerId: number;
  38249. }>;
  38250. /**
  38251. * Fires each time a drag begins (eg. mouse down on mesh)
  38252. */
  38253. onDragStartObservable: Observable<{
  38254. dragPlanePoint: Vector3;
  38255. pointerId: number;
  38256. }>;
  38257. /**
  38258. * Fires each time a drag ends (eg. mouse release after drag)
  38259. */
  38260. onDragEndObservable: Observable<{
  38261. dragPlanePoint: Vector3;
  38262. pointerId: number;
  38263. }>;
  38264. /**
  38265. * If the attached mesh should be moved when dragged
  38266. */
  38267. moveAttached: boolean;
  38268. /**
  38269. * If the drag behavior will react to drag events (Default: true)
  38270. */
  38271. enabled: boolean;
  38272. /**
  38273. * If pointer events should start and release the drag (Default: true)
  38274. */
  38275. startAndReleaseDragOnPointerEvents: boolean;
  38276. /**
  38277. * If camera controls should be detached during the drag
  38278. */
  38279. detachCameraControls: boolean;
  38280. /**
  38281. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38282. */
  38283. useObjectOrienationForDragging: boolean;
  38284. private _options;
  38285. /**
  38286. * Creates a pointer drag behavior that can be attached to a mesh
  38287. * @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)
  38288. */
  38289. constructor(options?: {
  38290. dragAxis?: Vector3;
  38291. dragPlaneNormal?: Vector3;
  38292. });
  38293. /**
  38294. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38295. */
  38296. validateDrag: (targetPosition: Vector3) => boolean;
  38297. /**
  38298. * The name of the behavior
  38299. */
  38300. readonly name: string;
  38301. /**
  38302. * Initializes the behavior
  38303. */
  38304. init(): void;
  38305. private _tmpVector;
  38306. private _alternatePickedPoint;
  38307. private _worldDragAxis;
  38308. private _targetPosition;
  38309. private _attachedElement;
  38310. /**
  38311. * Attaches the drag behavior the passed in mesh
  38312. * @param ownerNode The mesh that will be dragged around once attached
  38313. * @param predicate Predicate to use for pick filtering
  38314. */
  38315. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38316. /**
  38317. * Force relase the drag action by code.
  38318. */
  38319. releaseDrag(): void;
  38320. private _startDragRay;
  38321. private _lastPointerRay;
  38322. /**
  38323. * Simulates the start of a pointer drag event on the behavior
  38324. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38325. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38326. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38327. */
  38328. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38329. private _startDrag;
  38330. private _dragDelta;
  38331. private _moveDrag;
  38332. private _pickWithRayOnDragPlane;
  38333. private _pointA;
  38334. private _pointB;
  38335. private _pointC;
  38336. private _lineA;
  38337. private _lineB;
  38338. private _localAxis;
  38339. private _lookAt;
  38340. private _updateDragPlanePosition;
  38341. /**
  38342. * Detaches the behavior from the mesh
  38343. */
  38344. detach(): void;
  38345. }
  38346. }
  38347. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38348. import { Mesh } from "babylonjs/Meshes/mesh";
  38349. import { Behavior } from "babylonjs/Behaviors/behavior";
  38350. /**
  38351. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38352. */
  38353. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38354. private _dragBehaviorA;
  38355. private _dragBehaviorB;
  38356. private _startDistance;
  38357. private _initialScale;
  38358. private _targetScale;
  38359. private _ownerNode;
  38360. private _sceneRenderObserver;
  38361. /**
  38362. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38363. */
  38364. constructor();
  38365. /**
  38366. * The name of the behavior
  38367. */
  38368. readonly name: string;
  38369. /**
  38370. * Initializes the behavior
  38371. */
  38372. init(): void;
  38373. private _getCurrentDistance;
  38374. /**
  38375. * Attaches the scale behavior the passed in mesh
  38376. * @param ownerNode The mesh that will be scaled around once attached
  38377. */
  38378. attach(ownerNode: Mesh): void;
  38379. /**
  38380. * Detaches the behavior from the mesh
  38381. */
  38382. detach(): void;
  38383. }
  38384. }
  38385. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38386. import { Behavior } from "babylonjs/Behaviors/behavior";
  38387. import { Mesh } from "babylonjs/Meshes/mesh";
  38388. import { Observable } from "babylonjs/Misc/observable";
  38389. /**
  38390. * 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
  38391. */
  38392. export class SixDofDragBehavior implements Behavior<Mesh> {
  38393. private static _virtualScene;
  38394. private _ownerNode;
  38395. private _sceneRenderObserver;
  38396. private _scene;
  38397. private _targetPosition;
  38398. private _virtualOriginMesh;
  38399. private _virtualDragMesh;
  38400. private _pointerObserver;
  38401. private _moving;
  38402. private _startingOrientation;
  38403. /**
  38404. * 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)
  38405. */
  38406. private zDragFactor;
  38407. /**
  38408. * If the object should rotate to face the drag origin
  38409. */
  38410. rotateDraggedObject: boolean;
  38411. /**
  38412. * If the behavior is currently in a dragging state
  38413. */
  38414. dragging: boolean;
  38415. /**
  38416. * 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)
  38417. */
  38418. dragDeltaRatio: number;
  38419. /**
  38420. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38421. */
  38422. currentDraggingPointerID: number;
  38423. /**
  38424. * If camera controls should be detached during the drag
  38425. */
  38426. detachCameraControls: boolean;
  38427. /**
  38428. * Fires each time a drag starts
  38429. */
  38430. onDragStartObservable: Observable<{}>;
  38431. /**
  38432. * Fires each time a drag ends (eg. mouse release after drag)
  38433. */
  38434. onDragEndObservable: Observable<{}>;
  38435. /**
  38436. * 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
  38437. */
  38438. constructor();
  38439. /**
  38440. * The name of the behavior
  38441. */
  38442. readonly name: string;
  38443. /**
  38444. * Initializes the behavior
  38445. */
  38446. init(): void;
  38447. /**
  38448. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38449. */
  38450. private readonly _pointerCamera;
  38451. /**
  38452. * Attaches the scale behavior the passed in mesh
  38453. * @param ownerNode The mesh that will be scaled around once attached
  38454. */
  38455. attach(ownerNode: Mesh): void;
  38456. /**
  38457. * Detaches the behavior from the mesh
  38458. */
  38459. detach(): void;
  38460. }
  38461. }
  38462. declare module "babylonjs/Behaviors/Meshes/index" {
  38463. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38464. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38465. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38466. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38467. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38468. }
  38469. declare module "babylonjs/Behaviors/index" {
  38470. export * from "babylonjs/Behaviors/behavior";
  38471. export * from "babylonjs/Behaviors/Cameras/index";
  38472. export * from "babylonjs/Behaviors/Meshes/index";
  38473. }
  38474. declare module "babylonjs/Bones/boneIKController" {
  38475. import { Bone } from "babylonjs/Bones/bone";
  38476. import { Vector3 } from "babylonjs/Maths/math.vector";
  38477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38478. import { Nullable } from "babylonjs/types";
  38479. /**
  38480. * Class used to apply inverse kinematics to bones
  38481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38482. */
  38483. export class BoneIKController {
  38484. private static _tmpVecs;
  38485. private static _tmpQuat;
  38486. private static _tmpMats;
  38487. /**
  38488. * Gets or sets the target mesh
  38489. */
  38490. targetMesh: AbstractMesh;
  38491. /** Gets or sets the mesh used as pole */
  38492. poleTargetMesh: AbstractMesh;
  38493. /**
  38494. * Gets or sets the bone used as pole
  38495. */
  38496. poleTargetBone: Nullable<Bone>;
  38497. /**
  38498. * Gets or sets the target position
  38499. */
  38500. targetPosition: Vector3;
  38501. /**
  38502. * Gets or sets the pole target position
  38503. */
  38504. poleTargetPosition: Vector3;
  38505. /**
  38506. * Gets or sets the pole target local offset
  38507. */
  38508. poleTargetLocalOffset: Vector3;
  38509. /**
  38510. * Gets or sets the pole angle
  38511. */
  38512. poleAngle: number;
  38513. /**
  38514. * Gets or sets the mesh associated with the controller
  38515. */
  38516. mesh: AbstractMesh;
  38517. /**
  38518. * 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)
  38519. */
  38520. slerpAmount: number;
  38521. private _bone1Quat;
  38522. private _bone1Mat;
  38523. private _bone2Ang;
  38524. private _bone1;
  38525. private _bone2;
  38526. private _bone1Length;
  38527. private _bone2Length;
  38528. private _maxAngle;
  38529. private _maxReach;
  38530. private _rightHandedSystem;
  38531. private _bendAxis;
  38532. private _slerping;
  38533. private _adjustRoll;
  38534. /**
  38535. * Gets or sets maximum allowed angle
  38536. */
  38537. maxAngle: number;
  38538. /**
  38539. * Creates a new BoneIKController
  38540. * @param mesh defines the mesh to control
  38541. * @param bone defines the bone to control
  38542. * @param options defines options to set up the controller
  38543. */
  38544. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38545. targetMesh?: AbstractMesh;
  38546. poleTargetMesh?: AbstractMesh;
  38547. poleTargetBone?: Bone;
  38548. poleTargetLocalOffset?: Vector3;
  38549. poleAngle?: number;
  38550. bendAxis?: Vector3;
  38551. maxAngle?: number;
  38552. slerpAmount?: number;
  38553. });
  38554. private _setMaxAngle;
  38555. /**
  38556. * Force the controller to update the bones
  38557. */
  38558. update(): void;
  38559. }
  38560. }
  38561. declare module "babylonjs/Bones/boneLookController" {
  38562. import { Vector3 } from "babylonjs/Maths/math.vector";
  38563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38564. import { Bone } from "babylonjs/Bones/bone";
  38565. import { Space } from "babylonjs/Maths/math.axis";
  38566. /**
  38567. * Class used to make a bone look toward a point in space
  38568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38569. */
  38570. export class BoneLookController {
  38571. private static _tmpVecs;
  38572. private static _tmpQuat;
  38573. private static _tmpMats;
  38574. /**
  38575. * The target Vector3 that the bone will look at
  38576. */
  38577. target: Vector3;
  38578. /**
  38579. * The mesh that the bone is attached to
  38580. */
  38581. mesh: AbstractMesh;
  38582. /**
  38583. * The bone that will be looking to the target
  38584. */
  38585. bone: Bone;
  38586. /**
  38587. * The up axis of the coordinate system that is used when the bone is rotated
  38588. */
  38589. upAxis: Vector3;
  38590. /**
  38591. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38592. */
  38593. upAxisSpace: Space;
  38594. /**
  38595. * Used to make an adjustment to the yaw of the bone
  38596. */
  38597. adjustYaw: number;
  38598. /**
  38599. * Used to make an adjustment to the pitch of the bone
  38600. */
  38601. adjustPitch: number;
  38602. /**
  38603. * Used to make an adjustment to the roll of the bone
  38604. */
  38605. adjustRoll: number;
  38606. /**
  38607. * 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)
  38608. */
  38609. slerpAmount: number;
  38610. private _minYaw;
  38611. private _maxYaw;
  38612. private _minPitch;
  38613. private _maxPitch;
  38614. private _minYawSin;
  38615. private _minYawCos;
  38616. private _maxYawSin;
  38617. private _maxYawCos;
  38618. private _midYawConstraint;
  38619. private _minPitchTan;
  38620. private _maxPitchTan;
  38621. private _boneQuat;
  38622. private _slerping;
  38623. private _transformYawPitch;
  38624. private _transformYawPitchInv;
  38625. private _firstFrameSkipped;
  38626. private _yawRange;
  38627. private _fowardAxis;
  38628. /**
  38629. * Gets or sets the minimum yaw angle that the bone can look to
  38630. */
  38631. minYaw: number;
  38632. /**
  38633. * Gets or sets the maximum yaw angle that the bone can look to
  38634. */
  38635. maxYaw: number;
  38636. /**
  38637. * Gets or sets the minimum pitch angle that the bone can look to
  38638. */
  38639. minPitch: number;
  38640. /**
  38641. * Gets or sets the maximum pitch angle that the bone can look to
  38642. */
  38643. maxPitch: number;
  38644. /**
  38645. * Create a BoneLookController
  38646. * @param mesh the mesh that the bone belongs to
  38647. * @param bone the bone that will be looking to the target
  38648. * @param target the target Vector3 to look at
  38649. * @param options optional settings:
  38650. * * maxYaw: the maximum angle the bone will yaw to
  38651. * * minYaw: the minimum angle the bone will yaw to
  38652. * * maxPitch: the maximum angle the bone will pitch to
  38653. * * minPitch: the minimum angle the bone will yaw to
  38654. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38655. * * upAxis: the up axis of the coordinate system
  38656. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38657. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38658. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38659. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38660. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38661. * * adjustRoll: used to make an adjustment to the roll of the bone
  38662. **/
  38663. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38664. maxYaw?: number;
  38665. minYaw?: number;
  38666. maxPitch?: number;
  38667. minPitch?: number;
  38668. slerpAmount?: number;
  38669. upAxis?: Vector3;
  38670. upAxisSpace?: Space;
  38671. yawAxis?: Vector3;
  38672. pitchAxis?: Vector3;
  38673. adjustYaw?: number;
  38674. adjustPitch?: number;
  38675. adjustRoll?: number;
  38676. });
  38677. /**
  38678. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38679. */
  38680. update(): void;
  38681. private _getAngleDiff;
  38682. private _getAngleBetween;
  38683. private _isAngleBetween;
  38684. }
  38685. }
  38686. declare module "babylonjs/Bones/index" {
  38687. export * from "babylonjs/Bones/bone";
  38688. export * from "babylonjs/Bones/boneIKController";
  38689. export * from "babylonjs/Bones/boneLookController";
  38690. export * from "babylonjs/Bones/skeleton";
  38691. }
  38692. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38693. import { Nullable } from "babylonjs/types";
  38694. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38696. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38697. /**
  38698. * Manage the gamepad inputs to control an arc rotate camera.
  38699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38700. */
  38701. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38702. /**
  38703. * Defines the camera the input is attached to.
  38704. */
  38705. camera: ArcRotateCamera;
  38706. /**
  38707. * Defines the gamepad the input is gathering event from.
  38708. */
  38709. gamepad: Nullable<Gamepad>;
  38710. /**
  38711. * Defines the gamepad rotation sensiblity.
  38712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38713. */
  38714. gamepadRotationSensibility: number;
  38715. /**
  38716. * Defines the gamepad move sensiblity.
  38717. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38718. */
  38719. gamepadMoveSensibility: number;
  38720. private _yAxisScale;
  38721. /**
  38722. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38723. */
  38724. invertYAxis: boolean;
  38725. private _onGamepadConnectedObserver;
  38726. private _onGamepadDisconnectedObserver;
  38727. /**
  38728. * Attach the input controls to a specific dom element to get the input from.
  38729. * @param element Defines the element the controls should be listened from
  38730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38731. */
  38732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38733. /**
  38734. * Detach the current controls from the specified dom element.
  38735. * @param element Defines the element to stop listening the inputs from
  38736. */
  38737. detachControl(element: Nullable<HTMLElement>): void;
  38738. /**
  38739. * Update the current camera state depending on the inputs that have been used this frame.
  38740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38741. */
  38742. checkInputs(): void;
  38743. /**
  38744. * Gets the class name of the current intput.
  38745. * @returns the class name
  38746. */
  38747. getClassName(): string;
  38748. /**
  38749. * Get the friendly name associated with the input class.
  38750. * @returns the input friendly name
  38751. */
  38752. getSimpleName(): string;
  38753. }
  38754. }
  38755. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38756. import { Nullable } from "babylonjs/types";
  38757. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38759. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38760. interface ArcRotateCameraInputsManager {
  38761. /**
  38762. * Add orientation input support to the input manager.
  38763. * @returns the current input manager
  38764. */
  38765. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38766. }
  38767. }
  38768. /**
  38769. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38771. */
  38772. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38773. /**
  38774. * Defines the camera the input is attached to.
  38775. */
  38776. camera: ArcRotateCamera;
  38777. /**
  38778. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38779. */
  38780. alphaCorrection: number;
  38781. /**
  38782. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38783. */
  38784. gammaCorrection: number;
  38785. private _alpha;
  38786. private _gamma;
  38787. private _dirty;
  38788. private _deviceOrientationHandler;
  38789. /**
  38790. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38791. */
  38792. constructor();
  38793. /**
  38794. * Attach the input controls to a specific dom element to get the input from.
  38795. * @param element Defines the element the controls should be listened from
  38796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38797. */
  38798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38799. /** @hidden */
  38800. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38801. /**
  38802. * Update the current camera state depending on the inputs that have been used this frame.
  38803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38804. */
  38805. checkInputs(): void;
  38806. /**
  38807. * Detach the current controls from the specified dom element.
  38808. * @param element Defines the element to stop listening the inputs from
  38809. */
  38810. detachControl(element: Nullable<HTMLElement>): void;
  38811. /**
  38812. * Gets the class name of the current intput.
  38813. * @returns the class name
  38814. */
  38815. getClassName(): string;
  38816. /**
  38817. * Get the friendly name associated with the input class.
  38818. * @returns the input friendly name
  38819. */
  38820. getSimpleName(): string;
  38821. }
  38822. }
  38823. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38824. import { Nullable } from "babylonjs/types";
  38825. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38826. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38827. /**
  38828. * Listen to mouse events to control the camera.
  38829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38830. */
  38831. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38832. /**
  38833. * Defines the camera the input is attached to.
  38834. */
  38835. camera: FlyCamera;
  38836. /**
  38837. * Defines if touch is enabled. (Default is true.)
  38838. */
  38839. touchEnabled: boolean;
  38840. /**
  38841. * Defines the buttons associated with the input to handle camera rotation.
  38842. */
  38843. buttons: number[];
  38844. /**
  38845. * Assign buttons for Yaw control.
  38846. */
  38847. buttonsYaw: number[];
  38848. /**
  38849. * Assign buttons for Pitch control.
  38850. */
  38851. buttonsPitch: number[];
  38852. /**
  38853. * Assign buttons for Roll control.
  38854. */
  38855. buttonsRoll: number[];
  38856. /**
  38857. * Detect if any button is being pressed while mouse is moved.
  38858. * -1 = Mouse locked.
  38859. * 0 = Left button.
  38860. * 1 = Middle Button.
  38861. * 2 = Right Button.
  38862. */
  38863. activeButton: number;
  38864. /**
  38865. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38866. * Higher values reduce its sensitivity.
  38867. */
  38868. angularSensibility: number;
  38869. private _mousemoveCallback;
  38870. private _observer;
  38871. private _rollObserver;
  38872. private previousPosition;
  38873. private noPreventDefault;
  38874. private element;
  38875. /**
  38876. * Listen to mouse events to control the camera.
  38877. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38879. */
  38880. constructor(touchEnabled?: boolean);
  38881. /**
  38882. * Attach the mouse control to the HTML DOM element.
  38883. * @param element Defines the element that listens to the input events.
  38884. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38885. */
  38886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38887. /**
  38888. * Detach the current controls from the specified dom element.
  38889. * @param element Defines the element to stop listening the inputs from
  38890. */
  38891. detachControl(element: Nullable<HTMLElement>): void;
  38892. /**
  38893. * Gets the class name of the current input.
  38894. * @returns the class name.
  38895. */
  38896. getClassName(): string;
  38897. /**
  38898. * Get the friendly name associated with the input class.
  38899. * @returns the input's friendly name.
  38900. */
  38901. getSimpleName(): string;
  38902. private _pointerInput;
  38903. private _onMouseMove;
  38904. /**
  38905. * Rotate camera by mouse offset.
  38906. */
  38907. private rotateCamera;
  38908. }
  38909. }
  38910. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38911. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38912. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38913. /**
  38914. * Default Inputs manager for the FlyCamera.
  38915. * It groups all the default supported inputs for ease of use.
  38916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38917. */
  38918. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38919. /**
  38920. * Instantiates a new FlyCameraInputsManager.
  38921. * @param camera Defines the camera the inputs belong to.
  38922. */
  38923. constructor(camera: FlyCamera);
  38924. /**
  38925. * Add keyboard input support to the input manager.
  38926. * @returns the new FlyCameraKeyboardMoveInput().
  38927. */
  38928. addKeyboard(): FlyCameraInputsManager;
  38929. /**
  38930. * Add mouse input support to the input manager.
  38931. * @param touchEnabled Enable touch screen support.
  38932. * @returns the new FlyCameraMouseInput().
  38933. */
  38934. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38935. }
  38936. }
  38937. declare module "babylonjs/Cameras/flyCamera" {
  38938. import { Scene } from "babylonjs/scene";
  38939. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38941. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38942. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38943. /**
  38944. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38945. * such as in a 3D Space Shooter or a Flight Simulator.
  38946. */
  38947. export class FlyCamera extends TargetCamera {
  38948. /**
  38949. * Define the collision ellipsoid of the camera.
  38950. * This is helpful for simulating a camera body, like a player's body.
  38951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38952. */
  38953. ellipsoid: Vector3;
  38954. /**
  38955. * Define an offset for the position of the ellipsoid around the camera.
  38956. * This can be helpful if the camera is attached away from the player's body center,
  38957. * such as at its head.
  38958. */
  38959. ellipsoidOffset: Vector3;
  38960. /**
  38961. * Enable or disable collisions of the camera with the rest of the scene objects.
  38962. */
  38963. checkCollisions: boolean;
  38964. /**
  38965. * Enable or disable gravity on the camera.
  38966. */
  38967. applyGravity: boolean;
  38968. /**
  38969. * Define the current direction the camera is moving to.
  38970. */
  38971. cameraDirection: Vector3;
  38972. /**
  38973. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38974. * This overrides and empties cameraRotation.
  38975. */
  38976. rotationQuaternion: Quaternion;
  38977. /**
  38978. * Track Roll to maintain the wanted Rolling when looking around.
  38979. */
  38980. _trackRoll: number;
  38981. /**
  38982. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38983. */
  38984. rollCorrect: number;
  38985. /**
  38986. * Mimic a banked turn, Rolling the camera when Yawing.
  38987. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38988. */
  38989. bankedTurn: boolean;
  38990. /**
  38991. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38992. */
  38993. bankedTurnLimit: number;
  38994. /**
  38995. * Value of 0 disables the banked Roll.
  38996. * Value of 1 is equal to the Yaw angle in radians.
  38997. */
  38998. bankedTurnMultiplier: number;
  38999. /**
  39000. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39001. */
  39002. inputs: FlyCameraInputsManager;
  39003. /**
  39004. * Gets the input sensibility for mouse input.
  39005. * Higher values reduce sensitivity.
  39006. */
  39007. /**
  39008. * Sets the input sensibility for a mouse input.
  39009. * Higher values reduce sensitivity.
  39010. */
  39011. angularSensibility: number;
  39012. /**
  39013. * Get the keys for camera movement forward.
  39014. */
  39015. /**
  39016. * Set the keys for camera movement forward.
  39017. */
  39018. keysForward: number[];
  39019. /**
  39020. * Get the keys for camera movement backward.
  39021. */
  39022. keysBackward: number[];
  39023. /**
  39024. * Get the keys for camera movement up.
  39025. */
  39026. /**
  39027. * Set the keys for camera movement up.
  39028. */
  39029. keysUp: number[];
  39030. /**
  39031. * Get the keys for camera movement down.
  39032. */
  39033. /**
  39034. * Set the keys for camera movement down.
  39035. */
  39036. keysDown: number[];
  39037. /**
  39038. * Get the keys for camera movement left.
  39039. */
  39040. /**
  39041. * Set the keys for camera movement left.
  39042. */
  39043. keysLeft: number[];
  39044. /**
  39045. * Set the keys for camera movement right.
  39046. */
  39047. /**
  39048. * Set the keys for camera movement right.
  39049. */
  39050. keysRight: number[];
  39051. /**
  39052. * Event raised when the camera collides with a mesh in the scene.
  39053. */
  39054. onCollide: (collidedMesh: AbstractMesh) => void;
  39055. private _collider;
  39056. private _needMoveForGravity;
  39057. private _oldPosition;
  39058. private _diffPosition;
  39059. private _newPosition;
  39060. /** @hidden */
  39061. _localDirection: Vector3;
  39062. /** @hidden */
  39063. _transformedDirection: Vector3;
  39064. /**
  39065. * Instantiates a FlyCamera.
  39066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39067. * such as in a 3D Space Shooter or a Flight Simulator.
  39068. * @param name Define the name of the camera in the scene.
  39069. * @param position Define the starting position of the camera in the scene.
  39070. * @param scene Define the scene the camera belongs to.
  39071. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39072. */
  39073. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39074. /**
  39075. * Attach a control to the HTML DOM element.
  39076. * @param element Defines the element that listens to the input events.
  39077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39078. */
  39079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39080. /**
  39081. * Detach a control from the HTML DOM element.
  39082. * The camera will stop reacting to that input.
  39083. * @param element Defines the element that listens to the input events.
  39084. */
  39085. detachControl(element: HTMLElement): void;
  39086. private _collisionMask;
  39087. /**
  39088. * Get the mask that the camera ignores in collision events.
  39089. */
  39090. /**
  39091. * Set the mask that the camera ignores in collision events.
  39092. */
  39093. collisionMask: number;
  39094. /** @hidden */
  39095. _collideWithWorld(displacement: Vector3): void;
  39096. /** @hidden */
  39097. private _onCollisionPositionChange;
  39098. /** @hidden */
  39099. _checkInputs(): void;
  39100. /** @hidden */
  39101. _decideIfNeedsToMove(): boolean;
  39102. /** @hidden */
  39103. _updatePosition(): void;
  39104. /**
  39105. * Restore the Roll to its target value at the rate specified.
  39106. * @param rate - Higher means slower restoring.
  39107. * @hidden
  39108. */
  39109. restoreRoll(rate: number): void;
  39110. /**
  39111. * Destroy the camera and release the current resources held by it.
  39112. */
  39113. dispose(): void;
  39114. /**
  39115. * Get the current object class name.
  39116. * @returns the class name.
  39117. */
  39118. getClassName(): string;
  39119. }
  39120. }
  39121. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39122. import { Nullable } from "babylonjs/types";
  39123. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39124. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39125. /**
  39126. * Listen to keyboard events to control the camera.
  39127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39128. */
  39129. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39130. /**
  39131. * Defines the camera the input is attached to.
  39132. */
  39133. camera: FlyCamera;
  39134. /**
  39135. * The list of keyboard keys used to control the forward move of the camera.
  39136. */
  39137. keysForward: number[];
  39138. /**
  39139. * The list of keyboard keys used to control the backward move of the camera.
  39140. */
  39141. keysBackward: number[];
  39142. /**
  39143. * The list of keyboard keys used to control the forward move of the camera.
  39144. */
  39145. keysUp: number[];
  39146. /**
  39147. * The list of keyboard keys used to control the backward move of the camera.
  39148. */
  39149. keysDown: number[];
  39150. /**
  39151. * The list of keyboard keys used to control the right strafe move of the camera.
  39152. */
  39153. keysRight: number[];
  39154. /**
  39155. * The list of keyboard keys used to control the left strafe move of the camera.
  39156. */
  39157. keysLeft: number[];
  39158. private _keys;
  39159. private _onCanvasBlurObserver;
  39160. private _onKeyboardObserver;
  39161. private _engine;
  39162. private _scene;
  39163. /**
  39164. * Attach the input controls to a specific dom element to get the input from.
  39165. * @param element Defines the element the controls should be listened from
  39166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39167. */
  39168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39169. /**
  39170. * Detach the current controls from the specified dom element.
  39171. * @param element Defines the element to stop listening the inputs from
  39172. */
  39173. detachControl(element: Nullable<HTMLElement>): void;
  39174. /**
  39175. * Gets the class name of the current intput.
  39176. * @returns the class name
  39177. */
  39178. getClassName(): string;
  39179. /** @hidden */
  39180. _onLostFocus(e: FocusEvent): void;
  39181. /**
  39182. * Get the friendly name associated with the input class.
  39183. * @returns the input friendly name
  39184. */
  39185. getSimpleName(): string;
  39186. /**
  39187. * Update the current camera state depending on the inputs that have been used this frame.
  39188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39189. */
  39190. checkInputs(): void;
  39191. }
  39192. }
  39193. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39194. import { Nullable } from "babylonjs/types";
  39195. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39196. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39197. /**
  39198. * Manage the mouse wheel inputs to control a follow camera.
  39199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39200. */
  39201. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39202. /**
  39203. * Defines the camera the input is attached to.
  39204. */
  39205. camera: FollowCamera;
  39206. /**
  39207. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39208. */
  39209. axisControlRadius: boolean;
  39210. /**
  39211. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39212. */
  39213. axisControlHeight: boolean;
  39214. /**
  39215. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39216. */
  39217. axisControlRotation: boolean;
  39218. /**
  39219. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39220. * relation to mouseWheel events.
  39221. */
  39222. wheelPrecision: number;
  39223. /**
  39224. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39225. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39226. */
  39227. wheelDeltaPercentage: number;
  39228. private _wheel;
  39229. private _observer;
  39230. /**
  39231. * Attach the input controls to a specific dom element to get the input from.
  39232. * @param element Defines the element the controls should be listened from
  39233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39234. */
  39235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39236. /**
  39237. * Detach the current controls from the specified dom element.
  39238. * @param element Defines the element to stop listening the inputs from
  39239. */
  39240. detachControl(element: Nullable<HTMLElement>): void;
  39241. /**
  39242. * Gets the class name of the current intput.
  39243. * @returns the class name
  39244. */
  39245. getClassName(): string;
  39246. /**
  39247. * Get the friendly name associated with the input class.
  39248. * @returns the input friendly name
  39249. */
  39250. getSimpleName(): string;
  39251. }
  39252. }
  39253. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39254. import { Nullable } from "babylonjs/types";
  39255. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39256. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39257. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39258. /**
  39259. * Manage the pointers inputs to control an follow camera.
  39260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39261. */
  39262. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39263. /**
  39264. * Defines the camera the input is attached to.
  39265. */
  39266. camera: FollowCamera;
  39267. /**
  39268. * Gets the class name of the current input.
  39269. * @returns the class name
  39270. */
  39271. getClassName(): string;
  39272. /**
  39273. * Defines the pointer angular sensibility along the X axis or how fast is
  39274. * the camera rotating.
  39275. * A negative number will reverse the axis direction.
  39276. */
  39277. angularSensibilityX: number;
  39278. /**
  39279. * Defines the pointer angular sensibility along the Y axis or how fast is
  39280. * the camera rotating.
  39281. * A negative number will reverse the axis direction.
  39282. */
  39283. angularSensibilityY: number;
  39284. /**
  39285. * Defines the pointer pinch precision or how fast is the camera zooming.
  39286. * A negative number will reverse the axis direction.
  39287. */
  39288. pinchPrecision: number;
  39289. /**
  39290. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39291. * from 0.
  39292. * It defines the percentage of current camera.radius to use as delta when
  39293. * pinch zoom is used.
  39294. */
  39295. pinchDeltaPercentage: number;
  39296. /**
  39297. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39298. */
  39299. axisXControlRadius: boolean;
  39300. /**
  39301. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39302. */
  39303. axisXControlHeight: boolean;
  39304. /**
  39305. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39306. */
  39307. axisXControlRotation: boolean;
  39308. /**
  39309. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39310. */
  39311. axisYControlRadius: boolean;
  39312. /**
  39313. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39314. */
  39315. axisYControlHeight: boolean;
  39316. /**
  39317. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39318. */
  39319. axisYControlRotation: boolean;
  39320. /**
  39321. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39322. */
  39323. axisPinchControlRadius: boolean;
  39324. /**
  39325. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39326. */
  39327. axisPinchControlHeight: boolean;
  39328. /**
  39329. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39330. */
  39331. axisPinchControlRotation: boolean;
  39332. /**
  39333. * Log error messages if basic misconfiguration has occurred.
  39334. */
  39335. warningEnable: boolean;
  39336. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39337. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39338. private _warningCounter;
  39339. private _warning;
  39340. }
  39341. }
  39342. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39343. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39344. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39345. /**
  39346. * Default Inputs manager for the FollowCamera.
  39347. * It groups all the default supported inputs for ease of use.
  39348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39349. */
  39350. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39351. /**
  39352. * Instantiates a new FollowCameraInputsManager.
  39353. * @param camera Defines the camera the inputs belong to
  39354. */
  39355. constructor(camera: FollowCamera);
  39356. /**
  39357. * Add keyboard input support to the input manager.
  39358. * @returns the current input manager
  39359. */
  39360. addKeyboard(): FollowCameraInputsManager;
  39361. /**
  39362. * Add mouse wheel input support to the input manager.
  39363. * @returns the current input manager
  39364. */
  39365. addMouseWheel(): FollowCameraInputsManager;
  39366. /**
  39367. * Add pointers input support to the input manager.
  39368. * @returns the current input manager
  39369. */
  39370. addPointers(): FollowCameraInputsManager;
  39371. /**
  39372. * Add orientation input support to the input manager.
  39373. * @returns the current input manager
  39374. */
  39375. addVRDeviceOrientation(): FollowCameraInputsManager;
  39376. }
  39377. }
  39378. declare module "babylonjs/Cameras/followCamera" {
  39379. import { Nullable } from "babylonjs/types";
  39380. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39381. import { Scene } from "babylonjs/scene";
  39382. import { Vector3 } from "babylonjs/Maths/math.vector";
  39383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39384. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39385. /**
  39386. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39387. * an arc rotate version arcFollowCamera are available.
  39388. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39389. */
  39390. export class FollowCamera extends TargetCamera {
  39391. /**
  39392. * Distance the follow camera should follow an object at
  39393. */
  39394. radius: number;
  39395. /**
  39396. * Minimum allowed distance of the camera to the axis of rotation
  39397. * (The camera can not get closer).
  39398. * This can help limiting how the Camera is able to move in the scene.
  39399. */
  39400. lowerRadiusLimit: Nullable<number>;
  39401. /**
  39402. * Maximum allowed distance of the camera to the axis of rotation
  39403. * (The camera can not get further).
  39404. * This can help limiting how the Camera is able to move in the scene.
  39405. */
  39406. upperRadiusLimit: Nullable<number>;
  39407. /**
  39408. * Define a rotation offset between the camera and the object it follows
  39409. */
  39410. rotationOffset: number;
  39411. /**
  39412. * Minimum allowed angle to camera position relative to target object.
  39413. * This can help limiting how the Camera is able to move in the scene.
  39414. */
  39415. lowerRotationOffsetLimit: Nullable<number>;
  39416. /**
  39417. * Maximum allowed angle to camera position relative to target object.
  39418. * This can help limiting how the Camera is able to move in the scene.
  39419. */
  39420. upperRotationOffsetLimit: Nullable<number>;
  39421. /**
  39422. * Define a height offset between the camera and the object it follows.
  39423. * It can help following an object from the top (like a car chaing a plane)
  39424. */
  39425. heightOffset: number;
  39426. /**
  39427. * Minimum allowed height of camera position relative to target object.
  39428. * This can help limiting how the Camera is able to move in the scene.
  39429. */
  39430. lowerHeightOffsetLimit: Nullable<number>;
  39431. /**
  39432. * Maximum allowed height of camera position relative to target object.
  39433. * This can help limiting how the Camera is able to move in the scene.
  39434. */
  39435. upperHeightOffsetLimit: Nullable<number>;
  39436. /**
  39437. * Define how fast the camera can accelerate to follow it s target.
  39438. */
  39439. cameraAcceleration: number;
  39440. /**
  39441. * Define the speed limit of the camera following an object.
  39442. */
  39443. maxCameraSpeed: number;
  39444. /**
  39445. * Define the target of the camera.
  39446. */
  39447. lockedTarget: Nullable<AbstractMesh>;
  39448. /**
  39449. * Defines the input associated with the camera.
  39450. */
  39451. inputs: FollowCameraInputsManager;
  39452. /**
  39453. * Instantiates the follow camera.
  39454. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39455. * @param name Define the name of the camera in the scene
  39456. * @param position Define the position of the camera
  39457. * @param scene Define the scene the camera belong to
  39458. * @param lockedTarget Define the target of the camera
  39459. */
  39460. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39461. private _follow;
  39462. /**
  39463. * Attached controls to the current camera.
  39464. * @param element Defines the element the controls should be listened from
  39465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39466. */
  39467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39468. /**
  39469. * Detach the current controls from the camera.
  39470. * The camera will stop reacting to inputs.
  39471. * @param element Defines the element to stop listening the inputs from
  39472. */
  39473. detachControl(element: HTMLElement): void;
  39474. /** @hidden */
  39475. _checkInputs(): void;
  39476. private _checkLimits;
  39477. /**
  39478. * Gets the camera class name.
  39479. * @returns the class name
  39480. */
  39481. getClassName(): string;
  39482. }
  39483. /**
  39484. * Arc Rotate version of the follow camera.
  39485. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39486. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39487. */
  39488. export class ArcFollowCamera extends TargetCamera {
  39489. /** The longitudinal angle of the camera */
  39490. alpha: number;
  39491. /** The latitudinal angle of the camera */
  39492. beta: number;
  39493. /** The radius of the camera from its target */
  39494. radius: number;
  39495. /** Define the camera target (the messh it should follow) */
  39496. target: Nullable<AbstractMesh>;
  39497. private _cartesianCoordinates;
  39498. /**
  39499. * Instantiates a new ArcFollowCamera
  39500. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39501. * @param name Define the name of the camera
  39502. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39503. * @param beta Define the rotation angle of the camera around the elevation axis
  39504. * @param radius Define the radius of the camera from its target point
  39505. * @param target Define the target of the camera
  39506. * @param scene Define the scene the camera belongs to
  39507. */
  39508. constructor(name: string,
  39509. /** The longitudinal angle of the camera */
  39510. alpha: number,
  39511. /** The latitudinal angle of the camera */
  39512. beta: number,
  39513. /** The radius of the camera from its target */
  39514. radius: number,
  39515. /** Define the camera target (the messh it should follow) */
  39516. target: Nullable<AbstractMesh>, scene: Scene);
  39517. private _follow;
  39518. /** @hidden */
  39519. _checkInputs(): void;
  39520. /**
  39521. * Returns the class name of the object.
  39522. * It is mostly used internally for serialization purposes.
  39523. */
  39524. getClassName(): string;
  39525. }
  39526. }
  39527. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39528. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39529. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39530. import { Nullable } from "babylonjs/types";
  39531. /**
  39532. * Manage the keyboard inputs to control the movement of a follow camera.
  39533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39534. */
  39535. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39536. /**
  39537. * Defines the camera the input is attached to.
  39538. */
  39539. camera: FollowCamera;
  39540. /**
  39541. * Defines the list of key codes associated with the up action (increase heightOffset)
  39542. */
  39543. keysHeightOffsetIncr: number[];
  39544. /**
  39545. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39546. */
  39547. keysHeightOffsetDecr: number[];
  39548. /**
  39549. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39550. */
  39551. keysHeightOffsetModifierAlt: boolean;
  39552. /**
  39553. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39554. */
  39555. keysHeightOffsetModifierCtrl: boolean;
  39556. /**
  39557. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39558. */
  39559. keysHeightOffsetModifierShift: boolean;
  39560. /**
  39561. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39562. */
  39563. keysRotationOffsetIncr: number[];
  39564. /**
  39565. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39566. */
  39567. keysRotationOffsetDecr: number[];
  39568. /**
  39569. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39570. */
  39571. keysRotationOffsetModifierAlt: boolean;
  39572. /**
  39573. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39574. */
  39575. keysRotationOffsetModifierCtrl: boolean;
  39576. /**
  39577. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39578. */
  39579. keysRotationOffsetModifierShift: boolean;
  39580. /**
  39581. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39582. */
  39583. keysRadiusIncr: number[];
  39584. /**
  39585. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39586. */
  39587. keysRadiusDecr: number[];
  39588. /**
  39589. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39590. */
  39591. keysRadiusModifierAlt: boolean;
  39592. /**
  39593. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39594. */
  39595. keysRadiusModifierCtrl: boolean;
  39596. /**
  39597. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39598. */
  39599. keysRadiusModifierShift: boolean;
  39600. /**
  39601. * Defines the rate of change of heightOffset.
  39602. */
  39603. heightSensibility: number;
  39604. /**
  39605. * Defines the rate of change of rotationOffset.
  39606. */
  39607. rotationSensibility: number;
  39608. /**
  39609. * Defines the rate of change of radius.
  39610. */
  39611. radiusSensibility: number;
  39612. private _keys;
  39613. private _ctrlPressed;
  39614. private _altPressed;
  39615. private _shiftPressed;
  39616. private _onCanvasBlurObserver;
  39617. private _onKeyboardObserver;
  39618. private _engine;
  39619. private _scene;
  39620. /**
  39621. * Attach the input controls to a specific dom element to get the input from.
  39622. * @param element Defines the element the controls should be listened from
  39623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39624. */
  39625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39626. /**
  39627. * Detach the current controls from the specified dom element.
  39628. * @param element Defines the element to stop listening the inputs from
  39629. */
  39630. detachControl(element: Nullable<HTMLElement>): void;
  39631. /**
  39632. * Update the current camera state depending on the inputs that have been used this frame.
  39633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39634. */
  39635. checkInputs(): void;
  39636. /**
  39637. * Gets the class name of the current input.
  39638. * @returns the class name
  39639. */
  39640. getClassName(): string;
  39641. /**
  39642. * Get the friendly name associated with the input class.
  39643. * @returns the input friendly name
  39644. */
  39645. getSimpleName(): string;
  39646. /**
  39647. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39648. * allow modification of the heightOffset value.
  39649. */
  39650. private _modifierHeightOffset;
  39651. /**
  39652. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39653. * allow modification of the rotationOffset value.
  39654. */
  39655. private _modifierRotationOffset;
  39656. /**
  39657. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39658. * allow modification of the radius value.
  39659. */
  39660. private _modifierRadius;
  39661. }
  39662. }
  39663. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39664. import { Nullable } from "babylonjs/types";
  39665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39667. import { Observable } from "babylonjs/Misc/observable";
  39668. module "babylonjs/Cameras/freeCameraInputsManager" {
  39669. interface FreeCameraInputsManager {
  39670. /**
  39671. * @hidden
  39672. */
  39673. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39674. /**
  39675. * Add orientation input support to the input manager.
  39676. * @returns the current input manager
  39677. */
  39678. addDeviceOrientation(): FreeCameraInputsManager;
  39679. }
  39680. }
  39681. /**
  39682. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39683. * Screen rotation is taken into account.
  39684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39685. */
  39686. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39687. private _camera;
  39688. private _screenOrientationAngle;
  39689. private _constantTranform;
  39690. private _screenQuaternion;
  39691. private _alpha;
  39692. private _beta;
  39693. private _gamma;
  39694. /**
  39695. * Can be used to detect if a device orientation sensor is availible on a device
  39696. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39697. * @returns a promise that will resolve on orientation change
  39698. */
  39699. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39700. /**
  39701. * @hidden
  39702. */
  39703. _onDeviceOrientationChangedObservable: Observable<void>;
  39704. /**
  39705. * Instantiates a new input
  39706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39707. */
  39708. constructor();
  39709. /**
  39710. * Define the camera controlled by the input.
  39711. */
  39712. camera: FreeCamera;
  39713. /**
  39714. * Attach the input controls to a specific dom element to get the input from.
  39715. * @param element Defines the element the controls should be listened from
  39716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39717. */
  39718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39719. private _orientationChanged;
  39720. private _deviceOrientation;
  39721. /**
  39722. * Detach the current controls from the specified dom element.
  39723. * @param element Defines the element to stop listening the inputs from
  39724. */
  39725. detachControl(element: Nullable<HTMLElement>): void;
  39726. /**
  39727. * Update the current camera state depending on the inputs that have been used this frame.
  39728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39729. */
  39730. checkInputs(): void;
  39731. /**
  39732. * Gets the class name of the current intput.
  39733. * @returns the class name
  39734. */
  39735. getClassName(): string;
  39736. /**
  39737. * Get the friendly name associated with the input class.
  39738. * @returns the input friendly name
  39739. */
  39740. getSimpleName(): string;
  39741. }
  39742. }
  39743. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39744. import { Nullable } from "babylonjs/types";
  39745. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39746. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39747. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39748. /**
  39749. * Manage the gamepad inputs to control a free camera.
  39750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39751. */
  39752. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39753. /**
  39754. * Define the camera the input is attached to.
  39755. */
  39756. camera: FreeCamera;
  39757. /**
  39758. * Define the Gamepad controlling the input
  39759. */
  39760. gamepad: Nullable<Gamepad>;
  39761. /**
  39762. * Defines the gamepad rotation sensiblity.
  39763. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39764. */
  39765. gamepadAngularSensibility: number;
  39766. /**
  39767. * Defines the gamepad move sensiblity.
  39768. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39769. */
  39770. gamepadMoveSensibility: number;
  39771. private _yAxisScale;
  39772. /**
  39773. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39774. */
  39775. invertYAxis: boolean;
  39776. private _onGamepadConnectedObserver;
  39777. private _onGamepadDisconnectedObserver;
  39778. private _cameraTransform;
  39779. private _deltaTransform;
  39780. private _vector3;
  39781. private _vector2;
  39782. /**
  39783. * Attach the input controls to a specific dom element to get the input from.
  39784. * @param element Defines the element the controls should be listened from
  39785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39786. */
  39787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39788. /**
  39789. * Detach the current controls from the specified dom element.
  39790. * @param element Defines the element to stop listening the inputs from
  39791. */
  39792. detachControl(element: Nullable<HTMLElement>): void;
  39793. /**
  39794. * Update the current camera state depending on the inputs that have been used this frame.
  39795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39796. */
  39797. checkInputs(): void;
  39798. /**
  39799. * Gets the class name of the current intput.
  39800. * @returns the class name
  39801. */
  39802. getClassName(): string;
  39803. /**
  39804. * Get the friendly name associated with the input class.
  39805. * @returns the input friendly name
  39806. */
  39807. getSimpleName(): string;
  39808. }
  39809. }
  39810. declare module "babylonjs/Misc/virtualJoystick" {
  39811. import { Nullable } from "babylonjs/types";
  39812. import { Vector3 } from "babylonjs/Maths/math.vector";
  39813. /**
  39814. * Defines the potential axis of a Joystick
  39815. */
  39816. export enum JoystickAxis {
  39817. /** X axis */
  39818. X = 0,
  39819. /** Y axis */
  39820. Y = 1,
  39821. /** Z axis */
  39822. Z = 2
  39823. }
  39824. /**
  39825. * Class used to define virtual joystick (used in touch mode)
  39826. */
  39827. export class VirtualJoystick {
  39828. /**
  39829. * Gets or sets a boolean indicating that left and right values must be inverted
  39830. */
  39831. reverseLeftRight: boolean;
  39832. /**
  39833. * Gets or sets a boolean indicating that up and down values must be inverted
  39834. */
  39835. reverseUpDown: boolean;
  39836. /**
  39837. * Gets the offset value for the position (ie. the change of the position value)
  39838. */
  39839. deltaPosition: Vector3;
  39840. /**
  39841. * Gets a boolean indicating if the virtual joystick was pressed
  39842. */
  39843. pressed: boolean;
  39844. /**
  39845. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39846. */
  39847. static Canvas: Nullable<HTMLCanvasElement>;
  39848. private static _globalJoystickIndex;
  39849. private static vjCanvasContext;
  39850. private static vjCanvasWidth;
  39851. private static vjCanvasHeight;
  39852. private static halfWidth;
  39853. private _action;
  39854. private _axisTargetedByLeftAndRight;
  39855. private _axisTargetedByUpAndDown;
  39856. private _joystickSensibility;
  39857. private _inversedSensibility;
  39858. private _joystickPointerID;
  39859. private _joystickColor;
  39860. private _joystickPointerPos;
  39861. private _joystickPreviousPointerPos;
  39862. private _joystickPointerStartPos;
  39863. private _deltaJoystickVector;
  39864. private _leftJoystick;
  39865. private _touches;
  39866. private _onPointerDownHandlerRef;
  39867. private _onPointerMoveHandlerRef;
  39868. private _onPointerUpHandlerRef;
  39869. private _onResize;
  39870. /**
  39871. * Creates a new virtual joystick
  39872. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39873. */
  39874. constructor(leftJoystick?: boolean);
  39875. /**
  39876. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39877. * @param newJoystickSensibility defines the new sensibility
  39878. */
  39879. setJoystickSensibility(newJoystickSensibility: number): void;
  39880. private _onPointerDown;
  39881. private _onPointerMove;
  39882. private _onPointerUp;
  39883. /**
  39884. * Change the color of the virtual joystick
  39885. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39886. */
  39887. setJoystickColor(newColor: string): void;
  39888. /**
  39889. * Defines a callback to call when the joystick is touched
  39890. * @param action defines the callback
  39891. */
  39892. setActionOnTouch(action: () => any): void;
  39893. /**
  39894. * Defines which axis you'd like to control for left & right
  39895. * @param axis defines the axis to use
  39896. */
  39897. setAxisForLeftRight(axis: JoystickAxis): void;
  39898. /**
  39899. * Defines which axis you'd like to control for up & down
  39900. * @param axis defines the axis to use
  39901. */
  39902. setAxisForUpDown(axis: JoystickAxis): void;
  39903. private _drawVirtualJoystick;
  39904. /**
  39905. * Release internal HTML canvas
  39906. */
  39907. releaseCanvas(): void;
  39908. }
  39909. }
  39910. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39911. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39912. import { Nullable } from "babylonjs/types";
  39913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39914. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39915. module "babylonjs/Cameras/freeCameraInputsManager" {
  39916. interface FreeCameraInputsManager {
  39917. /**
  39918. * Add virtual joystick input support to the input manager.
  39919. * @returns the current input manager
  39920. */
  39921. addVirtualJoystick(): FreeCameraInputsManager;
  39922. }
  39923. }
  39924. /**
  39925. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39927. */
  39928. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39929. /**
  39930. * Defines the camera the input is attached to.
  39931. */
  39932. camera: FreeCamera;
  39933. private _leftjoystick;
  39934. private _rightjoystick;
  39935. /**
  39936. * Gets the left stick of the virtual joystick.
  39937. * @returns The virtual Joystick
  39938. */
  39939. getLeftJoystick(): VirtualJoystick;
  39940. /**
  39941. * Gets the right stick of the virtual joystick.
  39942. * @returns The virtual Joystick
  39943. */
  39944. getRightJoystick(): VirtualJoystick;
  39945. /**
  39946. * Update the current camera state depending on the inputs that have been used this frame.
  39947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39948. */
  39949. checkInputs(): void;
  39950. /**
  39951. * Attach the input controls to a specific dom element to get the input from.
  39952. * @param element Defines the element the controls should be listened from
  39953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39954. */
  39955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39956. /**
  39957. * Detach the current controls from the specified dom element.
  39958. * @param element Defines the element to stop listening the inputs from
  39959. */
  39960. detachControl(element: Nullable<HTMLElement>): void;
  39961. /**
  39962. * Gets the class name of the current intput.
  39963. * @returns the class name
  39964. */
  39965. getClassName(): string;
  39966. /**
  39967. * Get the friendly name associated with the input class.
  39968. * @returns the input friendly name
  39969. */
  39970. getSimpleName(): string;
  39971. }
  39972. }
  39973. declare module "babylonjs/Cameras/Inputs/index" {
  39974. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39975. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39976. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39977. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39978. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39979. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39980. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39981. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39982. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39983. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39984. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39985. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39986. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39987. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39988. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39989. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39990. }
  39991. declare module "babylonjs/Cameras/touchCamera" {
  39992. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39993. import { Scene } from "babylonjs/scene";
  39994. import { Vector3 } from "babylonjs/Maths/math.vector";
  39995. /**
  39996. * This represents a FPS type of camera controlled by touch.
  39997. * This is like a universal camera minus the Gamepad controls.
  39998. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39999. */
  40000. export class TouchCamera extends FreeCamera {
  40001. /**
  40002. * Defines the touch sensibility for rotation.
  40003. * The higher the faster.
  40004. */
  40005. touchAngularSensibility: number;
  40006. /**
  40007. * Defines the touch sensibility for move.
  40008. * The higher the faster.
  40009. */
  40010. touchMoveSensibility: number;
  40011. /**
  40012. * Instantiates a new touch camera.
  40013. * This represents a FPS type of camera controlled by touch.
  40014. * This is like a universal camera minus the Gamepad controls.
  40015. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40016. * @param name Define the name of the camera in the scene
  40017. * @param position Define the start position of the camera in the scene
  40018. * @param scene Define the scene the camera belongs to
  40019. */
  40020. constructor(name: string, position: Vector3, scene: Scene);
  40021. /**
  40022. * Gets the current object class name.
  40023. * @return the class name
  40024. */
  40025. getClassName(): string;
  40026. /** @hidden */
  40027. _setupInputs(): void;
  40028. }
  40029. }
  40030. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40032. import { Scene } from "babylonjs/scene";
  40033. import { Vector3 } from "babylonjs/Maths/math.vector";
  40034. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40035. import { Axis } from "babylonjs/Maths/math.axis";
  40036. /**
  40037. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40038. * being tilted forward or back and left or right.
  40039. */
  40040. export class DeviceOrientationCamera extends FreeCamera {
  40041. private _initialQuaternion;
  40042. private _quaternionCache;
  40043. private _tmpDragQuaternion;
  40044. private _disablePointerInputWhenUsingDeviceOrientation;
  40045. /**
  40046. * Creates a new device orientation camera
  40047. * @param name The name of the camera
  40048. * @param position The start position camera
  40049. * @param scene The scene the camera belongs to
  40050. */
  40051. constructor(name: string, position: Vector3, scene: Scene);
  40052. /**
  40053. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40054. */
  40055. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40056. private _dragFactor;
  40057. /**
  40058. * Enabled turning on the y axis when the orientation sensor is active
  40059. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40060. */
  40061. enableHorizontalDragging(dragFactor?: number): void;
  40062. /**
  40063. * Gets the current instance class name ("DeviceOrientationCamera").
  40064. * This helps avoiding instanceof at run time.
  40065. * @returns the class name
  40066. */
  40067. getClassName(): string;
  40068. /**
  40069. * @hidden
  40070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40071. */
  40072. _checkInputs(): void;
  40073. /**
  40074. * Reset the camera to its default orientation on the specified axis only.
  40075. * @param axis The axis to reset
  40076. */
  40077. resetToCurrentRotation(axis?: Axis): void;
  40078. }
  40079. }
  40080. declare module "babylonjs/Gamepads/xboxGamepad" {
  40081. import { Observable } from "babylonjs/Misc/observable";
  40082. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40083. /**
  40084. * Defines supported buttons for XBox360 compatible gamepads
  40085. */
  40086. export enum Xbox360Button {
  40087. /** A */
  40088. A = 0,
  40089. /** B */
  40090. B = 1,
  40091. /** X */
  40092. X = 2,
  40093. /** Y */
  40094. Y = 3,
  40095. /** Start */
  40096. Start = 4,
  40097. /** Back */
  40098. Back = 5,
  40099. /** Left button */
  40100. LB = 6,
  40101. /** Right button */
  40102. RB = 7,
  40103. /** Left stick */
  40104. LeftStick = 8,
  40105. /** Right stick */
  40106. RightStick = 9
  40107. }
  40108. /** Defines values for XBox360 DPad */
  40109. export enum Xbox360Dpad {
  40110. /** Up */
  40111. Up = 0,
  40112. /** Down */
  40113. Down = 1,
  40114. /** Left */
  40115. Left = 2,
  40116. /** Right */
  40117. Right = 3
  40118. }
  40119. /**
  40120. * Defines a XBox360 gamepad
  40121. */
  40122. export class Xbox360Pad extends Gamepad {
  40123. private _leftTrigger;
  40124. private _rightTrigger;
  40125. private _onlefttriggerchanged;
  40126. private _onrighttriggerchanged;
  40127. private _onbuttondown;
  40128. private _onbuttonup;
  40129. private _ondpaddown;
  40130. private _ondpadup;
  40131. /** Observable raised when a button is pressed */
  40132. onButtonDownObservable: Observable<Xbox360Button>;
  40133. /** Observable raised when a button is released */
  40134. onButtonUpObservable: Observable<Xbox360Button>;
  40135. /** Observable raised when a pad is pressed */
  40136. onPadDownObservable: Observable<Xbox360Dpad>;
  40137. /** Observable raised when a pad is released */
  40138. onPadUpObservable: Observable<Xbox360Dpad>;
  40139. private _buttonA;
  40140. private _buttonB;
  40141. private _buttonX;
  40142. private _buttonY;
  40143. private _buttonBack;
  40144. private _buttonStart;
  40145. private _buttonLB;
  40146. private _buttonRB;
  40147. private _buttonLeftStick;
  40148. private _buttonRightStick;
  40149. private _dPadUp;
  40150. private _dPadDown;
  40151. private _dPadLeft;
  40152. private _dPadRight;
  40153. private _isXboxOnePad;
  40154. /**
  40155. * Creates a new XBox360 gamepad object
  40156. * @param id defines the id of this gamepad
  40157. * @param index defines its index
  40158. * @param gamepad defines the internal HTML gamepad object
  40159. * @param xboxOne defines if it is a XBox One gamepad
  40160. */
  40161. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40162. /**
  40163. * Defines the callback to call when left trigger is pressed
  40164. * @param callback defines the callback to use
  40165. */
  40166. onlefttriggerchanged(callback: (value: number) => void): void;
  40167. /**
  40168. * Defines the callback to call when right trigger is pressed
  40169. * @param callback defines the callback to use
  40170. */
  40171. onrighttriggerchanged(callback: (value: number) => void): void;
  40172. /**
  40173. * Gets the left trigger value
  40174. */
  40175. /**
  40176. * Sets the left trigger value
  40177. */
  40178. leftTrigger: number;
  40179. /**
  40180. * Gets the right trigger value
  40181. */
  40182. /**
  40183. * Sets the right trigger value
  40184. */
  40185. rightTrigger: number;
  40186. /**
  40187. * Defines the callback to call when a button is pressed
  40188. * @param callback defines the callback to use
  40189. */
  40190. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40191. /**
  40192. * Defines the callback to call when a button is released
  40193. * @param callback defines the callback to use
  40194. */
  40195. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40196. /**
  40197. * Defines the callback to call when a pad is pressed
  40198. * @param callback defines the callback to use
  40199. */
  40200. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40201. /**
  40202. * Defines the callback to call when a pad is released
  40203. * @param callback defines the callback to use
  40204. */
  40205. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40206. private _setButtonValue;
  40207. private _setDPadValue;
  40208. /**
  40209. * Gets the value of the `A` button
  40210. */
  40211. /**
  40212. * Sets the value of the `A` button
  40213. */
  40214. buttonA: number;
  40215. /**
  40216. * Gets the value of the `B` button
  40217. */
  40218. /**
  40219. * Sets the value of the `B` button
  40220. */
  40221. buttonB: number;
  40222. /**
  40223. * Gets the value of the `X` button
  40224. */
  40225. /**
  40226. * Sets the value of the `X` button
  40227. */
  40228. buttonX: number;
  40229. /**
  40230. * Gets the value of the `Y` button
  40231. */
  40232. /**
  40233. * Sets the value of the `Y` button
  40234. */
  40235. buttonY: number;
  40236. /**
  40237. * Gets the value of the `Start` button
  40238. */
  40239. /**
  40240. * Sets the value of the `Start` button
  40241. */
  40242. buttonStart: number;
  40243. /**
  40244. * Gets the value of the `Back` button
  40245. */
  40246. /**
  40247. * Sets the value of the `Back` button
  40248. */
  40249. buttonBack: number;
  40250. /**
  40251. * Gets the value of the `Left` button
  40252. */
  40253. /**
  40254. * Sets the value of the `Left` button
  40255. */
  40256. buttonLB: number;
  40257. /**
  40258. * Gets the value of the `Right` button
  40259. */
  40260. /**
  40261. * Sets the value of the `Right` button
  40262. */
  40263. buttonRB: number;
  40264. /**
  40265. * Gets the value of the Left joystick
  40266. */
  40267. /**
  40268. * Sets the value of the Left joystick
  40269. */
  40270. buttonLeftStick: number;
  40271. /**
  40272. * Gets the value of the Right joystick
  40273. */
  40274. /**
  40275. * Sets the value of the Right joystick
  40276. */
  40277. buttonRightStick: number;
  40278. /**
  40279. * Gets the value of D-pad up
  40280. */
  40281. /**
  40282. * Sets the value of D-pad up
  40283. */
  40284. dPadUp: number;
  40285. /**
  40286. * Gets the value of D-pad down
  40287. */
  40288. /**
  40289. * Sets the value of D-pad down
  40290. */
  40291. dPadDown: number;
  40292. /**
  40293. * Gets the value of D-pad left
  40294. */
  40295. /**
  40296. * Sets the value of D-pad left
  40297. */
  40298. dPadLeft: number;
  40299. /**
  40300. * Gets the value of D-pad right
  40301. */
  40302. /**
  40303. * Sets the value of D-pad right
  40304. */
  40305. dPadRight: number;
  40306. /**
  40307. * Force the gamepad to synchronize with device values
  40308. */
  40309. update(): void;
  40310. /**
  40311. * Disposes the gamepad
  40312. */
  40313. dispose(): void;
  40314. }
  40315. }
  40316. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40317. import { Observable } from "babylonjs/Misc/observable";
  40318. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40319. /**
  40320. * Defines supported buttons for DualShock compatible gamepads
  40321. */
  40322. export enum DualShockButton {
  40323. /** Cross */
  40324. Cross = 0,
  40325. /** Circle */
  40326. Circle = 1,
  40327. /** Square */
  40328. Square = 2,
  40329. /** Triangle */
  40330. Triangle = 3,
  40331. /** Options */
  40332. Options = 4,
  40333. /** Share */
  40334. Share = 5,
  40335. /** L1 */
  40336. L1 = 6,
  40337. /** R1 */
  40338. R1 = 7,
  40339. /** Left stick */
  40340. LeftStick = 8,
  40341. /** Right stick */
  40342. RightStick = 9
  40343. }
  40344. /** Defines values for DualShock DPad */
  40345. export enum DualShockDpad {
  40346. /** Up */
  40347. Up = 0,
  40348. /** Down */
  40349. Down = 1,
  40350. /** Left */
  40351. Left = 2,
  40352. /** Right */
  40353. Right = 3
  40354. }
  40355. /**
  40356. * Defines a DualShock gamepad
  40357. */
  40358. export class DualShockPad extends Gamepad {
  40359. private _leftTrigger;
  40360. private _rightTrigger;
  40361. private _onlefttriggerchanged;
  40362. private _onrighttriggerchanged;
  40363. private _onbuttondown;
  40364. private _onbuttonup;
  40365. private _ondpaddown;
  40366. private _ondpadup;
  40367. /** Observable raised when a button is pressed */
  40368. onButtonDownObservable: Observable<DualShockButton>;
  40369. /** Observable raised when a button is released */
  40370. onButtonUpObservable: Observable<DualShockButton>;
  40371. /** Observable raised when a pad is pressed */
  40372. onPadDownObservable: Observable<DualShockDpad>;
  40373. /** Observable raised when a pad is released */
  40374. onPadUpObservable: Observable<DualShockDpad>;
  40375. private _buttonCross;
  40376. private _buttonCircle;
  40377. private _buttonSquare;
  40378. private _buttonTriangle;
  40379. private _buttonShare;
  40380. private _buttonOptions;
  40381. private _buttonL1;
  40382. private _buttonR1;
  40383. private _buttonLeftStick;
  40384. private _buttonRightStick;
  40385. private _dPadUp;
  40386. private _dPadDown;
  40387. private _dPadLeft;
  40388. private _dPadRight;
  40389. /**
  40390. * Creates a new DualShock gamepad object
  40391. * @param id defines the id of this gamepad
  40392. * @param index defines its index
  40393. * @param gamepad defines the internal HTML gamepad object
  40394. */
  40395. constructor(id: string, index: number, gamepad: any);
  40396. /**
  40397. * Defines the callback to call when left trigger is pressed
  40398. * @param callback defines the callback to use
  40399. */
  40400. onlefttriggerchanged(callback: (value: number) => void): void;
  40401. /**
  40402. * Defines the callback to call when right trigger is pressed
  40403. * @param callback defines the callback to use
  40404. */
  40405. onrighttriggerchanged(callback: (value: number) => void): void;
  40406. /**
  40407. * Gets the left trigger value
  40408. */
  40409. /**
  40410. * Sets the left trigger value
  40411. */
  40412. leftTrigger: number;
  40413. /**
  40414. * Gets the right trigger value
  40415. */
  40416. /**
  40417. * Sets the right trigger value
  40418. */
  40419. rightTrigger: number;
  40420. /**
  40421. * Defines the callback to call when a button is pressed
  40422. * @param callback defines the callback to use
  40423. */
  40424. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40425. /**
  40426. * Defines the callback to call when a button is released
  40427. * @param callback defines the callback to use
  40428. */
  40429. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40430. /**
  40431. * Defines the callback to call when a pad is pressed
  40432. * @param callback defines the callback to use
  40433. */
  40434. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40435. /**
  40436. * Defines the callback to call when a pad is released
  40437. * @param callback defines the callback to use
  40438. */
  40439. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40440. private _setButtonValue;
  40441. private _setDPadValue;
  40442. /**
  40443. * Gets the value of the `Cross` button
  40444. */
  40445. /**
  40446. * Sets the value of the `Cross` button
  40447. */
  40448. buttonCross: number;
  40449. /**
  40450. * Gets the value of the `Circle` button
  40451. */
  40452. /**
  40453. * Sets the value of the `Circle` button
  40454. */
  40455. buttonCircle: number;
  40456. /**
  40457. * Gets the value of the `Square` button
  40458. */
  40459. /**
  40460. * Sets the value of the `Square` button
  40461. */
  40462. buttonSquare: number;
  40463. /**
  40464. * Gets the value of the `Triangle` button
  40465. */
  40466. /**
  40467. * Sets the value of the `Triangle` button
  40468. */
  40469. buttonTriangle: number;
  40470. /**
  40471. * Gets the value of the `Options` button
  40472. */
  40473. /**
  40474. * Sets the value of the `Options` button
  40475. */
  40476. buttonOptions: number;
  40477. /**
  40478. * Gets the value of the `Share` button
  40479. */
  40480. /**
  40481. * Sets the value of the `Share` button
  40482. */
  40483. buttonShare: number;
  40484. /**
  40485. * Gets the value of the `L1` button
  40486. */
  40487. /**
  40488. * Sets the value of the `L1` button
  40489. */
  40490. buttonL1: number;
  40491. /**
  40492. * Gets the value of the `R1` button
  40493. */
  40494. /**
  40495. * Sets the value of the `R1` button
  40496. */
  40497. buttonR1: number;
  40498. /**
  40499. * Gets the value of the Left joystick
  40500. */
  40501. /**
  40502. * Sets the value of the Left joystick
  40503. */
  40504. buttonLeftStick: number;
  40505. /**
  40506. * Gets the value of the Right joystick
  40507. */
  40508. /**
  40509. * Sets the value of the Right joystick
  40510. */
  40511. buttonRightStick: number;
  40512. /**
  40513. * Gets the value of D-pad up
  40514. */
  40515. /**
  40516. * Sets the value of D-pad up
  40517. */
  40518. dPadUp: number;
  40519. /**
  40520. * Gets the value of D-pad down
  40521. */
  40522. /**
  40523. * Sets the value of D-pad down
  40524. */
  40525. dPadDown: number;
  40526. /**
  40527. * Gets the value of D-pad left
  40528. */
  40529. /**
  40530. * Sets the value of D-pad left
  40531. */
  40532. dPadLeft: number;
  40533. /**
  40534. * Gets the value of D-pad right
  40535. */
  40536. /**
  40537. * Sets the value of D-pad right
  40538. */
  40539. dPadRight: number;
  40540. /**
  40541. * Force the gamepad to synchronize with device values
  40542. */
  40543. update(): void;
  40544. /**
  40545. * Disposes the gamepad
  40546. */
  40547. dispose(): void;
  40548. }
  40549. }
  40550. declare module "babylonjs/Gamepads/gamepadManager" {
  40551. import { Observable } from "babylonjs/Misc/observable";
  40552. import { Nullable } from "babylonjs/types";
  40553. import { Scene } from "babylonjs/scene";
  40554. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40555. /**
  40556. * Manager for handling gamepads
  40557. */
  40558. export class GamepadManager {
  40559. private _scene?;
  40560. private _babylonGamepads;
  40561. private _oneGamepadConnected;
  40562. /** @hidden */
  40563. _isMonitoring: boolean;
  40564. private _gamepadEventSupported;
  40565. private _gamepadSupport;
  40566. /**
  40567. * observable to be triggered when the gamepad controller has been connected
  40568. */
  40569. onGamepadConnectedObservable: Observable<Gamepad>;
  40570. /**
  40571. * observable to be triggered when the gamepad controller has been disconnected
  40572. */
  40573. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40574. private _onGamepadConnectedEvent;
  40575. private _onGamepadDisconnectedEvent;
  40576. /**
  40577. * Initializes the gamepad manager
  40578. * @param _scene BabylonJS scene
  40579. */
  40580. constructor(_scene?: Scene | undefined);
  40581. /**
  40582. * The gamepads in the game pad manager
  40583. */
  40584. readonly gamepads: Gamepad[];
  40585. /**
  40586. * Get the gamepad controllers based on type
  40587. * @param type The type of gamepad controller
  40588. * @returns Nullable gamepad
  40589. */
  40590. getGamepadByType(type?: number): Nullable<Gamepad>;
  40591. /**
  40592. * Disposes the gamepad manager
  40593. */
  40594. dispose(): void;
  40595. private _addNewGamepad;
  40596. private _startMonitoringGamepads;
  40597. private _stopMonitoringGamepads;
  40598. /** @hidden */
  40599. _checkGamepadsStatus(): void;
  40600. private _updateGamepadObjects;
  40601. }
  40602. }
  40603. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40604. import { Nullable } from "babylonjs/types";
  40605. import { Scene } from "babylonjs/scene";
  40606. import { ISceneComponent } from "babylonjs/sceneComponent";
  40607. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40608. module "babylonjs/scene" {
  40609. interface Scene {
  40610. /** @hidden */
  40611. _gamepadManager: Nullable<GamepadManager>;
  40612. /**
  40613. * Gets the gamepad manager associated with the scene
  40614. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40615. */
  40616. gamepadManager: GamepadManager;
  40617. }
  40618. }
  40619. module "babylonjs/Cameras/freeCameraInputsManager" {
  40620. /**
  40621. * Interface representing a free camera inputs manager
  40622. */
  40623. interface FreeCameraInputsManager {
  40624. /**
  40625. * Adds gamepad input support to the FreeCameraInputsManager.
  40626. * @returns the FreeCameraInputsManager
  40627. */
  40628. addGamepad(): FreeCameraInputsManager;
  40629. }
  40630. }
  40631. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40632. /**
  40633. * Interface representing an arc rotate camera inputs manager
  40634. */
  40635. interface ArcRotateCameraInputsManager {
  40636. /**
  40637. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40638. * @returns the camera inputs manager
  40639. */
  40640. addGamepad(): ArcRotateCameraInputsManager;
  40641. }
  40642. }
  40643. /**
  40644. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40645. */
  40646. export class GamepadSystemSceneComponent implements ISceneComponent {
  40647. /**
  40648. * The component name helpfull to identify the component in the list of scene components.
  40649. */
  40650. readonly name: string;
  40651. /**
  40652. * The scene the component belongs to.
  40653. */
  40654. scene: Scene;
  40655. /**
  40656. * Creates a new instance of the component for the given scene
  40657. * @param scene Defines the scene to register the component in
  40658. */
  40659. constructor(scene: Scene);
  40660. /**
  40661. * Registers the component in a given scene
  40662. */
  40663. register(): void;
  40664. /**
  40665. * Rebuilds the elements related to this component in case of
  40666. * context lost for instance.
  40667. */
  40668. rebuild(): void;
  40669. /**
  40670. * Disposes the component and the associated ressources
  40671. */
  40672. dispose(): void;
  40673. private _beforeCameraUpdate;
  40674. }
  40675. }
  40676. declare module "babylonjs/Cameras/universalCamera" {
  40677. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40678. import { Scene } from "babylonjs/scene";
  40679. import { Vector3 } from "babylonjs/Maths/math.vector";
  40680. import "babylonjs/Gamepads/gamepadSceneComponent";
  40681. /**
  40682. * 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,
  40683. * which still works and will still be found in many Playgrounds.
  40684. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40685. */
  40686. export class UniversalCamera extends TouchCamera {
  40687. /**
  40688. * Defines the gamepad rotation sensiblity.
  40689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40690. */
  40691. gamepadAngularSensibility: number;
  40692. /**
  40693. * Defines the gamepad move sensiblity.
  40694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40695. */
  40696. gamepadMoveSensibility: number;
  40697. /**
  40698. * 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,
  40699. * which still works and will still be found in many Playgrounds.
  40700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40701. * @param name Define the name of the camera in the scene
  40702. * @param position Define the start position of the camera in the scene
  40703. * @param scene Define the scene the camera belongs to
  40704. */
  40705. constructor(name: string, position: Vector3, scene: Scene);
  40706. /**
  40707. * Gets the current object class name.
  40708. * @return the class name
  40709. */
  40710. getClassName(): string;
  40711. }
  40712. }
  40713. declare module "babylonjs/Cameras/gamepadCamera" {
  40714. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40715. import { Scene } from "babylonjs/scene";
  40716. import { Vector3 } from "babylonjs/Maths/math.vector";
  40717. /**
  40718. * This represents a FPS type of camera. This is only here for back compat purpose.
  40719. * Please use the UniversalCamera instead as both are identical.
  40720. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40721. */
  40722. export class GamepadCamera extends UniversalCamera {
  40723. /**
  40724. * Instantiates a new Gamepad Camera
  40725. * This represents a FPS type of camera. This is only here for back compat purpose.
  40726. * Please use the UniversalCamera instead as both are identical.
  40727. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40728. * @param name Define the name of the camera in the scene
  40729. * @param position Define the start position of the camera in the scene
  40730. * @param scene Define the scene the camera belongs to
  40731. */
  40732. constructor(name: string, position: Vector3, scene: Scene);
  40733. /**
  40734. * Gets the current object class name.
  40735. * @return the class name
  40736. */
  40737. getClassName(): string;
  40738. }
  40739. }
  40740. declare module "babylonjs/Shaders/pass.fragment" {
  40741. /** @hidden */
  40742. export var passPixelShader: {
  40743. name: string;
  40744. shader: string;
  40745. };
  40746. }
  40747. declare module "babylonjs/Shaders/passCube.fragment" {
  40748. /** @hidden */
  40749. export var passCubePixelShader: {
  40750. name: string;
  40751. shader: string;
  40752. };
  40753. }
  40754. declare module "babylonjs/PostProcesses/passPostProcess" {
  40755. import { Nullable } from "babylonjs/types";
  40756. import { Camera } from "babylonjs/Cameras/camera";
  40757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40758. import { Engine } from "babylonjs/Engines/engine";
  40759. import "babylonjs/Shaders/pass.fragment";
  40760. import "babylonjs/Shaders/passCube.fragment";
  40761. /**
  40762. * PassPostProcess which produces an output the same as it's input
  40763. */
  40764. export class PassPostProcess extends PostProcess {
  40765. /**
  40766. * Creates the PassPostProcess
  40767. * @param name The name of the effect.
  40768. * @param options The required width/height ratio to downsize to before computing the render pass.
  40769. * @param camera The camera to apply the render pass to.
  40770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40771. * @param engine The engine which the post process will be applied. (default: current engine)
  40772. * @param reusable If the post process can be reused on the same frame. (default: false)
  40773. * @param textureType The type of texture to be used when performing the post processing.
  40774. * @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)
  40775. */
  40776. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40777. }
  40778. /**
  40779. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40780. */
  40781. export class PassCubePostProcess extends PostProcess {
  40782. private _face;
  40783. /**
  40784. * Gets or sets the cube face to display.
  40785. * * 0 is +X
  40786. * * 1 is -X
  40787. * * 2 is +Y
  40788. * * 3 is -Y
  40789. * * 4 is +Z
  40790. * * 5 is -Z
  40791. */
  40792. face: number;
  40793. /**
  40794. * Creates the PassCubePostProcess
  40795. * @param name The name of the effect.
  40796. * @param options The required width/height ratio to downsize to before computing the render pass.
  40797. * @param camera The camera to apply the render pass to.
  40798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40799. * @param engine The engine which the post process will be applied. (default: current engine)
  40800. * @param reusable If the post process can be reused on the same frame. (default: false)
  40801. * @param textureType The type of texture to be used when performing the post processing.
  40802. * @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)
  40803. */
  40804. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40805. }
  40806. }
  40807. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40808. /** @hidden */
  40809. export var anaglyphPixelShader: {
  40810. name: string;
  40811. shader: string;
  40812. };
  40813. }
  40814. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40815. import { Engine } from "babylonjs/Engines/engine";
  40816. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40817. import { Camera } from "babylonjs/Cameras/camera";
  40818. import "babylonjs/Shaders/anaglyph.fragment";
  40819. /**
  40820. * Postprocess used to generate anaglyphic rendering
  40821. */
  40822. export class AnaglyphPostProcess extends PostProcess {
  40823. private _passedProcess;
  40824. /**
  40825. * Creates a new AnaglyphPostProcess
  40826. * @param name defines postprocess name
  40827. * @param options defines creation options or target ratio scale
  40828. * @param rigCameras defines cameras using this postprocess
  40829. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40830. * @param engine defines hosting engine
  40831. * @param reusable defines if the postprocess will be reused multiple times per frame
  40832. */
  40833. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40834. }
  40835. }
  40836. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40837. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40838. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40839. import { Scene } from "babylonjs/scene";
  40840. import { Vector3 } from "babylonjs/Maths/math.vector";
  40841. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40842. /**
  40843. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40844. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40845. */
  40846. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40847. /**
  40848. * Creates a new AnaglyphArcRotateCamera
  40849. * @param name defines camera name
  40850. * @param alpha defines alpha angle (in radians)
  40851. * @param beta defines beta angle (in radians)
  40852. * @param radius defines radius
  40853. * @param target defines camera target
  40854. * @param interaxialDistance defines distance between each color axis
  40855. * @param scene defines the hosting scene
  40856. */
  40857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40858. /**
  40859. * Gets camera class name
  40860. * @returns AnaglyphArcRotateCamera
  40861. */
  40862. getClassName(): string;
  40863. }
  40864. }
  40865. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40867. import { Scene } from "babylonjs/scene";
  40868. import { Vector3 } from "babylonjs/Maths/math.vector";
  40869. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40870. /**
  40871. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40872. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40873. */
  40874. export class AnaglyphFreeCamera extends FreeCamera {
  40875. /**
  40876. * Creates a new AnaglyphFreeCamera
  40877. * @param name defines camera name
  40878. * @param position defines initial position
  40879. * @param interaxialDistance defines distance between each color axis
  40880. * @param scene defines the hosting scene
  40881. */
  40882. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40883. /**
  40884. * Gets camera class name
  40885. * @returns AnaglyphFreeCamera
  40886. */
  40887. getClassName(): string;
  40888. }
  40889. }
  40890. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40891. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40895. /**
  40896. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40897. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40898. */
  40899. export class AnaglyphGamepadCamera extends GamepadCamera {
  40900. /**
  40901. * Creates a new AnaglyphGamepadCamera
  40902. * @param name defines camera name
  40903. * @param position defines initial position
  40904. * @param interaxialDistance defines distance between each color axis
  40905. * @param scene defines the hosting scene
  40906. */
  40907. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40908. /**
  40909. * Gets camera class name
  40910. * @returns AnaglyphGamepadCamera
  40911. */
  40912. getClassName(): string;
  40913. }
  40914. }
  40915. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40916. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40917. import { Scene } from "babylonjs/scene";
  40918. import { Vector3 } from "babylonjs/Maths/math.vector";
  40919. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40920. /**
  40921. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40922. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40923. */
  40924. export class AnaglyphUniversalCamera extends UniversalCamera {
  40925. /**
  40926. * Creates a new AnaglyphUniversalCamera
  40927. * @param name defines camera name
  40928. * @param position defines initial position
  40929. * @param interaxialDistance defines distance between each color axis
  40930. * @param scene defines the hosting scene
  40931. */
  40932. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40933. /**
  40934. * Gets camera class name
  40935. * @returns AnaglyphUniversalCamera
  40936. */
  40937. getClassName(): string;
  40938. }
  40939. }
  40940. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40941. /** @hidden */
  40942. export var stereoscopicInterlacePixelShader: {
  40943. name: string;
  40944. shader: string;
  40945. };
  40946. }
  40947. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40948. import { Camera } from "babylonjs/Cameras/camera";
  40949. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40950. import { Engine } from "babylonjs/Engines/engine";
  40951. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40952. /**
  40953. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40954. */
  40955. export class StereoscopicInterlacePostProcess extends PostProcess {
  40956. private _stepSize;
  40957. private _passedProcess;
  40958. /**
  40959. * Initializes a StereoscopicInterlacePostProcess
  40960. * @param name The name of the effect.
  40961. * @param rigCameras The rig cameras to be appled to the post process
  40962. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40964. * @param engine The engine which the post process will be applied. (default: current engine)
  40965. * @param reusable If the post process can be reused on the same frame. (default: false)
  40966. */
  40967. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40971. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40972. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40973. import { Scene } from "babylonjs/scene";
  40974. import { Vector3 } from "babylonjs/Maths/math.vector";
  40975. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40976. /**
  40977. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40978. * @see http://doc.babylonjs.com/features/cameras
  40979. */
  40980. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40981. /**
  40982. * Creates a new StereoscopicArcRotateCamera
  40983. * @param name defines camera name
  40984. * @param alpha defines alpha angle (in radians)
  40985. * @param beta defines beta angle (in radians)
  40986. * @param radius defines radius
  40987. * @param target defines camera target
  40988. * @param interaxialDistance defines distance between each color axis
  40989. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40990. * @param scene defines the hosting scene
  40991. */
  40992. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40993. /**
  40994. * Gets camera class name
  40995. * @returns StereoscopicArcRotateCamera
  40996. */
  40997. getClassName(): string;
  40998. }
  40999. }
  41000. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41001. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41002. import { Scene } from "babylonjs/scene";
  41003. import { Vector3 } from "babylonjs/Maths/math.vector";
  41004. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41005. /**
  41006. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41007. * @see http://doc.babylonjs.com/features/cameras
  41008. */
  41009. export class StereoscopicFreeCamera extends FreeCamera {
  41010. /**
  41011. * Creates a new StereoscopicFreeCamera
  41012. * @param name defines camera name
  41013. * @param position defines initial position
  41014. * @param interaxialDistance defines distance between each color axis
  41015. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41016. * @param scene defines the hosting scene
  41017. */
  41018. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41019. /**
  41020. * Gets camera class name
  41021. * @returns StereoscopicFreeCamera
  41022. */
  41023. getClassName(): string;
  41024. }
  41025. }
  41026. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41027. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41028. import { Scene } from "babylonjs/scene";
  41029. import { Vector3 } from "babylonjs/Maths/math.vector";
  41030. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41031. /**
  41032. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41033. * @see http://doc.babylonjs.com/features/cameras
  41034. */
  41035. export class StereoscopicGamepadCamera extends GamepadCamera {
  41036. /**
  41037. * Creates a new StereoscopicGamepadCamera
  41038. * @param name defines camera name
  41039. * @param position defines initial position
  41040. * @param interaxialDistance defines distance between each color axis
  41041. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41042. * @param scene defines the hosting scene
  41043. */
  41044. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41045. /**
  41046. * Gets camera class name
  41047. * @returns StereoscopicGamepadCamera
  41048. */
  41049. getClassName(): string;
  41050. }
  41051. }
  41052. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41053. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41054. import { Scene } from "babylonjs/scene";
  41055. import { Vector3 } from "babylonjs/Maths/math.vector";
  41056. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41057. /**
  41058. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41059. * @see http://doc.babylonjs.com/features/cameras
  41060. */
  41061. export class StereoscopicUniversalCamera extends UniversalCamera {
  41062. /**
  41063. * Creates a new StereoscopicUniversalCamera
  41064. * @param name defines camera name
  41065. * @param position defines initial position
  41066. * @param interaxialDistance defines distance between each color axis
  41067. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41068. * @param scene defines the hosting scene
  41069. */
  41070. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41071. /**
  41072. * Gets camera class name
  41073. * @returns StereoscopicUniversalCamera
  41074. */
  41075. getClassName(): string;
  41076. }
  41077. }
  41078. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41079. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41080. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41081. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41082. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41083. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41084. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41085. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41086. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41087. }
  41088. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41089. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Vector3 } from "babylonjs/Maths/math.vector";
  41092. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41093. /**
  41094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41095. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41096. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41097. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41098. */
  41099. export class VirtualJoysticksCamera extends FreeCamera {
  41100. /**
  41101. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41102. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41103. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41104. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41105. * @param name Define the name of the camera in the scene
  41106. * @param position Define the start position of the camera in the scene
  41107. * @param scene Define the scene the camera belongs to
  41108. */
  41109. constructor(name: string, position: Vector3, scene: Scene);
  41110. /**
  41111. * Gets the current object class name.
  41112. * @return the class name
  41113. */
  41114. getClassName(): string;
  41115. }
  41116. }
  41117. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41118. import { Matrix } from "babylonjs/Maths/math.vector";
  41119. /**
  41120. * This represents all the required metrics to create a VR camera.
  41121. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41122. */
  41123. export class VRCameraMetrics {
  41124. /**
  41125. * Define the horizontal resolution off the screen.
  41126. */
  41127. hResolution: number;
  41128. /**
  41129. * Define the vertical resolution off the screen.
  41130. */
  41131. vResolution: number;
  41132. /**
  41133. * Define the horizontal screen size.
  41134. */
  41135. hScreenSize: number;
  41136. /**
  41137. * Define the vertical screen size.
  41138. */
  41139. vScreenSize: number;
  41140. /**
  41141. * Define the vertical screen center position.
  41142. */
  41143. vScreenCenter: number;
  41144. /**
  41145. * Define the distance of the eyes to the screen.
  41146. */
  41147. eyeToScreenDistance: number;
  41148. /**
  41149. * Define the distance between both lenses
  41150. */
  41151. lensSeparationDistance: number;
  41152. /**
  41153. * Define the distance between both viewer's eyes.
  41154. */
  41155. interpupillaryDistance: number;
  41156. /**
  41157. * Define the distortion factor of the VR postprocess.
  41158. * Please, touch with care.
  41159. */
  41160. distortionK: number[];
  41161. /**
  41162. * Define the chromatic aberration correction factors for the VR post process.
  41163. */
  41164. chromaAbCorrection: number[];
  41165. /**
  41166. * Define the scale factor of the post process.
  41167. * The smaller the better but the slower.
  41168. */
  41169. postProcessScaleFactor: number;
  41170. /**
  41171. * Define an offset for the lens center.
  41172. */
  41173. lensCenterOffset: number;
  41174. /**
  41175. * Define if the current vr camera should compensate the distortion of the lense or not.
  41176. */
  41177. compensateDistortion: boolean;
  41178. /**
  41179. * Defines if multiview should be enabled when rendering (Default: false)
  41180. */
  41181. multiviewEnabled: boolean;
  41182. /**
  41183. * Gets the rendering aspect ratio based on the provided resolutions.
  41184. */
  41185. readonly aspectRatio: number;
  41186. /**
  41187. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41188. */
  41189. readonly aspectRatioFov: number;
  41190. /**
  41191. * @hidden
  41192. */
  41193. readonly leftHMatrix: Matrix;
  41194. /**
  41195. * @hidden
  41196. */
  41197. readonly rightHMatrix: Matrix;
  41198. /**
  41199. * @hidden
  41200. */
  41201. readonly leftPreViewMatrix: Matrix;
  41202. /**
  41203. * @hidden
  41204. */
  41205. readonly rightPreViewMatrix: Matrix;
  41206. /**
  41207. * Get the default VRMetrics based on the most generic setup.
  41208. * @returns the default vr metrics
  41209. */
  41210. static GetDefault(): VRCameraMetrics;
  41211. }
  41212. }
  41213. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41214. /** @hidden */
  41215. export var vrDistortionCorrectionPixelShader: {
  41216. name: string;
  41217. shader: string;
  41218. };
  41219. }
  41220. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41221. import { Camera } from "babylonjs/Cameras/camera";
  41222. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41224. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41225. /**
  41226. * VRDistortionCorrectionPostProcess used for mobile VR
  41227. */
  41228. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41229. private _isRightEye;
  41230. private _distortionFactors;
  41231. private _postProcessScaleFactor;
  41232. private _lensCenterOffset;
  41233. private _scaleIn;
  41234. private _scaleFactor;
  41235. private _lensCenter;
  41236. /**
  41237. * Initializes the VRDistortionCorrectionPostProcess
  41238. * @param name The name of the effect.
  41239. * @param camera The camera to apply the render pass to.
  41240. * @param isRightEye If this is for the right eye distortion
  41241. * @param vrMetrics All the required metrics for the VR camera
  41242. */
  41243. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41244. }
  41245. }
  41246. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41247. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41248. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41249. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41250. import { Scene } from "babylonjs/scene";
  41251. import { Vector3 } from "babylonjs/Maths/math.vector";
  41252. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41253. import "babylonjs/Cameras/RigModes/vrRigMode";
  41254. /**
  41255. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41256. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41257. */
  41258. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41259. /**
  41260. * Creates a new VRDeviceOrientationArcRotateCamera
  41261. * @param name defines camera name
  41262. * @param alpha defines the camera rotation along the logitudinal axis
  41263. * @param beta defines the camera rotation along the latitudinal axis
  41264. * @param radius defines the camera distance from its target
  41265. * @param target defines the camera target
  41266. * @param scene defines the scene the camera belongs to
  41267. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41268. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41269. */
  41270. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41271. /**
  41272. * Gets camera class name
  41273. * @returns VRDeviceOrientationArcRotateCamera
  41274. */
  41275. getClassName(): string;
  41276. }
  41277. }
  41278. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41279. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41280. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41281. import { Scene } from "babylonjs/scene";
  41282. import { Vector3 } from "babylonjs/Maths/math.vector";
  41283. import "babylonjs/Cameras/RigModes/vrRigMode";
  41284. /**
  41285. * Camera used to simulate VR rendering (based on FreeCamera)
  41286. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41287. */
  41288. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41289. /**
  41290. * Creates a new VRDeviceOrientationFreeCamera
  41291. * @param name defines camera name
  41292. * @param position defines the start position of the camera
  41293. * @param scene defines the scene the camera belongs to
  41294. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41295. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41296. */
  41297. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41298. /**
  41299. * Gets camera class name
  41300. * @returns VRDeviceOrientationFreeCamera
  41301. */
  41302. getClassName(): string;
  41303. }
  41304. }
  41305. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41306. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41307. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41308. import { Scene } from "babylonjs/scene";
  41309. import { Vector3 } from "babylonjs/Maths/math.vector";
  41310. import "babylonjs/Gamepads/gamepadSceneComponent";
  41311. /**
  41312. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41313. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41314. */
  41315. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41316. /**
  41317. * Creates a new VRDeviceOrientationGamepadCamera
  41318. * @param name defines camera name
  41319. * @param position defines the start position of the camera
  41320. * @param scene defines the scene the camera belongs to
  41321. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41322. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41323. */
  41324. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41325. /**
  41326. * Gets camera class name
  41327. * @returns VRDeviceOrientationGamepadCamera
  41328. */
  41329. getClassName(): string;
  41330. }
  41331. }
  41332. declare module "babylonjs/Materials/pushMaterial" {
  41333. import { Nullable } from "babylonjs/types";
  41334. import { Scene } from "babylonjs/scene";
  41335. import { Matrix } from "babylonjs/Maths/math.vector";
  41336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41337. import { Mesh } from "babylonjs/Meshes/mesh";
  41338. import { Material } from "babylonjs/Materials/material";
  41339. import { Effect } from "babylonjs/Materials/effect";
  41340. /**
  41341. * Base class of materials working in push mode in babylon JS
  41342. * @hidden
  41343. */
  41344. export class PushMaterial extends Material {
  41345. protected _activeEffect: Effect;
  41346. protected _normalMatrix: Matrix;
  41347. /**
  41348. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41349. * This means that the material can keep using a previous shader while a new one is being compiled.
  41350. * This is mostly used when shader parallel compilation is supported (true by default)
  41351. */
  41352. allowShaderHotSwapping: boolean;
  41353. constructor(name: string, scene: Scene);
  41354. getEffect(): Effect;
  41355. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41356. /**
  41357. * Binds the given world matrix to the active effect
  41358. *
  41359. * @param world the matrix to bind
  41360. */
  41361. bindOnlyWorldMatrix(world: Matrix): void;
  41362. /**
  41363. * Binds the given normal matrix to the active effect
  41364. *
  41365. * @param normalMatrix the matrix to bind
  41366. */
  41367. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41368. bind(world: Matrix, mesh?: Mesh): void;
  41369. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41370. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41371. }
  41372. }
  41373. declare module "babylonjs/Materials/materialFlags" {
  41374. /**
  41375. * This groups all the flags used to control the materials channel.
  41376. */
  41377. export class MaterialFlags {
  41378. private static _DiffuseTextureEnabled;
  41379. /**
  41380. * Are diffuse textures enabled in the application.
  41381. */
  41382. static DiffuseTextureEnabled: boolean;
  41383. private static _AmbientTextureEnabled;
  41384. /**
  41385. * Are ambient textures enabled in the application.
  41386. */
  41387. static AmbientTextureEnabled: boolean;
  41388. private static _OpacityTextureEnabled;
  41389. /**
  41390. * Are opacity textures enabled in the application.
  41391. */
  41392. static OpacityTextureEnabled: boolean;
  41393. private static _ReflectionTextureEnabled;
  41394. /**
  41395. * Are reflection textures enabled in the application.
  41396. */
  41397. static ReflectionTextureEnabled: boolean;
  41398. private static _EmissiveTextureEnabled;
  41399. /**
  41400. * Are emissive textures enabled in the application.
  41401. */
  41402. static EmissiveTextureEnabled: boolean;
  41403. private static _SpecularTextureEnabled;
  41404. /**
  41405. * Are specular textures enabled in the application.
  41406. */
  41407. static SpecularTextureEnabled: boolean;
  41408. private static _BumpTextureEnabled;
  41409. /**
  41410. * Are bump textures enabled in the application.
  41411. */
  41412. static BumpTextureEnabled: boolean;
  41413. private static _LightmapTextureEnabled;
  41414. /**
  41415. * Are lightmap textures enabled in the application.
  41416. */
  41417. static LightmapTextureEnabled: boolean;
  41418. private static _RefractionTextureEnabled;
  41419. /**
  41420. * Are refraction textures enabled in the application.
  41421. */
  41422. static RefractionTextureEnabled: boolean;
  41423. private static _ColorGradingTextureEnabled;
  41424. /**
  41425. * Are color grading textures enabled in the application.
  41426. */
  41427. static ColorGradingTextureEnabled: boolean;
  41428. private static _FresnelEnabled;
  41429. /**
  41430. * Are fresnels enabled in the application.
  41431. */
  41432. static FresnelEnabled: boolean;
  41433. private static _ClearCoatTextureEnabled;
  41434. /**
  41435. * Are clear coat textures enabled in the application.
  41436. */
  41437. static ClearCoatTextureEnabled: boolean;
  41438. private static _ClearCoatBumpTextureEnabled;
  41439. /**
  41440. * Are clear coat bump textures enabled in the application.
  41441. */
  41442. static ClearCoatBumpTextureEnabled: boolean;
  41443. private static _ClearCoatTintTextureEnabled;
  41444. /**
  41445. * Are clear coat tint textures enabled in the application.
  41446. */
  41447. static ClearCoatTintTextureEnabled: boolean;
  41448. private static _SheenTextureEnabled;
  41449. /**
  41450. * Are sheen textures enabled in the application.
  41451. */
  41452. static SheenTextureEnabled: boolean;
  41453. private static _AnisotropicTextureEnabled;
  41454. /**
  41455. * Are anisotropic textures enabled in the application.
  41456. */
  41457. static AnisotropicTextureEnabled: boolean;
  41458. private static _ThicknessTextureEnabled;
  41459. /**
  41460. * Are thickness textures enabled in the application.
  41461. */
  41462. static ThicknessTextureEnabled: boolean;
  41463. }
  41464. }
  41465. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41466. /** @hidden */
  41467. export var defaultFragmentDeclaration: {
  41468. name: string;
  41469. shader: string;
  41470. };
  41471. }
  41472. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41473. /** @hidden */
  41474. export var defaultUboDeclaration: {
  41475. name: string;
  41476. shader: string;
  41477. };
  41478. }
  41479. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41480. /** @hidden */
  41481. export var lightFragmentDeclaration: {
  41482. name: string;
  41483. shader: string;
  41484. };
  41485. }
  41486. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41487. /** @hidden */
  41488. export var lightUboDeclaration: {
  41489. name: string;
  41490. shader: string;
  41491. };
  41492. }
  41493. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41494. /** @hidden */
  41495. export var lightsFragmentFunctions: {
  41496. name: string;
  41497. shader: string;
  41498. };
  41499. }
  41500. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41501. /** @hidden */
  41502. export var shadowsFragmentFunctions: {
  41503. name: string;
  41504. shader: string;
  41505. };
  41506. }
  41507. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41508. /** @hidden */
  41509. export var fresnelFunction: {
  41510. name: string;
  41511. shader: string;
  41512. };
  41513. }
  41514. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41515. /** @hidden */
  41516. export var reflectionFunction: {
  41517. name: string;
  41518. shader: string;
  41519. };
  41520. }
  41521. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41522. /** @hidden */
  41523. export var bumpFragmentFunctions: {
  41524. name: string;
  41525. shader: string;
  41526. };
  41527. }
  41528. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41529. /** @hidden */
  41530. export var logDepthDeclaration: {
  41531. name: string;
  41532. shader: string;
  41533. };
  41534. }
  41535. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41536. /** @hidden */
  41537. export var bumpFragment: {
  41538. name: string;
  41539. shader: string;
  41540. };
  41541. }
  41542. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41543. /** @hidden */
  41544. export var depthPrePass: {
  41545. name: string;
  41546. shader: string;
  41547. };
  41548. }
  41549. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41550. /** @hidden */
  41551. export var lightFragment: {
  41552. name: string;
  41553. shader: string;
  41554. };
  41555. }
  41556. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41557. /** @hidden */
  41558. export var logDepthFragment: {
  41559. name: string;
  41560. shader: string;
  41561. };
  41562. }
  41563. declare module "babylonjs/Shaders/default.fragment" {
  41564. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41565. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41567. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41568. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41569. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41570. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41571. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41572. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41573. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41574. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41575. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41576. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41577. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41578. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41579. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41580. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41581. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41582. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41583. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41584. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41585. /** @hidden */
  41586. export var defaultPixelShader: {
  41587. name: string;
  41588. shader: string;
  41589. };
  41590. }
  41591. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41592. /** @hidden */
  41593. export var defaultVertexDeclaration: {
  41594. name: string;
  41595. shader: string;
  41596. };
  41597. }
  41598. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41599. /** @hidden */
  41600. export var bumpVertexDeclaration: {
  41601. name: string;
  41602. shader: string;
  41603. };
  41604. }
  41605. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41606. /** @hidden */
  41607. export var bumpVertex: {
  41608. name: string;
  41609. shader: string;
  41610. };
  41611. }
  41612. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41613. /** @hidden */
  41614. export var fogVertex: {
  41615. name: string;
  41616. shader: string;
  41617. };
  41618. }
  41619. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41620. /** @hidden */
  41621. export var shadowsVertex: {
  41622. name: string;
  41623. shader: string;
  41624. };
  41625. }
  41626. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41627. /** @hidden */
  41628. export var pointCloudVertex: {
  41629. name: string;
  41630. shader: string;
  41631. };
  41632. }
  41633. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41634. /** @hidden */
  41635. export var logDepthVertex: {
  41636. name: string;
  41637. shader: string;
  41638. };
  41639. }
  41640. declare module "babylonjs/Shaders/default.vertex" {
  41641. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41642. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41643. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41644. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41645. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41646. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41647. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41648. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41649. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41650. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41653. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41654. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41655. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41656. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41657. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41658. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41659. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41660. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41661. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41662. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41663. /** @hidden */
  41664. export var defaultVertexShader: {
  41665. name: string;
  41666. shader: string;
  41667. };
  41668. }
  41669. declare module "babylonjs/Materials/standardMaterial" {
  41670. import { SmartArray } from "babylonjs/Misc/smartArray";
  41671. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41672. import { Nullable } from "babylonjs/types";
  41673. import { Scene } from "babylonjs/scene";
  41674. import { Matrix } from "babylonjs/Maths/math.vector";
  41675. import { Color3 } from "babylonjs/Maths/math.color";
  41676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41678. import { Mesh } from "babylonjs/Meshes/mesh";
  41679. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41680. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41681. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41683. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41686. import "babylonjs/Shaders/default.fragment";
  41687. import "babylonjs/Shaders/default.vertex";
  41688. /** @hidden */
  41689. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41690. MAINUV1: boolean;
  41691. MAINUV2: boolean;
  41692. DIFFUSE: boolean;
  41693. DIFFUSEDIRECTUV: number;
  41694. AMBIENT: boolean;
  41695. AMBIENTDIRECTUV: number;
  41696. OPACITY: boolean;
  41697. OPACITYDIRECTUV: number;
  41698. OPACITYRGB: boolean;
  41699. REFLECTION: boolean;
  41700. EMISSIVE: boolean;
  41701. EMISSIVEDIRECTUV: number;
  41702. SPECULAR: boolean;
  41703. SPECULARDIRECTUV: number;
  41704. BUMP: boolean;
  41705. BUMPDIRECTUV: number;
  41706. PARALLAX: boolean;
  41707. PARALLAXOCCLUSION: boolean;
  41708. SPECULAROVERALPHA: boolean;
  41709. CLIPPLANE: boolean;
  41710. CLIPPLANE2: boolean;
  41711. CLIPPLANE3: boolean;
  41712. CLIPPLANE4: boolean;
  41713. ALPHATEST: boolean;
  41714. DEPTHPREPASS: boolean;
  41715. ALPHAFROMDIFFUSE: boolean;
  41716. POINTSIZE: boolean;
  41717. FOG: boolean;
  41718. SPECULARTERM: boolean;
  41719. DIFFUSEFRESNEL: boolean;
  41720. OPACITYFRESNEL: boolean;
  41721. REFLECTIONFRESNEL: boolean;
  41722. REFRACTIONFRESNEL: boolean;
  41723. EMISSIVEFRESNEL: boolean;
  41724. FRESNEL: boolean;
  41725. NORMAL: boolean;
  41726. UV1: boolean;
  41727. UV2: boolean;
  41728. VERTEXCOLOR: boolean;
  41729. VERTEXALPHA: boolean;
  41730. NUM_BONE_INFLUENCERS: number;
  41731. BonesPerMesh: number;
  41732. BONETEXTURE: boolean;
  41733. INSTANCES: boolean;
  41734. GLOSSINESS: boolean;
  41735. ROUGHNESS: boolean;
  41736. EMISSIVEASILLUMINATION: boolean;
  41737. LINKEMISSIVEWITHDIFFUSE: boolean;
  41738. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41739. LIGHTMAP: boolean;
  41740. LIGHTMAPDIRECTUV: number;
  41741. OBJECTSPACE_NORMALMAP: boolean;
  41742. USELIGHTMAPASSHADOWMAP: boolean;
  41743. REFLECTIONMAP_3D: boolean;
  41744. REFLECTIONMAP_SPHERICAL: boolean;
  41745. REFLECTIONMAP_PLANAR: boolean;
  41746. REFLECTIONMAP_CUBIC: boolean;
  41747. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41748. REFLECTIONMAP_PROJECTION: boolean;
  41749. REFLECTIONMAP_SKYBOX: boolean;
  41750. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41751. REFLECTIONMAP_EXPLICIT: boolean;
  41752. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41753. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41754. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41755. INVERTCUBICMAP: boolean;
  41756. LOGARITHMICDEPTH: boolean;
  41757. REFRACTION: boolean;
  41758. REFRACTIONMAP_3D: boolean;
  41759. REFLECTIONOVERALPHA: boolean;
  41760. TWOSIDEDLIGHTING: boolean;
  41761. SHADOWFLOAT: boolean;
  41762. MORPHTARGETS: boolean;
  41763. MORPHTARGETS_NORMAL: boolean;
  41764. MORPHTARGETS_TANGENT: boolean;
  41765. MORPHTARGETS_UV: boolean;
  41766. NUM_MORPH_INFLUENCERS: number;
  41767. NONUNIFORMSCALING: boolean;
  41768. PREMULTIPLYALPHA: boolean;
  41769. IMAGEPROCESSING: boolean;
  41770. VIGNETTE: boolean;
  41771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41772. VIGNETTEBLENDMODEOPAQUE: boolean;
  41773. TONEMAPPING: boolean;
  41774. TONEMAPPING_ACES: boolean;
  41775. CONTRAST: boolean;
  41776. COLORCURVES: boolean;
  41777. COLORGRADING: boolean;
  41778. COLORGRADING3D: boolean;
  41779. SAMPLER3DGREENDEPTH: boolean;
  41780. SAMPLER3DBGRMAP: boolean;
  41781. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41782. MULTIVIEW: boolean;
  41783. /**
  41784. * If the reflection texture on this material is in linear color space
  41785. * @hidden
  41786. */
  41787. IS_REFLECTION_LINEAR: boolean;
  41788. /**
  41789. * If the refraction texture on this material is in linear color space
  41790. * @hidden
  41791. */
  41792. IS_REFRACTION_LINEAR: boolean;
  41793. EXPOSURE: boolean;
  41794. constructor();
  41795. setReflectionMode(modeToEnable: string): void;
  41796. }
  41797. /**
  41798. * This is the default material used in Babylon. It is the best trade off between quality
  41799. * and performances.
  41800. * @see http://doc.babylonjs.com/babylon101/materials
  41801. */
  41802. export class StandardMaterial extends PushMaterial {
  41803. private _diffuseTexture;
  41804. /**
  41805. * The basic texture of the material as viewed under a light.
  41806. */
  41807. diffuseTexture: Nullable<BaseTexture>;
  41808. private _ambientTexture;
  41809. /**
  41810. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41811. */
  41812. ambientTexture: Nullable<BaseTexture>;
  41813. private _opacityTexture;
  41814. /**
  41815. * Define the transparency of the material from a texture.
  41816. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41817. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41818. */
  41819. opacityTexture: Nullable<BaseTexture>;
  41820. private _reflectionTexture;
  41821. /**
  41822. * Define the texture used to display the reflection.
  41823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41824. */
  41825. reflectionTexture: Nullable<BaseTexture>;
  41826. private _emissiveTexture;
  41827. /**
  41828. * Define texture of the material as if self lit.
  41829. * This will be mixed in the final result even in the absence of light.
  41830. */
  41831. emissiveTexture: Nullable<BaseTexture>;
  41832. private _specularTexture;
  41833. /**
  41834. * Define how the color and intensity of the highlight given by the light in the material.
  41835. */
  41836. specularTexture: Nullable<BaseTexture>;
  41837. private _bumpTexture;
  41838. /**
  41839. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41840. * 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.
  41841. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41842. */
  41843. bumpTexture: Nullable<BaseTexture>;
  41844. private _lightmapTexture;
  41845. /**
  41846. * Complex lighting can be computationally expensive to compute at runtime.
  41847. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41848. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41849. */
  41850. lightmapTexture: Nullable<BaseTexture>;
  41851. private _refractionTexture;
  41852. /**
  41853. * Define the texture used to display the refraction.
  41854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41855. */
  41856. refractionTexture: Nullable<BaseTexture>;
  41857. /**
  41858. * The color of the material lit by the environmental background lighting.
  41859. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41860. */
  41861. ambientColor: Color3;
  41862. /**
  41863. * The basic color of the material as viewed under a light.
  41864. */
  41865. diffuseColor: Color3;
  41866. /**
  41867. * Define how the color and intensity of the highlight given by the light in the material.
  41868. */
  41869. specularColor: Color3;
  41870. /**
  41871. * Define the color of the material as if self lit.
  41872. * This will be mixed in the final result even in the absence of light.
  41873. */
  41874. emissiveColor: Color3;
  41875. /**
  41876. * Defines how sharp are the highlights in the material.
  41877. * The bigger the value the sharper giving a more glossy feeling to the result.
  41878. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41879. */
  41880. specularPower: number;
  41881. private _useAlphaFromDiffuseTexture;
  41882. /**
  41883. * Does the transparency come from the diffuse texture alpha channel.
  41884. */
  41885. useAlphaFromDiffuseTexture: boolean;
  41886. private _useEmissiveAsIllumination;
  41887. /**
  41888. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41889. */
  41890. useEmissiveAsIllumination: boolean;
  41891. private _linkEmissiveWithDiffuse;
  41892. /**
  41893. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41894. * the emissive level when the final color is close to one.
  41895. */
  41896. linkEmissiveWithDiffuse: boolean;
  41897. private _useSpecularOverAlpha;
  41898. /**
  41899. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41900. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41901. */
  41902. useSpecularOverAlpha: boolean;
  41903. private _useReflectionOverAlpha;
  41904. /**
  41905. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41906. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41907. */
  41908. useReflectionOverAlpha: boolean;
  41909. private _disableLighting;
  41910. /**
  41911. * Does lights from the scene impacts this material.
  41912. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41913. */
  41914. disableLighting: boolean;
  41915. private _useObjectSpaceNormalMap;
  41916. /**
  41917. * Allows using an object space normal map (instead of tangent space).
  41918. */
  41919. useObjectSpaceNormalMap: boolean;
  41920. private _useParallax;
  41921. /**
  41922. * Is parallax enabled or not.
  41923. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41924. */
  41925. useParallax: boolean;
  41926. private _useParallaxOcclusion;
  41927. /**
  41928. * Is parallax occlusion enabled or not.
  41929. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41930. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41931. */
  41932. useParallaxOcclusion: boolean;
  41933. /**
  41934. * 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.
  41935. */
  41936. parallaxScaleBias: number;
  41937. private _roughness;
  41938. /**
  41939. * Helps to define how blurry the reflections should appears in the material.
  41940. */
  41941. roughness: number;
  41942. /**
  41943. * In case of refraction, define the value of the index of refraction.
  41944. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41945. */
  41946. indexOfRefraction: number;
  41947. /**
  41948. * Invert the refraction texture alongside the y axis.
  41949. * It can be useful with procedural textures or probe for instance.
  41950. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41951. */
  41952. invertRefractionY: boolean;
  41953. /**
  41954. * Defines the alpha limits in alpha test mode.
  41955. */
  41956. alphaCutOff: number;
  41957. private _useLightmapAsShadowmap;
  41958. /**
  41959. * In case of light mapping, define whether the map contains light or shadow informations.
  41960. */
  41961. useLightmapAsShadowmap: boolean;
  41962. private _diffuseFresnelParameters;
  41963. /**
  41964. * Define the diffuse fresnel parameters of the material.
  41965. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41966. */
  41967. diffuseFresnelParameters: FresnelParameters;
  41968. private _opacityFresnelParameters;
  41969. /**
  41970. * Define the opacity fresnel parameters of the material.
  41971. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41972. */
  41973. opacityFresnelParameters: FresnelParameters;
  41974. private _reflectionFresnelParameters;
  41975. /**
  41976. * Define the reflection fresnel parameters of the material.
  41977. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41978. */
  41979. reflectionFresnelParameters: FresnelParameters;
  41980. private _refractionFresnelParameters;
  41981. /**
  41982. * Define the refraction fresnel parameters of the material.
  41983. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41984. */
  41985. refractionFresnelParameters: FresnelParameters;
  41986. private _emissiveFresnelParameters;
  41987. /**
  41988. * Define the emissive fresnel parameters of the material.
  41989. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41990. */
  41991. emissiveFresnelParameters: FresnelParameters;
  41992. private _useReflectionFresnelFromSpecular;
  41993. /**
  41994. * If true automatically deducts the fresnels values from the material specularity.
  41995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41996. */
  41997. useReflectionFresnelFromSpecular: boolean;
  41998. private _useGlossinessFromSpecularMapAlpha;
  41999. /**
  42000. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42001. */
  42002. useGlossinessFromSpecularMapAlpha: boolean;
  42003. private _maxSimultaneousLights;
  42004. /**
  42005. * Defines the maximum number of lights that can be used in the material
  42006. */
  42007. maxSimultaneousLights: number;
  42008. private _invertNormalMapX;
  42009. /**
  42010. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42011. */
  42012. invertNormalMapX: boolean;
  42013. private _invertNormalMapY;
  42014. /**
  42015. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42016. */
  42017. invertNormalMapY: boolean;
  42018. private _twoSidedLighting;
  42019. /**
  42020. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42021. */
  42022. twoSidedLighting: boolean;
  42023. /**
  42024. * Default configuration related to image processing available in the standard Material.
  42025. */
  42026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42027. /**
  42028. * Gets the image processing configuration used either in this material.
  42029. */
  42030. /**
  42031. * Sets the Default image processing configuration used either in the this material.
  42032. *
  42033. * If sets to null, the scene one is in use.
  42034. */
  42035. imageProcessingConfiguration: ImageProcessingConfiguration;
  42036. /**
  42037. * Keep track of the image processing observer to allow dispose and replace.
  42038. */
  42039. private _imageProcessingObserver;
  42040. /**
  42041. * Attaches a new image processing configuration to the Standard Material.
  42042. * @param configuration
  42043. */
  42044. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42045. /**
  42046. * Gets wether the color curves effect is enabled.
  42047. */
  42048. /**
  42049. * Sets wether the color curves effect is enabled.
  42050. */
  42051. cameraColorCurvesEnabled: boolean;
  42052. /**
  42053. * Gets wether the color grading effect is enabled.
  42054. */
  42055. /**
  42056. * Gets wether the color grading effect is enabled.
  42057. */
  42058. cameraColorGradingEnabled: boolean;
  42059. /**
  42060. * Gets wether tonemapping is enabled or not.
  42061. */
  42062. /**
  42063. * Sets wether tonemapping is enabled or not
  42064. */
  42065. cameraToneMappingEnabled: boolean;
  42066. /**
  42067. * The camera exposure used on this material.
  42068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42069. * This corresponds to a photographic exposure.
  42070. */
  42071. /**
  42072. * The camera exposure used on this material.
  42073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42074. * This corresponds to a photographic exposure.
  42075. */
  42076. cameraExposure: number;
  42077. /**
  42078. * Gets The camera contrast used on this material.
  42079. */
  42080. /**
  42081. * Sets The camera contrast used on this material.
  42082. */
  42083. cameraContrast: number;
  42084. /**
  42085. * Gets the Color Grading 2D Lookup Texture.
  42086. */
  42087. /**
  42088. * Sets the Color Grading 2D Lookup Texture.
  42089. */
  42090. cameraColorGradingTexture: Nullable<BaseTexture>;
  42091. /**
  42092. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42093. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42094. * 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;
  42095. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42096. */
  42097. /**
  42098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42100. * 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;
  42101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42102. */
  42103. cameraColorCurves: Nullable<ColorCurves>;
  42104. /**
  42105. * Custom callback helping to override the default shader used in the material.
  42106. */
  42107. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42108. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42109. protected _worldViewProjectionMatrix: Matrix;
  42110. protected _globalAmbientColor: Color3;
  42111. protected _useLogarithmicDepth: boolean;
  42112. protected _rebuildInParallel: boolean;
  42113. /**
  42114. * Instantiates a new standard material.
  42115. * This is the default material used in Babylon. It is the best trade off between quality
  42116. * and performances.
  42117. * @see http://doc.babylonjs.com/babylon101/materials
  42118. * @param name Define the name of the material in the scene
  42119. * @param scene Define the scene the material belong to
  42120. */
  42121. constructor(name: string, scene: Scene);
  42122. /**
  42123. * Gets a boolean indicating that current material needs to register RTT
  42124. */
  42125. readonly hasRenderTargetTextures: boolean;
  42126. /**
  42127. * Gets the current class name of the material e.g. "StandardMaterial"
  42128. * Mainly use in serialization.
  42129. * @returns the class name
  42130. */
  42131. getClassName(): string;
  42132. /**
  42133. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42134. * You can try switching to logarithmic depth.
  42135. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42136. */
  42137. useLogarithmicDepth: boolean;
  42138. /**
  42139. * Specifies if the material will require alpha blending
  42140. * @returns a boolean specifying if alpha blending is needed
  42141. */
  42142. needAlphaBlending(): boolean;
  42143. /**
  42144. * Specifies if this material should be rendered in alpha test mode
  42145. * @returns a boolean specifying if an alpha test is needed.
  42146. */
  42147. needAlphaTesting(): boolean;
  42148. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42149. /**
  42150. * Get the texture used for alpha test purpose.
  42151. * @returns the diffuse texture in case of the standard material.
  42152. */
  42153. getAlphaTestTexture(): Nullable<BaseTexture>;
  42154. /**
  42155. * Get if the submesh is ready to be used and all its information available.
  42156. * Child classes can use it to update shaders
  42157. * @param mesh defines the mesh to check
  42158. * @param subMesh defines which submesh to check
  42159. * @param useInstances specifies that instances should be used
  42160. * @returns a boolean indicating that the submesh is ready or not
  42161. */
  42162. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42163. /**
  42164. * Builds the material UBO layouts.
  42165. * Used internally during the effect preparation.
  42166. */
  42167. buildUniformLayout(): void;
  42168. /**
  42169. * Unbinds the material from the mesh
  42170. */
  42171. unbind(): void;
  42172. /**
  42173. * Binds the submesh to this material by preparing the effect and shader to draw
  42174. * @param world defines the world transformation matrix
  42175. * @param mesh defines the mesh containing the submesh
  42176. * @param subMesh defines the submesh to bind the material to
  42177. */
  42178. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42179. /**
  42180. * Get the list of animatables in the material.
  42181. * @returns the list of animatables object used in the material
  42182. */
  42183. getAnimatables(): IAnimatable[];
  42184. /**
  42185. * Gets the active textures from the material
  42186. * @returns an array of textures
  42187. */
  42188. getActiveTextures(): BaseTexture[];
  42189. /**
  42190. * Specifies if the material uses a texture
  42191. * @param texture defines the texture to check against the material
  42192. * @returns a boolean specifying if the material uses the texture
  42193. */
  42194. hasTexture(texture: BaseTexture): boolean;
  42195. /**
  42196. * Disposes the material
  42197. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42198. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42199. */
  42200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42201. /**
  42202. * Makes a duplicate of the material, and gives it a new name
  42203. * @param name defines the new name for the duplicated material
  42204. * @returns the cloned material
  42205. */
  42206. clone(name: string): StandardMaterial;
  42207. /**
  42208. * Serializes this material in a JSON representation
  42209. * @returns the serialized material object
  42210. */
  42211. serialize(): any;
  42212. /**
  42213. * Creates a standard material from parsed material data
  42214. * @param source defines the JSON representation of the material
  42215. * @param scene defines the hosting scene
  42216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42217. * @returns a new standard material
  42218. */
  42219. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42220. /**
  42221. * Are diffuse textures enabled in the application.
  42222. */
  42223. static DiffuseTextureEnabled: boolean;
  42224. /**
  42225. * Are ambient textures enabled in the application.
  42226. */
  42227. static AmbientTextureEnabled: boolean;
  42228. /**
  42229. * Are opacity textures enabled in the application.
  42230. */
  42231. static OpacityTextureEnabled: boolean;
  42232. /**
  42233. * Are reflection textures enabled in the application.
  42234. */
  42235. static ReflectionTextureEnabled: boolean;
  42236. /**
  42237. * Are emissive textures enabled in the application.
  42238. */
  42239. static EmissiveTextureEnabled: boolean;
  42240. /**
  42241. * Are specular textures enabled in the application.
  42242. */
  42243. static SpecularTextureEnabled: boolean;
  42244. /**
  42245. * Are bump textures enabled in the application.
  42246. */
  42247. static BumpTextureEnabled: boolean;
  42248. /**
  42249. * Are lightmap textures enabled in the application.
  42250. */
  42251. static LightmapTextureEnabled: boolean;
  42252. /**
  42253. * Are refraction textures enabled in the application.
  42254. */
  42255. static RefractionTextureEnabled: boolean;
  42256. /**
  42257. * Are color grading textures enabled in the application.
  42258. */
  42259. static ColorGradingTextureEnabled: boolean;
  42260. /**
  42261. * Are fresnels enabled in the application.
  42262. */
  42263. static FresnelEnabled: boolean;
  42264. }
  42265. }
  42266. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42267. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42269. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42270. /** @hidden */
  42271. export var imageProcessingPixelShader: {
  42272. name: string;
  42273. shader: string;
  42274. };
  42275. }
  42276. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42277. import { Nullable } from "babylonjs/types";
  42278. import { Color4 } from "babylonjs/Maths/math.color";
  42279. import { Camera } from "babylonjs/Cameras/camera";
  42280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42281. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42282. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42284. import { Engine } from "babylonjs/Engines/engine";
  42285. import "babylonjs/Shaders/imageProcessing.fragment";
  42286. import "babylonjs/Shaders/postprocess.vertex";
  42287. /**
  42288. * ImageProcessingPostProcess
  42289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42290. */
  42291. export class ImageProcessingPostProcess extends PostProcess {
  42292. /**
  42293. * Default configuration related to image processing available in the PBR Material.
  42294. */
  42295. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42296. /**
  42297. * Gets the image processing configuration used either in this material.
  42298. */
  42299. /**
  42300. * Sets the Default image processing configuration used either in the this material.
  42301. *
  42302. * If sets to null, the scene one is in use.
  42303. */
  42304. imageProcessingConfiguration: ImageProcessingConfiguration;
  42305. /**
  42306. * Keep track of the image processing observer to allow dispose and replace.
  42307. */
  42308. private _imageProcessingObserver;
  42309. /**
  42310. * Attaches a new image processing configuration to the PBR Material.
  42311. * @param configuration
  42312. */
  42313. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42314. /**
  42315. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42316. */
  42317. /**
  42318. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42319. */
  42320. colorCurves: Nullable<ColorCurves>;
  42321. /**
  42322. * Gets wether the color curves effect is enabled.
  42323. */
  42324. /**
  42325. * Sets wether the color curves effect is enabled.
  42326. */
  42327. colorCurvesEnabled: boolean;
  42328. /**
  42329. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42330. */
  42331. /**
  42332. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42333. */
  42334. colorGradingTexture: Nullable<BaseTexture>;
  42335. /**
  42336. * Gets wether the color grading effect is enabled.
  42337. */
  42338. /**
  42339. * Gets wether the color grading effect is enabled.
  42340. */
  42341. colorGradingEnabled: boolean;
  42342. /**
  42343. * Gets exposure used in the effect.
  42344. */
  42345. /**
  42346. * Sets exposure used in the effect.
  42347. */
  42348. exposure: number;
  42349. /**
  42350. * Gets wether tonemapping is enabled or not.
  42351. */
  42352. /**
  42353. * Sets wether tonemapping is enabled or not
  42354. */
  42355. toneMappingEnabled: boolean;
  42356. /**
  42357. * Gets the type of tone mapping effect.
  42358. */
  42359. /**
  42360. * Sets the type of tone mapping effect.
  42361. */
  42362. toneMappingType: number;
  42363. /**
  42364. * Gets contrast used in the effect.
  42365. */
  42366. /**
  42367. * Sets contrast used in the effect.
  42368. */
  42369. contrast: number;
  42370. /**
  42371. * Gets Vignette stretch size.
  42372. */
  42373. /**
  42374. * Sets Vignette stretch size.
  42375. */
  42376. vignetteStretch: number;
  42377. /**
  42378. * Gets Vignette centre X Offset.
  42379. */
  42380. /**
  42381. * Sets Vignette centre X Offset.
  42382. */
  42383. vignetteCentreX: number;
  42384. /**
  42385. * Gets Vignette centre Y Offset.
  42386. */
  42387. /**
  42388. * Sets Vignette centre Y Offset.
  42389. */
  42390. vignetteCentreY: number;
  42391. /**
  42392. * Gets Vignette weight or intensity of the vignette effect.
  42393. */
  42394. /**
  42395. * Sets Vignette weight or intensity of the vignette effect.
  42396. */
  42397. vignetteWeight: number;
  42398. /**
  42399. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42400. * if vignetteEnabled is set to true.
  42401. */
  42402. /**
  42403. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42404. * if vignetteEnabled is set to true.
  42405. */
  42406. vignetteColor: Color4;
  42407. /**
  42408. * Gets Camera field of view used by the Vignette effect.
  42409. */
  42410. /**
  42411. * Sets Camera field of view used by the Vignette effect.
  42412. */
  42413. vignetteCameraFov: number;
  42414. /**
  42415. * Gets the vignette blend mode allowing different kind of effect.
  42416. */
  42417. /**
  42418. * Sets the vignette blend mode allowing different kind of effect.
  42419. */
  42420. vignetteBlendMode: number;
  42421. /**
  42422. * Gets wether the vignette effect is enabled.
  42423. */
  42424. /**
  42425. * Sets wether the vignette effect is enabled.
  42426. */
  42427. vignetteEnabled: boolean;
  42428. private _fromLinearSpace;
  42429. /**
  42430. * Gets wether the input of the processing is in Gamma or Linear Space.
  42431. */
  42432. /**
  42433. * Sets wether the input of the processing is in Gamma or Linear Space.
  42434. */
  42435. fromLinearSpace: boolean;
  42436. /**
  42437. * Defines cache preventing GC.
  42438. */
  42439. private _defines;
  42440. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42441. /**
  42442. * "ImageProcessingPostProcess"
  42443. * @returns "ImageProcessingPostProcess"
  42444. */
  42445. getClassName(): string;
  42446. protected _updateParameters(): void;
  42447. dispose(camera?: Camera): void;
  42448. }
  42449. }
  42450. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42451. import { Scene } from "babylonjs/scene";
  42452. import { Color3 } from "babylonjs/Maths/math.color";
  42453. import { Mesh } from "babylonjs/Meshes/mesh";
  42454. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42455. import { Nullable } from "babylonjs/types";
  42456. /**
  42457. * Class containing static functions to help procedurally build meshes
  42458. */
  42459. export class GroundBuilder {
  42460. /**
  42461. * Creates a ground mesh
  42462. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42463. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42465. * @param name defines the name of the mesh
  42466. * @param options defines the options used to create the mesh
  42467. * @param scene defines the hosting scene
  42468. * @returns the ground mesh
  42469. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42470. */
  42471. static CreateGround(name: string, options: {
  42472. width?: number;
  42473. height?: number;
  42474. subdivisions?: number;
  42475. subdivisionsX?: number;
  42476. subdivisionsY?: number;
  42477. updatable?: boolean;
  42478. }, scene: any): Mesh;
  42479. /**
  42480. * Creates a tiled ground mesh
  42481. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42482. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42483. * * 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
  42484. * * 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
  42485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42486. * @param name defines the name of the mesh
  42487. * @param options defines the options used to create the mesh
  42488. * @param scene defines the hosting scene
  42489. * @returns the tiled ground mesh
  42490. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42491. */
  42492. static CreateTiledGround(name: string, options: {
  42493. xmin: number;
  42494. zmin: number;
  42495. xmax: number;
  42496. zmax: number;
  42497. subdivisions?: {
  42498. w: number;
  42499. h: number;
  42500. };
  42501. precision?: {
  42502. w: number;
  42503. h: number;
  42504. };
  42505. updatable?: boolean;
  42506. }, scene?: Nullable<Scene>): Mesh;
  42507. /**
  42508. * Creates a ground mesh from a height map
  42509. * * The parameter `url` sets the URL of the height map image resource.
  42510. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42511. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42512. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42513. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42514. * * 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.
  42515. * * 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).
  42516. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42518. * @param name defines the name of the mesh
  42519. * @param url defines the url to the height map
  42520. * @param options defines the options used to create the mesh
  42521. * @param scene defines the hosting scene
  42522. * @returns the ground mesh
  42523. * @see https://doc.babylonjs.com/babylon101/height_map
  42524. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42525. */
  42526. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42527. width?: number;
  42528. height?: number;
  42529. subdivisions?: number;
  42530. minHeight?: number;
  42531. maxHeight?: number;
  42532. colorFilter?: Color3;
  42533. alphaFilter?: number;
  42534. updatable?: boolean;
  42535. onReady?: (mesh: GroundMesh) => void;
  42536. }, scene?: Nullable<Scene>): GroundMesh;
  42537. }
  42538. }
  42539. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42540. import { Vector4 } from "babylonjs/Maths/math.vector";
  42541. import { Mesh } from "babylonjs/Meshes/mesh";
  42542. /**
  42543. * Class containing static functions to help procedurally build meshes
  42544. */
  42545. export class TorusBuilder {
  42546. /**
  42547. * Creates a torus mesh
  42548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42554. * @param name defines the name of the mesh
  42555. * @param options defines the options used to create the mesh
  42556. * @param scene defines the hosting scene
  42557. * @returns the torus mesh
  42558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42559. */
  42560. static CreateTorus(name: string, options: {
  42561. diameter?: number;
  42562. thickness?: number;
  42563. tessellation?: number;
  42564. updatable?: boolean;
  42565. sideOrientation?: number;
  42566. frontUVs?: Vector4;
  42567. backUVs?: Vector4;
  42568. }, scene: any): Mesh;
  42569. }
  42570. }
  42571. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42572. import { Vector4 } from "babylonjs/Maths/math.vector";
  42573. import { Color4 } from "babylonjs/Maths/math.color";
  42574. import { Mesh } from "babylonjs/Meshes/mesh";
  42575. /**
  42576. * Class containing static functions to help procedurally build meshes
  42577. */
  42578. export class CylinderBuilder {
  42579. /**
  42580. * Creates a cylinder or a cone mesh
  42581. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42582. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42583. * * 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.
  42584. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42585. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42586. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42587. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42588. * * 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).
  42589. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42590. * * 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).
  42591. * * 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
  42592. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42593. * * 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
  42594. * * 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.
  42595. * * If `enclose` is false, a ring surface is one element.
  42596. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42597. * * 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
  42598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42601. * @param name defines the name of the mesh
  42602. * @param options defines the options used to create the mesh
  42603. * @param scene defines the hosting scene
  42604. * @returns the cylinder mesh
  42605. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42606. */
  42607. static CreateCylinder(name: string, options: {
  42608. height?: number;
  42609. diameterTop?: number;
  42610. diameterBottom?: number;
  42611. diameter?: number;
  42612. tessellation?: number;
  42613. subdivisions?: number;
  42614. arc?: number;
  42615. faceColors?: Color4[];
  42616. faceUV?: Vector4[];
  42617. updatable?: boolean;
  42618. hasRings?: boolean;
  42619. enclose?: boolean;
  42620. cap?: number;
  42621. sideOrientation?: number;
  42622. frontUVs?: Vector4;
  42623. backUVs?: Vector4;
  42624. }, scene: any): Mesh;
  42625. }
  42626. }
  42627. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42628. import { Observable } from "babylonjs/Misc/observable";
  42629. import { Nullable } from "babylonjs/types";
  42630. import { Camera } from "babylonjs/Cameras/camera";
  42631. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42632. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42633. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42634. import { Scene } from "babylonjs/scene";
  42635. import { Vector3 } from "babylonjs/Maths/math.vector";
  42636. import { Color3 } from "babylonjs/Maths/math.color";
  42637. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42639. import { Mesh } from "babylonjs/Meshes/mesh";
  42640. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42641. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42642. import "babylonjs/Meshes/Builders/groundBuilder";
  42643. import "babylonjs/Meshes/Builders/torusBuilder";
  42644. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42645. import "babylonjs/Gamepads/gamepadSceneComponent";
  42646. import "babylonjs/Animations/animatable";
  42647. /**
  42648. * Options to modify the vr teleportation behavior.
  42649. */
  42650. export interface VRTeleportationOptions {
  42651. /**
  42652. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42653. */
  42654. floorMeshName?: string;
  42655. /**
  42656. * A list of meshes to be used as the teleportation floor. (default: empty)
  42657. */
  42658. floorMeshes?: Mesh[];
  42659. }
  42660. /**
  42661. * Options to modify the vr experience helper's behavior.
  42662. */
  42663. export interface VRExperienceHelperOptions extends WebVROptions {
  42664. /**
  42665. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42666. */
  42667. createDeviceOrientationCamera?: boolean;
  42668. /**
  42669. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42670. */
  42671. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42672. /**
  42673. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42674. */
  42675. laserToggle?: boolean;
  42676. /**
  42677. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42678. */
  42679. floorMeshes?: Mesh[];
  42680. /**
  42681. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42682. */
  42683. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42684. }
  42685. /**
  42686. * Event containing information after VR has been entered
  42687. */
  42688. export class OnAfterEnteringVRObservableEvent {
  42689. /**
  42690. * If entering vr was successful
  42691. */
  42692. success: boolean;
  42693. }
  42694. /**
  42695. * Helps to quickly add VR support to an existing scene.
  42696. * See http://doc.babylonjs.com/how_to/webvr_helper
  42697. */
  42698. export class VRExperienceHelper {
  42699. /** Options to modify the vr experience helper's behavior. */
  42700. webVROptions: VRExperienceHelperOptions;
  42701. private _scene;
  42702. private _position;
  42703. private _btnVR;
  42704. private _btnVRDisplayed;
  42705. private _webVRsupported;
  42706. private _webVRready;
  42707. private _webVRrequesting;
  42708. private _webVRpresenting;
  42709. private _hasEnteredVR;
  42710. private _fullscreenVRpresenting;
  42711. private _inputElement;
  42712. private _webVRCamera;
  42713. private _vrDeviceOrientationCamera;
  42714. private _deviceOrientationCamera;
  42715. private _existingCamera;
  42716. private _onKeyDown;
  42717. private _onVrDisplayPresentChange;
  42718. private _onVRDisplayChanged;
  42719. private _onVRRequestPresentStart;
  42720. private _onVRRequestPresentComplete;
  42721. /**
  42722. * 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)
  42723. */
  42724. enableGazeEvenWhenNoPointerLock: boolean;
  42725. /**
  42726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42727. */
  42728. exitVROnDoubleTap: boolean;
  42729. /**
  42730. * Observable raised right before entering VR.
  42731. */
  42732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42733. /**
  42734. * Observable raised when entering VR has completed.
  42735. */
  42736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42737. /**
  42738. * Observable raised when exiting VR.
  42739. */
  42740. onExitingVRObservable: Observable<VRExperienceHelper>;
  42741. /**
  42742. * Observable raised when controller mesh is loaded.
  42743. */
  42744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42745. /** Return this.onEnteringVRObservable
  42746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42747. */
  42748. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42749. /** Return this.onExitingVRObservable
  42750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42751. */
  42752. readonly onExitingVR: Observable<VRExperienceHelper>;
  42753. /** Return this.onControllerMeshLoadedObservable
  42754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42755. */
  42756. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42757. private _rayLength;
  42758. private _useCustomVRButton;
  42759. private _teleportationRequested;
  42760. private _teleportActive;
  42761. private _floorMeshName;
  42762. private _floorMeshesCollection;
  42763. private _rotationAllowed;
  42764. private _teleportBackwardsVector;
  42765. private _teleportationTarget;
  42766. private _isDefaultTeleportationTarget;
  42767. private _postProcessMove;
  42768. private _teleportationFillColor;
  42769. private _teleportationBorderColor;
  42770. private _rotationAngle;
  42771. private _haloCenter;
  42772. private _cameraGazer;
  42773. private _padSensibilityUp;
  42774. private _padSensibilityDown;
  42775. private _leftController;
  42776. private _rightController;
  42777. /**
  42778. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42779. */
  42780. onNewMeshSelected: Observable<AbstractMesh>;
  42781. /**
  42782. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42783. * This observable will provide the mesh and the controller used to select the mesh
  42784. */
  42785. onMeshSelectedWithController: Observable<{
  42786. mesh: AbstractMesh;
  42787. controller: WebVRController;
  42788. }>;
  42789. /**
  42790. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42791. */
  42792. onNewMeshPicked: Observable<PickingInfo>;
  42793. private _circleEase;
  42794. /**
  42795. * Observable raised before camera teleportation
  42796. */
  42797. onBeforeCameraTeleport: Observable<Vector3>;
  42798. /**
  42799. * Observable raised after camera teleportation
  42800. */
  42801. onAfterCameraTeleport: Observable<Vector3>;
  42802. /**
  42803. * Observable raised when current selected mesh gets unselected
  42804. */
  42805. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42806. private _raySelectionPredicate;
  42807. /**
  42808. * To be optionaly changed by user to define custom ray selection
  42809. */
  42810. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42811. /**
  42812. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42813. */
  42814. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42815. /**
  42816. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42817. */
  42818. teleportationEnabled: boolean;
  42819. private _defaultHeight;
  42820. private _teleportationInitialized;
  42821. private _interactionsEnabled;
  42822. private _interactionsRequested;
  42823. private _displayGaze;
  42824. private _displayLaserPointer;
  42825. /**
  42826. * The mesh used to display where the user is going to teleport.
  42827. */
  42828. /**
  42829. * Sets the mesh to be used to display where the user is going to teleport.
  42830. */
  42831. teleportationTarget: Mesh;
  42832. /**
  42833. * 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
  42834. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42835. * See http://doc.babylonjs.com/resources/baking_transformations
  42836. */
  42837. gazeTrackerMesh: Mesh;
  42838. /**
  42839. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42840. */
  42841. updateGazeTrackerScale: boolean;
  42842. /**
  42843. * If the gaze trackers color should be updated when selecting meshes
  42844. */
  42845. updateGazeTrackerColor: boolean;
  42846. /**
  42847. * If the controller laser color should be updated when selecting meshes
  42848. */
  42849. updateControllerLaserColor: boolean;
  42850. /**
  42851. * The gaze tracking mesh corresponding to the left controller
  42852. */
  42853. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42854. /**
  42855. * The gaze tracking mesh corresponding to the right controller
  42856. */
  42857. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42858. /**
  42859. * If the ray of the gaze should be displayed.
  42860. */
  42861. /**
  42862. * Sets if the ray of the gaze should be displayed.
  42863. */
  42864. displayGaze: boolean;
  42865. /**
  42866. * If the ray of the LaserPointer should be displayed.
  42867. */
  42868. /**
  42869. * Sets if the ray of the LaserPointer should be displayed.
  42870. */
  42871. displayLaserPointer: boolean;
  42872. /**
  42873. * The deviceOrientationCamera used as the camera when not in VR.
  42874. */
  42875. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42876. /**
  42877. * Based on the current WebVR support, returns the current VR camera used.
  42878. */
  42879. readonly currentVRCamera: Nullable<Camera>;
  42880. /**
  42881. * The webVRCamera which is used when in VR.
  42882. */
  42883. readonly webVRCamera: WebVRFreeCamera;
  42884. /**
  42885. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42886. */
  42887. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42888. /**
  42889. * The html button that is used to trigger entering into VR.
  42890. */
  42891. readonly vrButton: Nullable<HTMLButtonElement>;
  42892. private readonly _teleportationRequestInitiated;
  42893. /**
  42894. * Defines wether or not Pointer lock should be requested when switching to
  42895. * full screen.
  42896. */
  42897. requestPointerLockOnFullScreen: boolean;
  42898. /**
  42899. * Instantiates a VRExperienceHelper.
  42900. * Helps to quickly add VR support to an existing scene.
  42901. * @param scene The scene the VRExperienceHelper belongs to.
  42902. * @param webVROptions Options to modify the vr experience helper's behavior.
  42903. */
  42904. constructor(scene: Scene,
  42905. /** Options to modify the vr experience helper's behavior. */
  42906. webVROptions?: VRExperienceHelperOptions);
  42907. private _onDefaultMeshLoaded;
  42908. private _onResize;
  42909. private _onFullscreenChange;
  42910. /**
  42911. * Gets a value indicating if we are currently in VR mode.
  42912. */
  42913. readonly isInVRMode: boolean;
  42914. private onVrDisplayPresentChange;
  42915. private onVRDisplayChanged;
  42916. private moveButtonToBottomRight;
  42917. private displayVRButton;
  42918. private updateButtonVisibility;
  42919. private _cachedAngularSensibility;
  42920. /**
  42921. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42922. * Otherwise, will use the fullscreen API.
  42923. */
  42924. enterVR(): void;
  42925. /**
  42926. * Attempt to exit VR, or fullscreen.
  42927. */
  42928. exitVR(): void;
  42929. /**
  42930. * The position of the vr experience helper.
  42931. */
  42932. /**
  42933. * Sets the position of the vr experience helper.
  42934. */
  42935. position: Vector3;
  42936. /**
  42937. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42938. */
  42939. enableInteractions(): void;
  42940. private readonly _noControllerIsActive;
  42941. private beforeRender;
  42942. private _isTeleportationFloor;
  42943. /**
  42944. * Adds a floor mesh to be used for teleportation.
  42945. * @param floorMesh the mesh to be used for teleportation.
  42946. */
  42947. addFloorMesh(floorMesh: Mesh): void;
  42948. /**
  42949. * Removes a floor mesh from being used for teleportation.
  42950. * @param floorMesh the mesh to be removed.
  42951. */
  42952. removeFloorMesh(floorMesh: Mesh): void;
  42953. /**
  42954. * Enables interactions and teleportation using the VR controllers and gaze.
  42955. * @param vrTeleportationOptions options to modify teleportation behavior.
  42956. */
  42957. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42958. private _onNewGamepadConnected;
  42959. private _tryEnableInteractionOnController;
  42960. private _onNewGamepadDisconnected;
  42961. private _enableInteractionOnController;
  42962. private _checkTeleportWithRay;
  42963. private _checkRotate;
  42964. private _checkTeleportBackwards;
  42965. private _enableTeleportationOnController;
  42966. private _createTeleportationCircles;
  42967. private _displayTeleportationTarget;
  42968. private _hideTeleportationTarget;
  42969. private _rotateCamera;
  42970. private _moveTeleportationSelectorTo;
  42971. private _workingVector;
  42972. private _workingQuaternion;
  42973. private _workingMatrix;
  42974. /**
  42975. * Teleports the users feet to the desired location
  42976. * @param location The location where the user's feet should be placed
  42977. */
  42978. teleportCamera(location: Vector3): void;
  42979. private _convertNormalToDirectionOfRay;
  42980. private _castRayAndSelectObject;
  42981. private _notifySelectedMeshUnselected;
  42982. /**
  42983. * Sets the color of the laser ray from the vr controllers.
  42984. * @param color new color for the ray.
  42985. */
  42986. changeLaserColor(color: Color3): void;
  42987. /**
  42988. * Sets the color of the ray from the vr headsets gaze.
  42989. * @param color new color for the ray.
  42990. */
  42991. changeGazeColor(color: Color3): void;
  42992. /**
  42993. * Exits VR and disposes of the vr experience helper
  42994. */
  42995. dispose(): void;
  42996. /**
  42997. * Gets the name of the VRExperienceHelper class
  42998. * @returns "VRExperienceHelper"
  42999. */
  43000. getClassName(): string;
  43001. }
  43002. }
  43003. declare module "babylonjs/Cameras/VR/index" {
  43004. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43005. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43006. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43007. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43008. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43009. export * from "babylonjs/Cameras/VR/webVRCamera";
  43010. }
  43011. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43012. import { Nullable } from "babylonjs/types";
  43013. import { IDisposable } from "babylonjs/scene";
  43014. /**
  43015. * States of the webXR experience
  43016. */
  43017. export enum WebXRState {
  43018. /**
  43019. * Transitioning to being in XR mode
  43020. */
  43021. ENTERING_XR = 0,
  43022. /**
  43023. * Transitioning to non XR mode
  43024. */
  43025. EXITING_XR = 1,
  43026. /**
  43027. * In XR mode and presenting
  43028. */
  43029. IN_XR = 2,
  43030. /**
  43031. * Not entered XR mode
  43032. */
  43033. NOT_IN_XR = 3
  43034. }
  43035. /**
  43036. * Abstraction of the XR render target
  43037. */
  43038. export interface WebXRRenderTarget extends IDisposable {
  43039. /**
  43040. * xrpresent context of the canvas which can be used to display/mirror xr content
  43041. */
  43042. canvasContext: WebGLRenderingContext;
  43043. /**
  43044. * xr layer for the canvas
  43045. */
  43046. xrLayer: Nullable<XRWebGLLayer>;
  43047. /**
  43048. * Initializes the xr layer for the session
  43049. * @param xrSession xr session
  43050. * @returns a promise that will resolve once the XR Layer has been created
  43051. */
  43052. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43053. }
  43054. }
  43055. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43056. import { Nullable } from "babylonjs/types";
  43057. import { Observable } from "babylonjs/Misc/observable";
  43058. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43059. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43060. /**
  43061. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43062. */
  43063. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43064. private _engine;
  43065. private _canvas;
  43066. /**
  43067. * xrpresent context of the canvas which can be used to display/mirror xr content
  43068. */
  43069. canvasContext: WebGLRenderingContext;
  43070. /**
  43071. * xr layer for the canvas
  43072. */
  43073. xrLayer: Nullable<XRWebGLLayer>;
  43074. /**
  43075. * Initializes the xr layer for the session
  43076. * @param xrSession xr session
  43077. * @returns a promise that will resolve once the XR Layer has been created
  43078. */
  43079. initializeXRLayerAsync(xrSession: any): any;
  43080. /**
  43081. * Initializes the canvas to be added/removed upon entering/exiting xr
  43082. * @param engine the Babylon engine
  43083. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43084. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43085. */
  43086. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43087. /**
  43088. * Disposes of the object
  43089. */
  43090. dispose(): void;
  43091. private _setManagedOutputCanvas;
  43092. private _addCanvas;
  43093. private _removeCanvas;
  43094. }
  43095. }
  43096. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43097. import { Observable } from "babylonjs/Misc/observable";
  43098. import { Nullable } from "babylonjs/types";
  43099. import { IDisposable, Scene } from "babylonjs/scene";
  43100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43101. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43102. /**
  43103. * Manages an XRSession to work with Babylon's engine
  43104. * @see https://doc.babylonjs.com/how_to/webxr
  43105. */
  43106. export class WebXRSessionManager implements IDisposable {
  43107. private scene;
  43108. /**
  43109. * Fires every time a new xrFrame arrives which can be used to update the camera
  43110. */
  43111. onXRFrameObservable: Observable<any>;
  43112. /**
  43113. * Fires when the xr session is ended either by the device or manually done
  43114. */
  43115. onXRSessionEnded: Observable<any>;
  43116. /**
  43117. * Underlying xr session
  43118. */
  43119. session: XRSession;
  43120. /**
  43121. * Type of reference space used when creating the session
  43122. */
  43123. referenceSpace: XRReferenceSpace;
  43124. /**
  43125. * Current XR frame
  43126. */
  43127. currentFrame: Nullable<XRFrame>;
  43128. private _xrNavigator;
  43129. private baseLayer;
  43130. private _rttProvider;
  43131. private _sessionEnded;
  43132. /**
  43133. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43134. * @param scene The scene which the session should be created for
  43135. */
  43136. constructor(scene: Scene);
  43137. /**
  43138. * Initializes the manager
  43139. * After initialization enterXR can be called to start an XR session
  43140. * @returns Promise which resolves after it is initialized
  43141. */
  43142. initializeAsync(): Promise<void>;
  43143. /**
  43144. * Initializes an xr session
  43145. * @param xrSessionMode mode to initialize
  43146. * @param optionalFeatures defines optional values to pass to the session builder
  43147. * @returns a promise which will resolve once the session has been initialized
  43148. */
  43149. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43150. /**
  43151. * Sets the reference space on the xr session
  43152. * @param referenceSpace space to set
  43153. * @returns a promise that will resolve once the reference space has been set
  43154. */
  43155. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43156. /**
  43157. * Updates the render state of the session
  43158. * @param state state to set
  43159. * @returns a promise that resolves once the render state has been updated
  43160. */
  43161. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43162. /**
  43163. * Starts rendering to the xr layer
  43164. * @returns a promise that will resolve once rendering has started
  43165. */
  43166. startRenderingToXRAsync(): Promise<void>;
  43167. /**
  43168. * Gets the correct render target texture to be rendered this frame for this eye
  43169. * @param eye the eye for which to get the render target
  43170. * @returns the render target for the specified eye
  43171. */
  43172. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43173. /**
  43174. * Stops the xrSession and restores the renderloop
  43175. * @returns Promise which resolves after it exits XR
  43176. */
  43177. exitXRAsync(): Promise<void>;
  43178. /**
  43179. * Checks if a session would be supported for the creation options specified
  43180. * @param sessionMode session mode to check if supported eg. immersive-vr
  43181. * @returns true if supported
  43182. */
  43183. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43184. /**
  43185. * Creates a WebXRRenderTarget object for the XR session
  43186. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43187. * @returns a WebXR render target to which the session can render
  43188. */
  43189. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43190. /**
  43191. * @hidden
  43192. * Converts the render layer of xrSession to a render target
  43193. * @param session session to create render target for
  43194. * @param scene scene the new render target should be created for
  43195. */
  43196. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43197. /**
  43198. * Disposes of the session manager
  43199. */
  43200. dispose(): void;
  43201. }
  43202. }
  43203. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43204. import { Scene } from "babylonjs/scene";
  43205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43206. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43207. /**
  43208. * WebXR Camera which holds the views for the xrSession
  43209. * @see https://doc.babylonjs.com/how_to/webxr
  43210. */
  43211. export class WebXRCamera extends FreeCamera {
  43212. private static _TmpMatrix;
  43213. /**
  43214. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43215. * @param name the name of the camera
  43216. * @param scene the scene to add the camera to
  43217. */
  43218. constructor(name: string, scene: Scene);
  43219. private _updateNumberOfRigCameras;
  43220. /** @hidden */
  43221. _updateForDualEyeDebugging(): void;
  43222. /**
  43223. * Updates the cameras position from the current pose information of the XR session
  43224. * @param xrSessionManager the session containing pose information
  43225. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43226. */
  43227. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43228. }
  43229. }
  43230. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43231. import { Observable } from "babylonjs/Misc/observable";
  43232. import { IDisposable, Scene } from "babylonjs/scene";
  43233. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43235. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43236. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43237. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43238. /**
  43239. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43240. * @see https://doc.babylonjs.com/how_to/webxr
  43241. */
  43242. export class WebXRExperienceHelper implements IDisposable {
  43243. private scene;
  43244. /**
  43245. * 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
  43246. */
  43247. container: AbstractMesh;
  43248. /**
  43249. * Camera used to render xr content
  43250. */
  43251. camera: WebXRCamera;
  43252. /**
  43253. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43254. */
  43255. state: WebXRState;
  43256. private _setState;
  43257. private static _TmpVector;
  43258. /**
  43259. * Fires when the state of the experience helper has changed
  43260. */
  43261. onStateChangedObservable: Observable<WebXRState>;
  43262. /** Session manager used to keep track of xr session */
  43263. sessionManager: WebXRSessionManager;
  43264. private _nonVRCamera;
  43265. private _originalSceneAutoClear;
  43266. private _supported;
  43267. /**
  43268. * Creates the experience helper
  43269. * @param scene the scene to attach the experience helper to
  43270. * @returns a promise for the experience helper
  43271. */
  43272. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43273. /**
  43274. * Creates a WebXRExperienceHelper
  43275. * @param scene The scene the helper should be created in
  43276. */
  43277. private constructor();
  43278. /**
  43279. * Exits XR mode and returns the scene to its original state
  43280. * @returns promise that resolves after xr mode has exited
  43281. */
  43282. exitXRAsync(): Promise<void>;
  43283. /**
  43284. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43285. * @param sessionMode options for the XR session
  43286. * @param referenceSpaceType frame of reference of the XR session
  43287. * @param renderTarget the output canvas that will be used to enter XR mode
  43288. * @returns promise that resolves after xr mode has entered
  43289. */
  43290. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43291. /**
  43292. * Updates the global position of the camera by moving the camera's container
  43293. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43294. * @param position The desired global position of the camera
  43295. */
  43296. setPositionOfCameraUsingContainer(position: Vector3): void;
  43297. /**
  43298. * Rotates the xr camera by rotating the camera's container around the camera's position
  43299. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43300. * @param rotation the desired quaternion rotation to apply to the camera
  43301. */
  43302. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43303. /**
  43304. * Disposes of the experience helper
  43305. */
  43306. dispose(): void;
  43307. }
  43308. }
  43309. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43310. import { Nullable } from "babylonjs/types";
  43311. import { Observable } from "babylonjs/Misc/observable";
  43312. import { IDisposable, Scene } from "babylonjs/scene";
  43313. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43314. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43315. /**
  43316. * Button which can be used to enter a different mode of XR
  43317. */
  43318. export class WebXREnterExitUIButton {
  43319. /** button element */
  43320. element: HTMLElement;
  43321. /** XR initialization options for the button */
  43322. sessionMode: XRSessionMode;
  43323. /** Reference space type */
  43324. referenceSpaceType: XRReferenceSpaceType;
  43325. /**
  43326. * Creates a WebXREnterExitUIButton
  43327. * @param element button element
  43328. * @param sessionMode XR initialization session mode
  43329. * @param referenceSpaceType the type of reference space to be used
  43330. */
  43331. constructor(
  43332. /** button element */
  43333. element: HTMLElement,
  43334. /** XR initialization options for the button */
  43335. sessionMode: XRSessionMode,
  43336. /** Reference space type */
  43337. referenceSpaceType: XRReferenceSpaceType);
  43338. /**
  43339. * Overwritable function which can be used to update the button's visuals when the state changes
  43340. * @param activeButton the current active button in the UI
  43341. */
  43342. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43343. }
  43344. /**
  43345. * Options to create the webXR UI
  43346. */
  43347. export class WebXREnterExitUIOptions {
  43348. /**
  43349. * Context to enter xr with
  43350. */
  43351. renderTarget?: Nullable<WebXRRenderTarget>;
  43352. /**
  43353. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43354. */
  43355. customButtons?: Array<WebXREnterExitUIButton>;
  43356. }
  43357. /**
  43358. * UI to allow the user to enter/exit XR mode
  43359. */
  43360. export class WebXREnterExitUI implements IDisposable {
  43361. private scene;
  43362. private _overlay;
  43363. private _buttons;
  43364. private _activeButton;
  43365. /**
  43366. * Fired every time the active button is changed.
  43367. *
  43368. * When xr is entered via a button that launches xr that button will be the callback parameter
  43369. *
  43370. * When exiting xr the callback parameter will be null)
  43371. */
  43372. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43373. /**
  43374. * Creates UI to allow the user to enter/exit XR mode
  43375. * @param scene the scene to add the ui to
  43376. * @param helper the xr experience helper to enter/exit xr with
  43377. * @param options options to configure the UI
  43378. * @returns the created ui
  43379. */
  43380. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43381. private constructor();
  43382. private _updateButtons;
  43383. /**
  43384. * Disposes of the object
  43385. */
  43386. dispose(): void;
  43387. }
  43388. }
  43389. declare module "babylonjs/Cameras/XR/webXRController" {
  43390. import { Nullable } from "babylonjs/types";
  43391. import { Observable } from "babylonjs/Misc/observable";
  43392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43393. import { Ray } from "babylonjs/Culling/ray";
  43394. import { Scene } from "babylonjs/scene";
  43395. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43396. /**
  43397. * Represents an XR input
  43398. */
  43399. export class WebXRController {
  43400. private scene;
  43401. /** The underlying input source for the controller */
  43402. inputSource: XRInputSource;
  43403. private parentContainer;
  43404. /**
  43405. * 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
  43406. */
  43407. grip?: AbstractMesh;
  43408. /**
  43409. * Pointer which can be used to select objects or attach a visible laser to
  43410. */
  43411. pointer: AbstractMesh;
  43412. private _gamepadMode;
  43413. /**
  43414. * If available, this is the gamepad object related to this controller.
  43415. * Using this object it is possible to get click events and trackpad changes of the
  43416. * webxr controller that is currently being used.
  43417. */
  43418. gamepadController?: WebVRController;
  43419. /**
  43420. * Event that fires when the controller is removed/disposed
  43421. */
  43422. onDisposeObservable: Observable<{}>;
  43423. private _tmpMatrix;
  43424. private _tmpQuaternion;
  43425. private _tmpVector;
  43426. /**
  43427. * Creates the controller
  43428. * @see https://doc.babylonjs.com/how_to/webxr
  43429. * @param scene the scene which the controller should be associated to
  43430. * @param inputSource the underlying input source for the controller
  43431. * @param parentContainer parent that the controller meshes should be children of
  43432. */
  43433. constructor(scene: Scene,
  43434. /** The underlying input source for the controller */
  43435. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43436. /**
  43437. * Updates the controller pose based on the given XRFrame
  43438. * @param xrFrame xr frame to update the pose with
  43439. * @param referenceSpace reference space to use
  43440. */
  43441. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43442. /**
  43443. * Gets a world space ray coming from the controller
  43444. * @param result the resulting ray
  43445. */
  43446. getWorldPointerRayToRef(result: Ray): void;
  43447. /**
  43448. * Get the scene associated with this controller
  43449. * @returns the scene object
  43450. */
  43451. getScene(): Scene;
  43452. /**
  43453. * Disposes of the object
  43454. */
  43455. dispose(): void;
  43456. }
  43457. }
  43458. declare module "babylonjs/Cameras/XR/webXRInput" {
  43459. import { Observable } from "babylonjs/Misc/observable";
  43460. import { IDisposable } from "babylonjs/scene";
  43461. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43462. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43463. /**
  43464. * XR input used to track XR inputs such as controllers/rays
  43465. */
  43466. export class WebXRInput implements IDisposable {
  43467. /**
  43468. * Base experience the input listens to
  43469. */
  43470. baseExperience: WebXRExperienceHelper;
  43471. /**
  43472. * XR controllers being tracked
  43473. */
  43474. controllers: Array<WebXRController>;
  43475. private _frameObserver;
  43476. private _stateObserver;
  43477. /**
  43478. * Event when a controller has been connected/added
  43479. */
  43480. onControllerAddedObservable: Observable<WebXRController>;
  43481. /**
  43482. * Event when a controller has been removed/disconnected
  43483. */
  43484. onControllerRemovedObservable: Observable<WebXRController>;
  43485. /**
  43486. * Initializes the WebXRInput
  43487. * @param baseExperience experience helper which the input should be created for
  43488. */
  43489. constructor(
  43490. /**
  43491. * Base experience the input listens to
  43492. */
  43493. baseExperience: WebXRExperienceHelper);
  43494. private _onInputSourcesChange;
  43495. private _addAndRemoveControllers;
  43496. /**
  43497. * Disposes of the object
  43498. */
  43499. dispose(): void;
  43500. }
  43501. }
  43502. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43504. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43505. /**
  43506. * Enables teleportation
  43507. */
  43508. export class WebXRControllerTeleportation {
  43509. private _teleportationFillColor;
  43510. private _teleportationBorderColor;
  43511. private _tmpRay;
  43512. private _tmpVector;
  43513. /**
  43514. * Creates a WebXRControllerTeleportation
  43515. * @param input input manager to add teleportation to
  43516. * @param floorMeshes floormeshes which can be teleported to
  43517. */
  43518. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43519. }
  43520. }
  43521. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43522. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43523. /**
  43524. * Handles pointer input automatically for the pointer of XR controllers
  43525. */
  43526. export class WebXRControllerPointerSelection {
  43527. private static _idCounter;
  43528. private _tmpRay;
  43529. /**
  43530. * Creates a WebXRControllerPointerSelection
  43531. * @param input input manager to setup pointer selection
  43532. */
  43533. constructor(input: WebXRInput);
  43534. private _convertNormalToDirectionOfRay;
  43535. private _updatePointerDistance;
  43536. }
  43537. }
  43538. declare module "babylonjs/Loading/sceneLoader" {
  43539. import { Observable } from "babylonjs/Misc/observable";
  43540. import { Nullable } from "babylonjs/types";
  43541. import { Scene } from "babylonjs/scene";
  43542. import { Engine } from "babylonjs/Engines/engine";
  43543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43544. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43545. import { AssetContainer } from "babylonjs/assetContainer";
  43546. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43547. import { Skeleton } from "babylonjs/Bones/skeleton";
  43548. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43549. import { WebRequest } from "babylonjs/Misc/webRequest";
  43550. /**
  43551. * Class used to represent data loading progression
  43552. */
  43553. export class SceneLoaderProgressEvent {
  43554. /** defines if data length to load can be evaluated */
  43555. readonly lengthComputable: boolean;
  43556. /** defines the loaded data length */
  43557. readonly loaded: number;
  43558. /** defines the data length to load */
  43559. readonly total: number;
  43560. /**
  43561. * Create a new progress event
  43562. * @param lengthComputable defines if data length to load can be evaluated
  43563. * @param loaded defines the loaded data length
  43564. * @param total defines the data length to load
  43565. */
  43566. constructor(
  43567. /** defines if data length to load can be evaluated */
  43568. lengthComputable: boolean,
  43569. /** defines the loaded data length */
  43570. loaded: number,
  43571. /** defines the data length to load */
  43572. total: number);
  43573. /**
  43574. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43575. * @param event defines the source event
  43576. * @returns a new SceneLoaderProgressEvent
  43577. */
  43578. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43579. }
  43580. /**
  43581. * Interface used by SceneLoader plugins to define supported file extensions
  43582. */
  43583. export interface ISceneLoaderPluginExtensions {
  43584. /**
  43585. * Defines the list of supported extensions
  43586. */
  43587. [extension: string]: {
  43588. isBinary: boolean;
  43589. };
  43590. }
  43591. /**
  43592. * Interface used by SceneLoader plugin factory
  43593. */
  43594. export interface ISceneLoaderPluginFactory {
  43595. /**
  43596. * Defines the name of the factory
  43597. */
  43598. name: string;
  43599. /**
  43600. * Function called to create a new plugin
  43601. * @return the new plugin
  43602. */
  43603. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43604. /**
  43605. * The callback that returns true if the data can be directly loaded.
  43606. * @param data string containing the file data
  43607. * @returns if the data can be loaded directly
  43608. */
  43609. canDirectLoad?(data: string): boolean;
  43610. }
  43611. /**
  43612. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43613. */
  43614. export interface ISceneLoaderPluginBase {
  43615. /**
  43616. * The friendly name of this plugin.
  43617. */
  43618. name: string;
  43619. /**
  43620. * The file extensions supported by this plugin.
  43621. */
  43622. extensions: string | ISceneLoaderPluginExtensions;
  43623. /**
  43624. * The callback called when loading from a url.
  43625. * @param scene scene loading this url
  43626. * @param url url to load
  43627. * @param onSuccess callback called when the file successfully loads
  43628. * @param onProgress callback called while file is loading (if the server supports this mode)
  43629. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43630. * @param onError callback called when the file fails to load
  43631. * @returns a file request object
  43632. */
  43633. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43634. /**
  43635. * The callback called when loading from a file object.
  43636. * @param scene scene loading this file
  43637. * @param file defines the file to load
  43638. * @param onSuccess defines the callback to call when data is loaded
  43639. * @param onProgress defines the callback to call during loading process
  43640. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43641. * @param onError defines the callback to call when an error occurs
  43642. * @returns a file request object
  43643. */
  43644. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43645. /**
  43646. * The callback that returns true if the data can be directly loaded.
  43647. * @param data string containing the file data
  43648. * @returns if the data can be loaded directly
  43649. */
  43650. canDirectLoad?(data: string): boolean;
  43651. /**
  43652. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43653. * @param scene scene loading this data
  43654. * @param data string containing the data
  43655. * @returns data to pass to the plugin
  43656. */
  43657. directLoad?(scene: Scene, data: string): any;
  43658. /**
  43659. * The callback that allows custom handling of the root url based on the response url.
  43660. * @param rootUrl the original root url
  43661. * @param responseURL the response url if available
  43662. * @returns the new root url
  43663. */
  43664. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43665. }
  43666. /**
  43667. * Interface used to define a SceneLoader plugin
  43668. */
  43669. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43670. /**
  43671. * Import meshes into a scene.
  43672. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43673. * @param scene The scene to import into
  43674. * @param data The data to import
  43675. * @param rootUrl The root url for scene and resources
  43676. * @param meshes The meshes array to import into
  43677. * @param particleSystems The particle systems array to import into
  43678. * @param skeletons The skeletons array to import into
  43679. * @param onError The callback when import fails
  43680. * @returns True if successful or false otherwise
  43681. */
  43682. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43683. /**
  43684. * Load into a scene.
  43685. * @param scene The scene to load into
  43686. * @param data The data to import
  43687. * @param rootUrl The root url for scene and resources
  43688. * @param onError The callback when import fails
  43689. * @returns True if successful or false otherwise
  43690. */
  43691. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43692. /**
  43693. * Load into an asset container.
  43694. * @param scene The scene to load into
  43695. * @param data The data to import
  43696. * @param rootUrl The root url for scene and resources
  43697. * @param onError The callback when import fails
  43698. * @returns The loaded asset container
  43699. */
  43700. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43701. }
  43702. /**
  43703. * Interface used to define an async SceneLoader plugin
  43704. */
  43705. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43706. /**
  43707. * Import meshes into a scene.
  43708. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43709. * @param scene The scene to import into
  43710. * @param data The data to import
  43711. * @param rootUrl The root url for scene and resources
  43712. * @param onProgress The callback when the load progresses
  43713. * @param fileName Defines the name of the file to load
  43714. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43715. */
  43716. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43717. meshes: AbstractMesh[];
  43718. particleSystems: IParticleSystem[];
  43719. skeletons: Skeleton[];
  43720. animationGroups: AnimationGroup[];
  43721. }>;
  43722. /**
  43723. * Load into a scene.
  43724. * @param scene The scene to load into
  43725. * @param data The data to import
  43726. * @param rootUrl The root url for scene and resources
  43727. * @param onProgress The callback when the load progresses
  43728. * @param fileName Defines the name of the file to load
  43729. * @returns Nothing
  43730. */
  43731. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43732. /**
  43733. * Load into an asset container.
  43734. * @param scene The scene to load into
  43735. * @param data The data to import
  43736. * @param rootUrl The root url for scene and resources
  43737. * @param onProgress The callback when the load progresses
  43738. * @param fileName Defines the name of the file to load
  43739. * @returns The loaded asset container
  43740. */
  43741. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43742. }
  43743. /**
  43744. * Class used to load scene from various file formats using registered plugins
  43745. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43746. */
  43747. export class SceneLoader {
  43748. /**
  43749. * No logging while loading
  43750. */
  43751. static readonly NO_LOGGING: number;
  43752. /**
  43753. * Minimal logging while loading
  43754. */
  43755. static readonly MINIMAL_LOGGING: number;
  43756. /**
  43757. * Summary logging while loading
  43758. */
  43759. static readonly SUMMARY_LOGGING: number;
  43760. /**
  43761. * Detailled logging while loading
  43762. */
  43763. static readonly DETAILED_LOGGING: number;
  43764. /**
  43765. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43766. */
  43767. static ForceFullSceneLoadingForIncremental: boolean;
  43768. /**
  43769. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43770. */
  43771. static ShowLoadingScreen: boolean;
  43772. /**
  43773. * Defines the current logging level (while loading the scene)
  43774. * @ignorenaming
  43775. */
  43776. static loggingLevel: number;
  43777. /**
  43778. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43779. */
  43780. static CleanBoneMatrixWeights: boolean;
  43781. /**
  43782. * Event raised when a plugin is used to load a scene
  43783. */
  43784. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43785. private static _registeredPlugins;
  43786. private static _getDefaultPlugin;
  43787. private static _getPluginForExtension;
  43788. private static _getPluginForDirectLoad;
  43789. private static _getPluginForFilename;
  43790. private static _getDirectLoad;
  43791. private static _loadData;
  43792. private static _getFileInfo;
  43793. /**
  43794. * Gets a plugin that can load the given extension
  43795. * @param extension defines the extension to load
  43796. * @returns a plugin or null if none works
  43797. */
  43798. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43799. /**
  43800. * Gets a boolean indicating that the given extension can be loaded
  43801. * @param extension defines the extension to load
  43802. * @returns true if the extension is supported
  43803. */
  43804. static IsPluginForExtensionAvailable(extension: string): boolean;
  43805. /**
  43806. * Adds a new plugin to the list of registered plugins
  43807. * @param plugin defines the plugin to add
  43808. */
  43809. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43810. /**
  43811. * Import meshes into a scene
  43812. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43813. * @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)
  43814. * @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)
  43815. * @param scene the instance of BABYLON.Scene to append to
  43816. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43817. * @param onProgress a callback with a progress event for each file being loaded
  43818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43819. * @param pluginExtension the extension used to determine the plugin
  43820. * @returns The loaded plugin
  43821. */
  43822. 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>;
  43823. /**
  43824. * Import meshes into a scene
  43825. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43826. * @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)
  43827. * @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)
  43828. * @param scene the instance of BABYLON.Scene to append to
  43829. * @param onProgress a callback with a progress event for each file being loaded
  43830. * @param pluginExtension the extension used to determine the plugin
  43831. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43832. */
  43833. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43834. meshes: AbstractMesh[];
  43835. particleSystems: IParticleSystem[];
  43836. skeletons: Skeleton[];
  43837. animationGroups: AnimationGroup[];
  43838. }>;
  43839. /**
  43840. * Load a scene
  43841. * @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)
  43842. * @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)
  43843. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43844. * @param onSuccess a callback with the scene when import succeeds
  43845. * @param onProgress a callback with a progress event for each file being loaded
  43846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43847. * @param pluginExtension the extension used to determine the plugin
  43848. * @returns The loaded plugin
  43849. */
  43850. 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>;
  43851. /**
  43852. * Load a scene
  43853. * @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)
  43854. * @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)
  43855. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43856. * @param onProgress a callback with a progress event for each file being loaded
  43857. * @param pluginExtension the extension used to determine the plugin
  43858. * @returns The loaded scene
  43859. */
  43860. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43861. /**
  43862. * Append a scene
  43863. * @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)
  43864. * @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)
  43865. * @param scene is the instance of BABYLON.Scene to append to
  43866. * @param onSuccess a callback with the scene when import succeeds
  43867. * @param onProgress a callback with a progress event for each file being loaded
  43868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43869. * @param pluginExtension the extension used to determine the plugin
  43870. * @returns The loaded plugin
  43871. */
  43872. 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>;
  43873. /**
  43874. * Append a scene
  43875. * @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)
  43876. * @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)
  43877. * @param scene is the instance of BABYLON.Scene to append to
  43878. * @param onProgress a callback with a progress event for each file being loaded
  43879. * @param pluginExtension the extension used to determine the plugin
  43880. * @returns The given scene
  43881. */
  43882. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43883. /**
  43884. * Load a scene into an asset container
  43885. * @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)
  43886. * @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)
  43887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43888. * @param onSuccess a callback with the scene when import succeeds
  43889. * @param onProgress a callback with a progress event for each file being loaded
  43890. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43891. * @param pluginExtension the extension used to determine the plugin
  43892. * @returns The loaded plugin
  43893. */
  43894. 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>;
  43895. /**
  43896. * Load a scene into an asset container
  43897. * @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)
  43898. * @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)
  43899. * @param scene is the instance of Scene to append to
  43900. * @param onProgress a callback with a progress event for each file being loaded
  43901. * @param pluginExtension the extension used to determine the plugin
  43902. * @returns The loaded asset container
  43903. */
  43904. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43905. }
  43906. }
  43907. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43908. import { Scene } from "babylonjs/scene";
  43909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43910. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43911. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43912. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43913. /**
  43914. * Generic Controller
  43915. */
  43916. export class GenericController extends WebVRController {
  43917. /**
  43918. * Base Url for the controller model.
  43919. */
  43920. static readonly MODEL_BASE_URL: string;
  43921. /**
  43922. * File name for the controller model.
  43923. */
  43924. static readonly MODEL_FILENAME: string;
  43925. /**
  43926. * Creates a new GenericController from a gamepad
  43927. * @param vrGamepad the gamepad that the controller should be created from
  43928. */
  43929. constructor(vrGamepad: any);
  43930. /**
  43931. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43932. * @param scene scene in which to add meshes
  43933. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43934. */
  43935. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43936. /**
  43937. * Called once for each button that changed state since the last frame
  43938. * @param buttonIdx Which button index changed
  43939. * @param state New state of the button
  43940. * @param changes Which properties on the state changed since last frame
  43941. */
  43942. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43943. }
  43944. }
  43945. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43946. import { Observable } from "babylonjs/Misc/observable";
  43947. import { Scene } from "babylonjs/scene";
  43948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43949. import { Ray } from "babylonjs/Culling/ray";
  43950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43951. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43952. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43953. /**
  43954. * Defines the WindowsMotionController object that the state of the windows motion controller
  43955. */
  43956. export class WindowsMotionController extends WebVRController {
  43957. /**
  43958. * The base url used to load the left and right controller models
  43959. */
  43960. static MODEL_BASE_URL: string;
  43961. /**
  43962. * The name of the left controller model file
  43963. */
  43964. static MODEL_LEFT_FILENAME: string;
  43965. /**
  43966. * The name of the right controller model file
  43967. */
  43968. static MODEL_RIGHT_FILENAME: string;
  43969. /**
  43970. * The controller name prefix for this controller type
  43971. */
  43972. static readonly GAMEPAD_ID_PREFIX: string;
  43973. /**
  43974. * The controller id pattern for this controller type
  43975. */
  43976. private static readonly GAMEPAD_ID_PATTERN;
  43977. private _loadedMeshInfo;
  43978. private readonly _mapping;
  43979. /**
  43980. * Fired when the trackpad on this controller is clicked
  43981. */
  43982. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43983. /**
  43984. * Fired when the trackpad on this controller is modified
  43985. */
  43986. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43987. /**
  43988. * The current x and y values of this controller's trackpad
  43989. */
  43990. trackpad: StickValues;
  43991. /**
  43992. * Creates a new WindowsMotionController from a gamepad
  43993. * @param vrGamepad the gamepad that the controller should be created from
  43994. */
  43995. constructor(vrGamepad: any);
  43996. /**
  43997. * Fired when the trigger on this controller is modified
  43998. */
  43999. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44000. /**
  44001. * Fired when the menu button on this controller is modified
  44002. */
  44003. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44004. /**
  44005. * Fired when the grip button on this controller is modified
  44006. */
  44007. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44008. /**
  44009. * Fired when the thumbstick button on this controller is modified
  44010. */
  44011. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44012. /**
  44013. * Fired when the touchpad button on this controller is modified
  44014. */
  44015. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44016. /**
  44017. * Fired when the touchpad values on this controller are modified
  44018. */
  44019. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44020. private _updateTrackpad;
  44021. /**
  44022. * Called once per frame by the engine.
  44023. */
  44024. update(): void;
  44025. /**
  44026. * Called once for each button that changed state since the last frame
  44027. * @param buttonIdx Which button index changed
  44028. * @param state New state of the button
  44029. * @param changes Which properties on the state changed since last frame
  44030. */
  44031. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44032. /**
  44033. * Moves the buttons on the controller mesh based on their current state
  44034. * @param buttonName the name of the button to move
  44035. * @param buttonValue the value of the button which determines the buttons new position
  44036. */
  44037. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44038. /**
  44039. * Moves the axis on the controller mesh based on its current state
  44040. * @param axis the index of the axis
  44041. * @param axisValue the value of the axis which determines the meshes new position
  44042. * @hidden
  44043. */
  44044. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44045. /**
  44046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44047. * @param scene scene in which to add meshes
  44048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44049. */
  44050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44051. /**
  44052. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44053. * can be transformed by button presses and axes values, based on this._mapping.
  44054. *
  44055. * @param scene scene in which the meshes exist
  44056. * @param meshes list of meshes that make up the controller model to process
  44057. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44058. */
  44059. private processModel;
  44060. private createMeshInfo;
  44061. /**
  44062. * Gets the ray of the controller in the direction the controller is pointing
  44063. * @param length the length the resulting ray should be
  44064. * @returns a ray in the direction the controller is pointing
  44065. */
  44066. getForwardRay(length?: number): Ray;
  44067. /**
  44068. * Disposes of the controller
  44069. */
  44070. dispose(): void;
  44071. }
  44072. }
  44073. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44074. import { Observable } from "babylonjs/Misc/observable";
  44075. import { Scene } from "babylonjs/scene";
  44076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44078. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44079. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44080. /**
  44081. * Oculus Touch Controller
  44082. */
  44083. export class OculusTouchController extends WebVRController {
  44084. /**
  44085. * Base Url for the controller model.
  44086. */
  44087. static MODEL_BASE_URL: string;
  44088. /**
  44089. * File name for the left controller model.
  44090. */
  44091. static MODEL_LEFT_FILENAME: string;
  44092. /**
  44093. * File name for the right controller model.
  44094. */
  44095. static MODEL_RIGHT_FILENAME: string;
  44096. /**
  44097. * Base Url for the Quest controller model.
  44098. */
  44099. static QUEST_MODEL_BASE_URL: string;
  44100. /**
  44101. * @hidden
  44102. * If the controllers are running on a device that needs the updated Quest controller models
  44103. */
  44104. static _IsQuest: boolean;
  44105. /**
  44106. * Fired when the secondary trigger on this controller is modified
  44107. */
  44108. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44109. /**
  44110. * Fired when the thumb rest on this controller is modified
  44111. */
  44112. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44113. /**
  44114. * Creates a new OculusTouchController from a gamepad
  44115. * @param vrGamepad the gamepad that the controller should be created from
  44116. */
  44117. constructor(vrGamepad: any);
  44118. /**
  44119. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44120. * @param scene scene in which to add meshes
  44121. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44122. */
  44123. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44124. /**
  44125. * Fired when the A button on this controller is modified
  44126. */
  44127. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44128. /**
  44129. * Fired when the B button on this controller is modified
  44130. */
  44131. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44132. /**
  44133. * Fired when the X button on this controller is modified
  44134. */
  44135. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44136. /**
  44137. * Fired when the Y button on this controller is modified
  44138. */
  44139. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44140. /**
  44141. * Called once for each button that changed state since the last frame
  44142. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44143. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44144. * 2) secondary trigger (same)
  44145. * 3) A (right) X (left), touch, pressed = value
  44146. * 4) B / Y
  44147. * 5) thumb rest
  44148. * @param buttonIdx Which button index changed
  44149. * @param state New state of the button
  44150. * @param changes Which properties on the state changed since last frame
  44151. */
  44152. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44153. }
  44154. }
  44155. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44156. import { Scene } from "babylonjs/scene";
  44157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44158. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44159. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44160. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44161. import { Observable } from "babylonjs/Misc/observable";
  44162. /**
  44163. * Vive Controller
  44164. */
  44165. export class ViveController extends WebVRController {
  44166. /**
  44167. * Base Url for the controller model.
  44168. */
  44169. static MODEL_BASE_URL: string;
  44170. /**
  44171. * File name for the controller model.
  44172. */
  44173. static MODEL_FILENAME: string;
  44174. /**
  44175. * Creates a new ViveController from a gamepad
  44176. * @param vrGamepad the gamepad that the controller should be created from
  44177. */
  44178. constructor(vrGamepad: any);
  44179. /**
  44180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44181. * @param scene scene in which to add meshes
  44182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44183. */
  44184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44185. /**
  44186. * Fired when the left button on this controller is modified
  44187. */
  44188. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44189. /**
  44190. * Fired when the right button on this controller is modified
  44191. */
  44192. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44193. /**
  44194. * Fired when the menu button on this controller is modified
  44195. */
  44196. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44197. /**
  44198. * Called once for each button that changed state since the last frame
  44199. * Vive mapping:
  44200. * 0: touchpad
  44201. * 1: trigger
  44202. * 2: left AND right buttons
  44203. * 3: menu button
  44204. * @param buttonIdx Which button index changed
  44205. * @param state New state of the button
  44206. * @param changes Which properties on the state changed since last frame
  44207. */
  44208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44209. }
  44210. }
  44211. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44212. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44213. /**
  44214. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44215. */
  44216. export class WebXRControllerModelLoader {
  44217. /**
  44218. * Creates the WebXRControllerModelLoader
  44219. * @param input xr input that creates the controllers
  44220. */
  44221. constructor(input: WebXRInput);
  44222. }
  44223. }
  44224. declare module "babylonjs/Cameras/XR/index" {
  44225. export * from "babylonjs/Cameras/XR/webXRCamera";
  44226. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44227. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44228. export * from "babylonjs/Cameras/XR/webXRInput";
  44229. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44230. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44231. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44232. export * from "babylonjs/Cameras/XR/webXRController";
  44233. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44234. export * from "babylonjs/Cameras/XR/webXRTypes";
  44235. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44236. }
  44237. declare module "babylonjs/Cameras/RigModes/index" {
  44238. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44239. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44240. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44241. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44242. }
  44243. declare module "babylonjs/Cameras/index" {
  44244. export * from "babylonjs/Cameras/Inputs/index";
  44245. export * from "babylonjs/Cameras/cameraInputsManager";
  44246. export * from "babylonjs/Cameras/camera";
  44247. export * from "babylonjs/Cameras/targetCamera";
  44248. export * from "babylonjs/Cameras/freeCamera";
  44249. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44250. export * from "babylonjs/Cameras/touchCamera";
  44251. export * from "babylonjs/Cameras/arcRotateCamera";
  44252. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44253. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44254. export * from "babylonjs/Cameras/flyCamera";
  44255. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44256. export * from "babylonjs/Cameras/followCamera";
  44257. export * from "babylonjs/Cameras/followCameraInputsManager";
  44258. export * from "babylonjs/Cameras/gamepadCamera";
  44259. export * from "babylonjs/Cameras/Stereoscopic/index";
  44260. export * from "babylonjs/Cameras/universalCamera";
  44261. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44262. export * from "babylonjs/Cameras/VR/index";
  44263. export * from "babylonjs/Cameras/XR/index";
  44264. export * from "babylonjs/Cameras/RigModes/index";
  44265. }
  44266. declare module "babylonjs/Collisions/index" {
  44267. export * from "babylonjs/Collisions/collider";
  44268. export * from "babylonjs/Collisions/collisionCoordinator";
  44269. export * from "babylonjs/Collisions/pickingInfo";
  44270. export * from "babylonjs/Collisions/intersectionInfo";
  44271. export * from "babylonjs/Collisions/meshCollisionData";
  44272. }
  44273. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44274. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44275. import { Vector3 } from "babylonjs/Maths/math.vector";
  44276. import { Ray } from "babylonjs/Culling/ray";
  44277. import { Plane } from "babylonjs/Maths/math.plane";
  44278. /**
  44279. * Contains an array of blocks representing the octree
  44280. */
  44281. export interface IOctreeContainer<T> {
  44282. /**
  44283. * Blocks within the octree
  44284. */
  44285. blocks: Array<OctreeBlock<T>>;
  44286. }
  44287. /**
  44288. * Class used to store a cell in an octree
  44289. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44290. */
  44291. export class OctreeBlock<T> {
  44292. /**
  44293. * Gets the content of the current block
  44294. */
  44295. entries: T[];
  44296. /**
  44297. * Gets the list of block children
  44298. */
  44299. blocks: Array<OctreeBlock<T>>;
  44300. private _depth;
  44301. private _maxDepth;
  44302. private _capacity;
  44303. private _minPoint;
  44304. private _maxPoint;
  44305. private _boundingVectors;
  44306. private _creationFunc;
  44307. /**
  44308. * Creates a new block
  44309. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44310. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44311. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44312. * @param depth defines the current depth of this block in the octree
  44313. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44314. * @param creationFunc defines a callback to call when an element is added to the block
  44315. */
  44316. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44317. /**
  44318. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44319. */
  44320. readonly capacity: number;
  44321. /**
  44322. * Gets the minimum vector (in world space) of the block's bounding box
  44323. */
  44324. readonly minPoint: Vector3;
  44325. /**
  44326. * Gets the maximum vector (in world space) of the block's bounding box
  44327. */
  44328. readonly maxPoint: Vector3;
  44329. /**
  44330. * Add a new element to this block
  44331. * @param entry defines the element to add
  44332. */
  44333. addEntry(entry: T): void;
  44334. /**
  44335. * Remove an element from this block
  44336. * @param entry defines the element to remove
  44337. */
  44338. removeEntry(entry: T): void;
  44339. /**
  44340. * Add an array of elements to this block
  44341. * @param entries defines the array of elements to add
  44342. */
  44343. addEntries(entries: T[]): void;
  44344. /**
  44345. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44346. * @param frustumPlanes defines the frustum planes to test
  44347. * @param selection defines the array to store current content if selection is positive
  44348. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44349. */
  44350. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44351. /**
  44352. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44353. * @param sphereCenter defines the bounding sphere center
  44354. * @param sphereRadius defines the bounding sphere radius
  44355. * @param selection defines the array to store current content if selection is positive
  44356. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44357. */
  44358. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44359. /**
  44360. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44361. * @param ray defines the ray to test with
  44362. * @param selection defines the array to store current content if selection is positive
  44363. */
  44364. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44365. /**
  44366. * Subdivide the content into child blocks (this block will then be empty)
  44367. */
  44368. createInnerBlocks(): void;
  44369. /**
  44370. * @hidden
  44371. */
  44372. 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;
  44373. }
  44374. }
  44375. declare module "babylonjs/Culling/Octrees/octree" {
  44376. import { SmartArray } from "babylonjs/Misc/smartArray";
  44377. import { Vector3 } from "babylonjs/Maths/math.vector";
  44378. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44380. import { Ray } from "babylonjs/Culling/ray";
  44381. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44382. import { Plane } from "babylonjs/Maths/math.plane";
  44383. /**
  44384. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44385. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44386. */
  44387. export class Octree<T> {
  44388. /** 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.) */
  44389. maxDepth: number;
  44390. /**
  44391. * Blocks within the octree containing objects
  44392. */
  44393. blocks: Array<OctreeBlock<T>>;
  44394. /**
  44395. * Content stored in the octree
  44396. */
  44397. dynamicContent: T[];
  44398. private _maxBlockCapacity;
  44399. private _selectionContent;
  44400. private _creationFunc;
  44401. /**
  44402. * Creates a octree
  44403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44404. * @param creationFunc function to be used to instatiate the octree
  44405. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44406. * @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.)
  44407. */
  44408. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44409. /** 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.) */
  44410. maxDepth?: number);
  44411. /**
  44412. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44413. * @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);
  44414. * @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);
  44415. * @param entries meshes to be added to the octree blocks
  44416. */
  44417. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44418. /**
  44419. * Adds a mesh to the octree
  44420. * @param entry Mesh to add to the octree
  44421. */
  44422. addMesh(entry: T): void;
  44423. /**
  44424. * Remove an element from the octree
  44425. * @param entry defines the element to remove
  44426. */
  44427. removeMesh(entry: T): void;
  44428. /**
  44429. * Selects an array of meshes within the frustum
  44430. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44431. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44432. * @returns array of meshes within the frustum
  44433. */
  44434. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44435. /**
  44436. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44437. * @param sphereCenter defines the bounding sphere center
  44438. * @param sphereRadius defines the bounding sphere radius
  44439. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44440. * @returns an array of objects that intersect the sphere
  44441. */
  44442. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44443. /**
  44444. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44445. * @param ray defines the ray to test with
  44446. * @returns array of intersected objects
  44447. */
  44448. intersectsRay(ray: Ray): SmartArray<T>;
  44449. /**
  44450. * Adds a mesh into the octree block if it intersects the block
  44451. */
  44452. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44453. /**
  44454. * Adds a submesh into the octree block if it intersects the block
  44455. */
  44456. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44457. }
  44458. }
  44459. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44460. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44461. import { Scene } from "babylonjs/scene";
  44462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44464. import { Ray } from "babylonjs/Culling/ray";
  44465. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44466. import { Collider } from "babylonjs/Collisions/collider";
  44467. module "babylonjs/scene" {
  44468. interface Scene {
  44469. /**
  44470. * @hidden
  44471. * Backing Filed
  44472. */
  44473. _selectionOctree: Octree<AbstractMesh>;
  44474. /**
  44475. * Gets the octree used to boost mesh selection (picking)
  44476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44477. */
  44478. selectionOctree: Octree<AbstractMesh>;
  44479. /**
  44480. * Creates or updates the octree used to boost selection (picking)
  44481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44482. * @param maxCapacity defines the maximum capacity per leaf
  44483. * @param maxDepth defines the maximum depth of the octree
  44484. * @returns an octree of AbstractMesh
  44485. */
  44486. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44487. }
  44488. }
  44489. module "babylonjs/Meshes/abstractMesh" {
  44490. interface AbstractMesh {
  44491. /**
  44492. * @hidden
  44493. * Backing Field
  44494. */
  44495. _submeshesOctree: Octree<SubMesh>;
  44496. /**
  44497. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44498. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44499. * @param maxCapacity defines the maximum size of each block (64 by default)
  44500. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44501. * @returns the new octree
  44502. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44504. */
  44505. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44506. }
  44507. }
  44508. /**
  44509. * Defines the octree scene component responsible to manage any octrees
  44510. * in a given scene.
  44511. */
  44512. export class OctreeSceneComponent {
  44513. /**
  44514. * The component name help to identify the component in the list of scene components.
  44515. */
  44516. readonly name: string;
  44517. /**
  44518. * The scene the component belongs to.
  44519. */
  44520. scene: Scene;
  44521. /**
  44522. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44523. */
  44524. readonly checksIsEnabled: boolean;
  44525. /**
  44526. * Creates a new instance of the component for the given scene
  44527. * @param scene Defines the scene to register the component in
  44528. */
  44529. constructor(scene: Scene);
  44530. /**
  44531. * Registers the component in a given scene
  44532. */
  44533. register(): void;
  44534. /**
  44535. * Return the list of active meshes
  44536. * @returns the list of active meshes
  44537. */
  44538. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44539. /**
  44540. * Return the list of active sub meshes
  44541. * @param mesh The mesh to get the candidates sub meshes from
  44542. * @returns the list of active sub meshes
  44543. */
  44544. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44545. private _tempRay;
  44546. /**
  44547. * Return the list of sub meshes intersecting with a given local ray
  44548. * @param mesh defines the mesh to find the submesh for
  44549. * @param localRay defines the ray in local space
  44550. * @returns the list of intersecting sub meshes
  44551. */
  44552. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44553. /**
  44554. * Return the list of sub meshes colliding with a collider
  44555. * @param mesh defines the mesh to find the submesh for
  44556. * @param collider defines the collider to evaluate the collision against
  44557. * @returns the list of colliding sub meshes
  44558. */
  44559. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44560. /**
  44561. * Rebuilds the elements related to this component in case of
  44562. * context lost for instance.
  44563. */
  44564. rebuild(): void;
  44565. /**
  44566. * Disposes the component and the associated ressources.
  44567. */
  44568. dispose(): void;
  44569. }
  44570. }
  44571. declare module "babylonjs/Culling/Octrees/index" {
  44572. export * from "babylonjs/Culling/Octrees/octree";
  44573. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44574. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44575. }
  44576. declare module "babylonjs/Culling/index" {
  44577. export * from "babylonjs/Culling/boundingBox";
  44578. export * from "babylonjs/Culling/boundingInfo";
  44579. export * from "babylonjs/Culling/boundingSphere";
  44580. export * from "babylonjs/Culling/Octrees/index";
  44581. export * from "babylonjs/Culling/ray";
  44582. }
  44583. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44584. import { IDisposable, Scene } from "babylonjs/scene";
  44585. import { Nullable } from "babylonjs/types";
  44586. import { Observable } from "babylonjs/Misc/observable";
  44587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44588. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44589. import { Camera } from "babylonjs/Cameras/camera";
  44590. /**
  44591. * Renders a layer on top of an existing scene
  44592. */
  44593. export class UtilityLayerRenderer implements IDisposable {
  44594. /** the original scene that will be rendered on top of */
  44595. originalScene: Scene;
  44596. private _pointerCaptures;
  44597. private _lastPointerEvents;
  44598. private static _DefaultUtilityLayer;
  44599. private static _DefaultKeepDepthUtilityLayer;
  44600. private _sharedGizmoLight;
  44601. private _renderCamera;
  44602. /**
  44603. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44604. * @returns the camera that is used when rendering the utility layer
  44605. */
  44606. getRenderCamera(): Nullable<Camera>;
  44607. /**
  44608. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44609. * @param cam the camera that should be used when rendering the utility layer
  44610. */
  44611. setRenderCamera(cam: Nullable<Camera>): void;
  44612. /**
  44613. * @hidden
  44614. * Light which used by gizmos to get light shading
  44615. */
  44616. _getSharedGizmoLight(): HemisphericLight;
  44617. /**
  44618. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44619. */
  44620. pickUtilitySceneFirst: boolean;
  44621. /**
  44622. * 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)
  44623. */
  44624. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44625. /**
  44626. * 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)
  44627. */
  44628. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44629. /**
  44630. * The scene that is rendered on top of the original scene
  44631. */
  44632. utilityLayerScene: Scene;
  44633. /**
  44634. * If the utility layer should automatically be rendered on top of existing scene
  44635. */
  44636. shouldRender: boolean;
  44637. /**
  44638. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44639. */
  44640. onlyCheckPointerDownEvents: boolean;
  44641. /**
  44642. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44643. */
  44644. processAllEvents: boolean;
  44645. /**
  44646. * Observable raised when the pointer move from the utility layer scene to the main scene
  44647. */
  44648. onPointerOutObservable: Observable<number>;
  44649. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44650. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44651. private _afterRenderObserver;
  44652. private _sceneDisposeObserver;
  44653. private _originalPointerObserver;
  44654. /**
  44655. * Instantiates a UtilityLayerRenderer
  44656. * @param originalScene the original scene that will be rendered on top of
  44657. * @param handleEvents boolean indicating if the utility layer should handle events
  44658. */
  44659. constructor(
  44660. /** the original scene that will be rendered on top of */
  44661. originalScene: Scene, handleEvents?: boolean);
  44662. private _notifyObservers;
  44663. /**
  44664. * Renders the utility layers scene on top of the original scene
  44665. */
  44666. render(): void;
  44667. /**
  44668. * Disposes of the renderer
  44669. */
  44670. dispose(): void;
  44671. private _updateCamera;
  44672. }
  44673. }
  44674. declare module "babylonjs/Gizmos/gizmo" {
  44675. import { Nullable } from "babylonjs/types";
  44676. import { IDisposable } from "babylonjs/scene";
  44677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44678. import { Mesh } from "babylonjs/Meshes/mesh";
  44679. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44680. /**
  44681. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44682. */
  44683. export class Gizmo implements IDisposable {
  44684. /** The utility layer the gizmo will be added to */
  44685. gizmoLayer: UtilityLayerRenderer;
  44686. /**
  44687. * The root mesh of the gizmo
  44688. */
  44689. _rootMesh: Mesh;
  44690. private _attachedMesh;
  44691. /**
  44692. * Ratio for the scale of the gizmo (Default: 1)
  44693. */
  44694. scaleRatio: number;
  44695. /**
  44696. * If a custom mesh has been set (Default: false)
  44697. */
  44698. protected _customMeshSet: boolean;
  44699. /**
  44700. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44701. * * When set, interactions will be enabled
  44702. */
  44703. attachedMesh: Nullable<AbstractMesh>;
  44704. /**
  44705. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44706. * @param mesh The mesh to replace the default mesh of the gizmo
  44707. */
  44708. setCustomMesh(mesh: Mesh): void;
  44709. /**
  44710. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44711. */
  44712. updateGizmoRotationToMatchAttachedMesh: boolean;
  44713. /**
  44714. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44715. */
  44716. updateGizmoPositionToMatchAttachedMesh: boolean;
  44717. /**
  44718. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44719. */
  44720. updateScale: boolean;
  44721. protected _interactionsEnabled: boolean;
  44722. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44723. private _beforeRenderObserver;
  44724. private _tempVector;
  44725. /**
  44726. * Creates a gizmo
  44727. * @param gizmoLayer The utility layer the gizmo will be added to
  44728. */
  44729. constructor(
  44730. /** The utility layer the gizmo will be added to */
  44731. gizmoLayer?: UtilityLayerRenderer);
  44732. /**
  44733. * Updates the gizmo to match the attached mesh's position/rotation
  44734. */
  44735. protected _update(): void;
  44736. /**
  44737. * Disposes of the gizmo
  44738. */
  44739. dispose(): void;
  44740. }
  44741. }
  44742. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44743. import { Observable } from "babylonjs/Misc/observable";
  44744. import { Nullable } from "babylonjs/types";
  44745. import { Vector3 } from "babylonjs/Maths/math.vector";
  44746. import { Color3 } from "babylonjs/Maths/math.color";
  44747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44749. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44750. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44751. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44752. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44753. import { Scene } from "babylonjs/scene";
  44754. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44755. /**
  44756. * Single plane drag gizmo
  44757. */
  44758. export class PlaneDragGizmo extends Gizmo {
  44759. /**
  44760. * Drag behavior responsible for the gizmos dragging interactions
  44761. */
  44762. dragBehavior: PointerDragBehavior;
  44763. private _pointerObserver;
  44764. /**
  44765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44766. */
  44767. snapDistance: number;
  44768. /**
  44769. * Event that fires each time the gizmo snaps to a new location.
  44770. * * snapDistance is the the change in distance
  44771. */
  44772. onSnapObservable: Observable<{
  44773. snapDistance: number;
  44774. }>;
  44775. private _plane;
  44776. private _coloredMaterial;
  44777. private _hoverMaterial;
  44778. private _isEnabled;
  44779. private _parent;
  44780. /** @hidden */
  44781. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44782. /** @hidden */
  44783. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44784. /**
  44785. * Creates a PlaneDragGizmo
  44786. * @param gizmoLayer The utility layer the gizmo will be added to
  44787. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44788. * @param color The color of the gizmo
  44789. */
  44790. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44791. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44792. /**
  44793. * If the gizmo is enabled
  44794. */
  44795. isEnabled: boolean;
  44796. /**
  44797. * Disposes of the gizmo
  44798. */
  44799. dispose(): void;
  44800. }
  44801. }
  44802. declare module "babylonjs/Gizmos/positionGizmo" {
  44803. import { Observable } from "babylonjs/Misc/observable";
  44804. import { Nullable } from "babylonjs/types";
  44805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44806. import { Mesh } from "babylonjs/Meshes/mesh";
  44807. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44808. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44809. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44810. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44811. /**
  44812. * Gizmo that enables dragging a mesh along 3 axis
  44813. */
  44814. export class PositionGizmo extends Gizmo {
  44815. /**
  44816. * Internal gizmo used for interactions on the x axis
  44817. */
  44818. xGizmo: AxisDragGizmo;
  44819. /**
  44820. * Internal gizmo used for interactions on the y axis
  44821. */
  44822. yGizmo: AxisDragGizmo;
  44823. /**
  44824. * Internal gizmo used for interactions on the z axis
  44825. */
  44826. zGizmo: AxisDragGizmo;
  44827. /**
  44828. * Internal gizmo used for interactions on the yz plane
  44829. */
  44830. xPlaneGizmo: PlaneDragGizmo;
  44831. /**
  44832. * Internal gizmo used for interactions on the xz plane
  44833. */
  44834. yPlaneGizmo: PlaneDragGizmo;
  44835. /**
  44836. * Internal gizmo used for interactions on the xy plane
  44837. */
  44838. zPlaneGizmo: PlaneDragGizmo;
  44839. /**
  44840. * private variables
  44841. */
  44842. private _meshAttached;
  44843. private _updateGizmoRotationToMatchAttachedMesh;
  44844. private _snapDistance;
  44845. private _scaleRatio;
  44846. /** Fires an event when any of it's sub gizmos are dragged */
  44847. onDragStartObservable: Observable<unknown>;
  44848. /** Fires an event when any of it's sub gizmos are released from dragging */
  44849. onDragEndObservable: Observable<unknown>;
  44850. /**
  44851. * If set to true, planar drag is enabled
  44852. */
  44853. private _planarGizmoEnabled;
  44854. attachedMesh: Nullable<AbstractMesh>;
  44855. /**
  44856. * Creates a PositionGizmo
  44857. * @param gizmoLayer The utility layer the gizmo will be added to
  44858. */
  44859. constructor(gizmoLayer?: UtilityLayerRenderer);
  44860. /**
  44861. * If the planar drag gizmo is enabled
  44862. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44863. */
  44864. planarGizmoEnabled: boolean;
  44865. updateGizmoRotationToMatchAttachedMesh: boolean;
  44866. /**
  44867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44868. */
  44869. snapDistance: number;
  44870. /**
  44871. * Ratio for the scale of the gizmo (Default: 1)
  44872. */
  44873. scaleRatio: number;
  44874. /**
  44875. * Disposes of the gizmo
  44876. */
  44877. dispose(): void;
  44878. /**
  44879. * CustomMeshes are not supported by this gizmo
  44880. * @param mesh The mesh to replace the default mesh of the gizmo
  44881. */
  44882. setCustomMesh(mesh: Mesh): void;
  44883. }
  44884. }
  44885. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44886. import { Observable } from "babylonjs/Misc/observable";
  44887. import { Nullable } from "babylonjs/types";
  44888. import { Vector3 } from "babylonjs/Maths/math.vector";
  44889. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44891. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44892. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44893. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44894. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44895. import { Scene } from "babylonjs/scene";
  44896. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44897. import { Color3 } from "babylonjs/Maths/math.color";
  44898. /**
  44899. * Single axis drag gizmo
  44900. */
  44901. export class AxisDragGizmo extends Gizmo {
  44902. /**
  44903. * Drag behavior responsible for the gizmos dragging interactions
  44904. */
  44905. dragBehavior: PointerDragBehavior;
  44906. private _pointerObserver;
  44907. /**
  44908. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44909. */
  44910. snapDistance: number;
  44911. /**
  44912. * Event that fires each time the gizmo snaps to a new location.
  44913. * * snapDistance is the the change in distance
  44914. */
  44915. onSnapObservable: Observable<{
  44916. snapDistance: number;
  44917. }>;
  44918. private _isEnabled;
  44919. private _parent;
  44920. private _arrow;
  44921. private _coloredMaterial;
  44922. private _hoverMaterial;
  44923. /** @hidden */
  44924. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44925. /** @hidden */
  44926. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44927. /**
  44928. * Creates an AxisDragGizmo
  44929. * @param gizmoLayer The utility layer the gizmo will be added to
  44930. * @param dragAxis The axis which the gizmo will be able to drag on
  44931. * @param color The color of the gizmo
  44932. */
  44933. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44934. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44935. /**
  44936. * If the gizmo is enabled
  44937. */
  44938. isEnabled: boolean;
  44939. /**
  44940. * Disposes of the gizmo
  44941. */
  44942. dispose(): void;
  44943. }
  44944. }
  44945. declare module "babylonjs/Debug/axesViewer" {
  44946. import { Vector3 } from "babylonjs/Maths/math.vector";
  44947. import { Nullable } from "babylonjs/types";
  44948. import { Scene } from "babylonjs/scene";
  44949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44950. /**
  44951. * The Axes viewer will show 3 axes in a specific point in space
  44952. */
  44953. export class AxesViewer {
  44954. private _xAxis;
  44955. private _yAxis;
  44956. private _zAxis;
  44957. private _scaleLinesFactor;
  44958. private _instanced;
  44959. /**
  44960. * Gets the hosting scene
  44961. */
  44962. scene: Scene;
  44963. /**
  44964. * Gets or sets a number used to scale line length
  44965. */
  44966. scaleLines: number;
  44967. /** Gets the node hierarchy used to render x-axis */
  44968. readonly xAxis: TransformNode;
  44969. /** Gets the node hierarchy used to render y-axis */
  44970. readonly yAxis: TransformNode;
  44971. /** Gets the node hierarchy used to render z-axis */
  44972. readonly zAxis: TransformNode;
  44973. /**
  44974. * Creates a new AxesViewer
  44975. * @param scene defines the hosting scene
  44976. * @param scaleLines defines a number used to scale line length (1 by default)
  44977. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44978. * @param xAxis defines the node hierarchy used to render the x-axis
  44979. * @param yAxis defines the node hierarchy used to render the y-axis
  44980. * @param zAxis defines the node hierarchy used to render the z-axis
  44981. */
  44982. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44983. /**
  44984. * Force the viewer to update
  44985. * @param position defines the position of the viewer
  44986. * @param xaxis defines the x axis of the viewer
  44987. * @param yaxis defines the y axis of the viewer
  44988. * @param zaxis defines the z axis of the viewer
  44989. */
  44990. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44991. /**
  44992. * Creates an instance of this axes viewer.
  44993. * @returns a new axes viewer with instanced meshes
  44994. */
  44995. createInstance(): AxesViewer;
  44996. /** Releases resources */
  44997. dispose(): void;
  44998. private static _SetRenderingGroupId;
  44999. }
  45000. }
  45001. declare module "babylonjs/Debug/boneAxesViewer" {
  45002. import { Nullable } from "babylonjs/types";
  45003. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45004. import { Vector3 } from "babylonjs/Maths/math.vector";
  45005. import { Mesh } from "babylonjs/Meshes/mesh";
  45006. import { Bone } from "babylonjs/Bones/bone";
  45007. import { Scene } from "babylonjs/scene";
  45008. /**
  45009. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45010. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45011. */
  45012. export class BoneAxesViewer extends AxesViewer {
  45013. /**
  45014. * Gets or sets the target mesh where to display the axes viewer
  45015. */
  45016. mesh: Nullable<Mesh>;
  45017. /**
  45018. * Gets or sets the target bone where to display the axes viewer
  45019. */
  45020. bone: Nullable<Bone>;
  45021. /** Gets current position */
  45022. pos: Vector3;
  45023. /** Gets direction of X axis */
  45024. xaxis: Vector3;
  45025. /** Gets direction of Y axis */
  45026. yaxis: Vector3;
  45027. /** Gets direction of Z axis */
  45028. zaxis: Vector3;
  45029. /**
  45030. * Creates a new BoneAxesViewer
  45031. * @param scene defines the hosting scene
  45032. * @param bone defines the target bone
  45033. * @param mesh defines the target mesh
  45034. * @param scaleLines defines a scaling factor for line length (1 by default)
  45035. */
  45036. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45037. /**
  45038. * Force the viewer to update
  45039. */
  45040. update(): void;
  45041. /** Releases resources */
  45042. dispose(): void;
  45043. }
  45044. }
  45045. declare module "babylonjs/Debug/debugLayer" {
  45046. import { Scene } from "babylonjs/scene";
  45047. /**
  45048. * Interface used to define scene explorer extensibility option
  45049. */
  45050. export interface IExplorerExtensibilityOption {
  45051. /**
  45052. * Define the option label
  45053. */
  45054. label: string;
  45055. /**
  45056. * Defines the action to execute on click
  45057. */
  45058. action: (entity: any) => void;
  45059. }
  45060. /**
  45061. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45062. */
  45063. export interface IExplorerExtensibilityGroup {
  45064. /**
  45065. * Defines a predicate to test if a given type mut be extended
  45066. */
  45067. predicate: (entity: any) => boolean;
  45068. /**
  45069. * Gets the list of options added to a type
  45070. */
  45071. entries: IExplorerExtensibilityOption[];
  45072. }
  45073. /**
  45074. * Interface used to define the options to use to create the Inspector
  45075. */
  45076. export interface IInspectorOptions {
  45077. /**
  45078. * Display in overlay mode (default: false)
  45079. */
  45080. overlay?: boolean;
  45081. /**
  45082. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45083. */
  45084. globalRoot?: HTMLElement;
  45085. /**
  45086. * Display the Scene explorer
  45087. */
  45088. showExplorer?: boolean;
  45089. /**
  45090. * Display the property inspector
  45091. */
  45092. showInspector?: boolean;
  45093. /**
  45094. * Display in embed mode (both panes on the right)
  45095. */
  45096. embedMode?: boolean;
  45097. /**
  45098. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45099. */
  45100. handleResize?: boolean;
  45101. /**
  45102. * Allow the panes to popup (default: true)
  45103. */
  45104. enablePopup?: boolean;
  45105. /**
  45106. * Allow the panes to be closed by users (default: true)
  45107. */
  45108. enableClose?: boolean;
  45109. /**
  45110. * Optional list of extensibility entries
  45111. */
  45112. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45113. /**
  45114. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45115. */
  45116. inspectorURL?: string;
  45117. }
  45118. module "babylonjs/scene" {
  45119. interface Scene {
  45120. /**
  45121. * @hidden
  45122. * Backing field
  45123. */
  45124. _debugLayer: DebugLayer;
  45125. /**
  45126. * Gets the debug layer (aka Inspector) associated with the scene
  45127. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45128. */
  45129. debugLayer: DebugLayer;
  45130. }
  45131. }
  45132. /**
  45133. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45134. * what is happening in your scene
  45135. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45136. */
  45137. export class DebugLayer {
  45138. /**
  45139. * Define the url to get the inspector script from.
  45140. * By default it uses the babylonjs CDN.
  45141. * @ignoreNaming
  45142. */
  45143. static InspectorURL: string;
  45144. private _scene;
  45145. private BJSINSPECTOR;
  45146. private _onPropertyChangedObservable?;
  45147. /**
  45148. * Observable triggered when a property is changed through the inspector.
  45149. */
  45150. readonly onPropertyChangedObservable: any;
  45151. /**
  45152. * Instantiates a new debug layer.
  45153. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45154. * what is happening in your scene
  45155. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45156. * @param scene Defines the scene to inspect
  45157. */
  45158. constructor(scene: Scene);
  45159. /** Creates the inspector window. */
  45160. private _createInspector;
  45161. /**
  45162. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45163. * @param entity defines the entity to select
  45164. * @param lineContainerTitle defines the specific block to highlight
  45165. */
  45166. select(entity: any, lineContainerTitle?: string): void;
  45167. /** Get the inspector from bundle or global */
  45168. private _getGlobalInspector;
  45169. /**
  45170. * Get if the inspector is visible or not.
  45171. * @returns true if visible otherwise, false
  45172. */
  45173. isVisible(): boolean;
  45174. /**
  45175. * Hide the inspector and close its window.
  45176. */
  45177. hide(): void;
  45178. /**
  45179. * Launch the debugLayer.
  45180. * @param config Define the configuration of the inspector
  45181. * @return a promise fulfilled when the debug layer is visible
  45182. */
  45183. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45184. }
  45185. }
  45186. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45187. import { Nullable } from "babylonjs/types";
  45188. import { Scene } from "babylonjs/scene";
  45189. import { Vector4 } from "babylonjs/Maths/math.vector";
  45190. import { Color4 } from "babylonjs/Maths/math.color";
  45191. import { Mesh } from "babylonjs/Meshes/mesh";
  45192. /**
  45193. * Class containing static functions to help procedurally build meshes
  45194. */
  45195. export class BoxBuilder {
  45196. /**
  45197. * Creates a box mesh
  45198. * * The parameter `size` sets the size (float) of each box side (default 1)
  45199. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45200. * * 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)
  45201. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45205. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45206. * @param name defines the name of the mesh
  45207. * @param options defines the options used to create the mesh
  45208. * @param scene defines the hosting scene
  45209. * @returns the box mesh
  45210. */
  45211. static CreateBox(name: string, options: {
  45212. size?: number;
  45213. width?: number;
  45214. height?: number;
  45215. depth?: number;
  45216. faceUV?: Vector4[];
  45217. faceColors?: Color4[];
  45218. sideOrientation?: number;
  45219. frontUVs?: Vector4;
  45220. backUVs?: Vector4;
  45221. wrap?: boolean;
  45222. topBaseAt?: number;
  45223. bottomBaseAt?: number;
  45224. updatable?: boolean;
  45225. }, scene?: Nullable<Scene>): Mesh;
  45226. }
  45227. }
  45228. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45229. import { Vector4 } from "babylonjs/Maths/math.vector";
  45230. import { Mesh } from "babylonjs/Meshes/mesh";
  45231. import { Scene } from "babylonjs/scene";
  45232. import { Nullable } from "babylonjs/types";
  45233. /**
  45234. * Class containing static functions to help procedurally build meshes
  45235. */
  45236. export class SphereBuilder {
  45237. /**
  45238. * Creates a sphere mesh
  45239. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45240. * * 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`)
  45241. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45242. * * 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
  45243. * * 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)
  45244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45247. * @param name defines the name of the mesh
  45248. * @param options defines the options used to create the mesh
  45249. * @param scene defines the hosting scene
  45250. * @returns the sphere mesh
  45251. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45252. */
  45253. static CreateSphere(name: string, options: {
  45254. segments?: number;
  45255. diameter?: number;
  45256. diameterX?: number;
  45257. diameterY?: number;
  45258. diameterZ?: number;
  45259. arc?: number;
  45260. slice?: number;
  45261. sideOrientation?: number;
  45262. frontUVs?: Vector4;
  45263. backUVs?: Vector4;
  45264. updatable?: boolean;
  45265. }, scene?: Nullable<Scene>): Mesh;
  45266. }
  45267. }
  45268. declare module "babylonjs/Debug/physicsViewer" {
  45269. import { Nullable } from "babylonjs/types";
  45270. import { Scene } from "babylonjs/scene";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import { Mesh } from "babylonjs/Meshes/mesh";
  45273. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45274. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45275. /**
  45276. * Used to show the physics impostor around the specific mesh
  45277. */
  45278. export class PhysicsViewer {
  45279. /** @hidden */
  45280. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45281. /** @hidden */
  45282. protected _meshes: Array<Nullable<AbstractMesh>>;
  45283. /** @hidden */
  45284. protected _scene: Nullable<Scene>;
  45285. /** @hidden */
  45286. protected _numMeshes: number;
  45287. /** @hidden */
  45288. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45289. private _renderFunction;
  45290. private _utilityLayer;
  45291. private _debugBoxMesh;
  45292. private _debugSphereMesh;
  45293. private _debugCylinderMesh;
  45294. private _debugMaterial;
  45295. private _debugMeshMeshes;
  45296. /**
  45297. * Creates a new PhysicsViewer
  45298. * @param scene defines the hosting scene
  45299. */
  45300. constructor(scene: Scene);
  45301. /** @hidden */
  45302. protected _updateDebugMeshes(): void;
  45303. /**
  45304. * Renders a specified physic impostor
  45305. * @param impostor defines the impostor to render
  45306. * @param targetMesh defines the mesh represented by the impostor
  45307. * @returns the new debug mesh used to render the impostor
  45308. */
  45309. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45310. /**
  45311. * Hides a specified physic impostor
  45312. * @param impostor defines the impostor to hide
  45313. */
  45314. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45315. private _getDebugMaterial;
  45316. private _getDebugBoxMesh;
  45317. private _getDebugSphereMesh;
  45318. private _getDebugCylinderMesh;
  45319. private _getDebugMeshMesh;
  45320. private _getDebugMesh;
  45321. /** Releases all resources */
  45322. dispose(): void;
  45323. }
  45324. }
  45325. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45326. import { Vector3 } from "babylonjs/Maths/math.vector";
  45327. import { Color4 } from "babylonjs/Maths/math.color";
  45328. import { Nullable } from "babylonjs/types";
  45329. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45330. import { Scene } from "babylonjs/scene";
  45331. /**
  45332. * Class containing static functions to help procedurally build meshes
  45333. */
  45334. export class LinesBuilder {
  45335. /**
  45336. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45337. * * 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
  45338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45339. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45340. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45341. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45343. * * 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
  45344. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45347. * @param name defines the name of the new line system
  45348. * @param options defines the options used to create the line system
  45349. * @param scene defines the hosting scene
  45350. * @returns a new line system mesh
  45351. */
  45352. static CreateLineSystem(name: string, options: {
  45353. lines: Vector3[][];
  45354. updatable?: boolean;
  45355. instance?: Nullable<LinesMesh>;
  45356. colors?: Nullable<Color4[][]>;
  45357. useVertexAlpha?: boolean;
  45358. }, scene: Nullable<Scene>): LinesMesh;
  45359. /**
  45360. * Creates a line mesh
  45361. * 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
  45362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45363. * * The parameter `points` is an array successive Vector3
  45364. * * 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
  45365. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45367. * * When updating an instance, remember that only point positions can change, not the number of points
  45368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45370. * @param name defines the name of the new line system
  45371. * @param options defines the options used to create the line system
  45372. * @param scene defines the hosting scene
  45373. * @returns a new line mesh
  45374. */
  45375. static CreateLines(name: string, options: {
  45376. points: Vector3[];
  45377. updatable?: boolean;
  45378. instance?: Nullable<LinesMesh>;
  45379. colors?: Color4[];
  45380. useVertexAlpha?: boolean;
  45381. }, scene?: Nullable<Scene>): LinesMesh;
  45382. /**
  45383. * Creates a dashed line mesh
  45384. * * 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
  45385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45386. * * The parameter `points` is an array successive Vector3
  45387. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45388. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45389. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45390. * * 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
  45391. * * When updating an instance, remember that only point positions can change, not the number of points
  45392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45393. * @param name defines the name of the mesh
  45394. * @param options defines the options used to create the mesh
  45395. * @param scene defines the hosting scene
  45396. * @returns the dashed line mesh
  45397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45398. */
  45399. static CreateDashedLines(name: string, options: {
  45400. points: Vector3[];
  45401. dashSize?: number;
  45402. gapSize?: number;
  45403. dashNb?: number;
  45404. updatable?: boolean;
  45405. instance?: LinesMesh;
  45406. }, scene?: Nullable<Scene>): LinesMesh;
  45407. }
  45408. }
  45409. declare module "babylonjs/Debug/rayHelper" {
  45410. import { Nullable } from "babylonjs/types";
  45411. import { Ray } from "babylonjs/Culling/ray";
  45412. import { Vector3 } from "babylonjs/Maths/math.vector";
  45413. import { Color3 } from "babylonjs/Maths/math.color";
  45414. import { Scene } from "babylonjs/scene";
  45415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45416. import "babylonjs/Meshes/Builders/linesBuilder";
  45417. /**
  45418. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45419. * in order to better appreciate the issue one might have.
  45420. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45421. */
  45422. export class RayHelper {
  45423. /**
  45424. * Defines the ray we are currently tryin to visualize.
  45425. */
  45426. ray: Nullable<Ray>;
  45427. private _renderPoints;
  45428. private _renderLine;
  45429. private _renderFunction;
  45430. private _scene;
  45431. private _updateToMeshFunction;
  45432. private _attachedToMesh;
  45433. private _meshSpaceDirection;
  45434. private _meshSpaceOrigin;
  45435. /**
  45436. * Helper function to create a colored helper in a scene in one line.
  45437. * @param ray Defines the ray we are currently tryin to visualize
  45438. * @param scene Defines the scene the ray is used in
  45439. * @param color Defines the color we want to see the ray in
  45440. * @returns The newly created ray helper.
  45441. */
  45442. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45443. /**
  45444. * Instantiate a new ray helper.
  45445. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45446. * in order to better appreciate the issue one might have.
  45447. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45448. * @param ray Defines the ray we are currently tryin to visualize
  45449. */
  45450. constructor(ray: Ray);
  45451. /**
  45452. * Shows the ray we are willing to debug.
  45453. * @param scene Defines the scene the ray needs to be rendered in
  45454. * @param color Defines the color the ray needs to be rendered in
  45455. */
  45456. show(scene: Scene, color?: Color3): void;
  45457. /**
  45458. * Hides the ray we are debugging.
  45459. */
  45460. hide(): void;
  45461. private _render;
  45462. /**
  45463. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45464. * @param mesh Defines the mesh we want the helper attached to
  45465. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45466. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45467. * @param length Defines the length of the ray
  45468. */
  45469. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45470. /**
  45471. * Detach the ray helper from the mesh it has previously been attached to.
  45472. */
  45473. detachFromMesh(): void;
  45474. private _updateToMesh;
  45475. /**
  45476. * Dispose the helper and release its associated resources.
  45477. */
  45478. dispose(): void;
  45479. }
  45480. }
  45481. declare module "babylonjs/Debug/skeletonViewer" {
  45482. import { Color3 } from "babylonjs/Maths/math.color";
  45483. import { Scene } from "babylonjs/scene";
  45484. import { Nullable } from "babylonjs/types";
  45485. import { Skeleton } from "babylonjs/Bones/skeleton";
  45486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45487. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45488. /**
  45489. * Class used to render a debug view of a given skeleton
  45490. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45491. */
  45492. export class SkeletonViewer {
  45493. /** defines the skeleton to render */
  45494. skeleton: Skeleton;
  45495. /** defines the mesh attached to the skeleton */
  45496. mesh: AbstractMesh;
  45497. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45498. autoUpdateBonesMatrices: boolean;
  45499. /** defines the rendering group id to use with the viewer */
  45500. renderingGroupId: number;
  45501. /** Gets or sets the color used to render the skeleton */
  45502. color: Color3;
  45503. private _scene;
  45504. private _debugLines;
  45505. private _debugMesh;
  45506. private _isEnabled;
  45507. private _renderFunction;
  45508. private _utilityLayer;
  45509. /**
  45510. * Returns the mesh used to render the bones
  45511. */
  45512. readonly debugMesh: Nullable<LinesMesh>;
  45513. /**
  45514. * Creates a new SkeletonViewer
  45515. * @param skeleton defines the skeleton to render
  45516. * @param mesh defines the mesh attached to the skeleton
  45517. * @param scene defines the hosting scene
  45518. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45519. * @param renderingGroupId defines the rendering group id to use with the viewer
  45520. */
  45521. constructor(
  45522. /** defines the skeleton to render */
  45523. skeleton: Skeleton,
  45524. /** defines the mesh attached to the skeleton */
  45525. mesh: AbstractMesh, scene: Scene,
  45526. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45527. autoUpdateBonesMatrices?: boolean,
  45528. /** defines the rendering group id to use with the viewer */
  45529. renderingGroupId?: number);
  45530. /** Gets or sets a boolean indicating if the viewer is enabled */
  45531. isEnabled: boolean;
  45532. private _getBonePosition;
  45533. private _getLinesForBonesWithLength;
  45534. private _getLinesForBonesNoLength;
  45535. /** Update the viewer to sync with current skeleton state */
  45536. update(): void;
  45537. /** Release associated resources */
  45538. dispose(): void;
  45539. }
  45540. }
  45541. declare module "babylonjs/Debug/index" {
  45542. export * from "babylonjs/Debug/axesViewer";
  45543. export * from "babylonjs/Debug/boneAxesViewer";
  45544. export * from "babylonjs/Debug/debugLayer";
  45545. export * from "babylonjs/Debug/physicsViewer";
  45546. export * from "babylonjs/Debug/rayHelper";
  45547. export * from "babylonjs/Debug/skeletonViewer";
  45548. }
  45549. declare module "babylonjs/Engines/nullEngine" {
  45550. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45551. import { Scene } from "babylonjs/scene";
  45552. import { Engine } from "babylonjs/Engines/engine";
  45553. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45554. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45556. import { Effect } from "babylonjs/Materials/effect";
  45557. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45559. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45560. /**
  45561. * Options to create the null engine
  45562. */
  45563. export class NullEngineOptions {
  45564. /**
  45565. * Render width (Default: 512)
  45566. */
  45567. renderWidth: number;
  45568. /**
  45569. * Render height (Default: 256)
  45570. */
  45571. renderHeight: number;
  45572. /**
  45573. * Texture size (Default: 512)
  45574. */
  45575. textureSize: number;
  45576. /**
  45577. * If delta time between frames should be constant
  45578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45579. */
  45580. deterministicLockstep: boolean;
  45581. /**
  45582. * Maximum about of steps between frames (Default: 4)
  45583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45584. */
  45585. lockstepMaxSteps: number;
  45586. }
  45587. /**
  45588. * The null engine class provides support for headless version of babylon.js.
  45589. * This can be used in server side scenario or for testing purposes
  45590. */
  45591. export class NullEngine extends Engine {
  45592. private _options;
  45593. /**
  45594. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45595. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45596. * @returns true if engine is in deterministic lock step mode
  45597. */
  45598. isDeterministicLockStep(): boolean;
  45599. /**
  45600. * Gets the max steps when engine is running in deterministic lock step
  45601. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45602. * @returns the max steps
  45603. */
  45604. getLockstepMaxSteps(): number;
  45605. /**
  45606. * Gets the current hardware scaling level.
  45607. * By default the hardware scaling level is computed from the window device ratio.
  45608. * 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.
  45609. * @returns a number indicating the current hardware scaling level
  45610. */
  45611. getHardwareScalingLevel(): number;
  45612. constructor(options?: NullEngineOptions);
  45613. /**
  45614. * Creates a vertex buffer
  45615. * @param vertices the data for the vertex buffer
  45616. * @returns the new WebGL static buffer
  45617. */
  45618. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45619. /**
  45620. * Creates a new index buffer
  45621. * @param indices defines the content of the index buffer
  45622. * @param updatable defines if the index buffer must be updatable
  45623. * @returns a new webGL buffer
  45624. */
  45625. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45626. /**
  45627. * Clear the current render buffer or the current render target (if any is set up)
  45628. * @param color defines the color to use
  45629. * @param backBuffer defines if the back buffer must be cleared
  45630. * @param depth defines if the depth buffer must be cleared
  45631. * @param stencil defines if the stencil buffer must be cleared
  45632. */
  45633. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45634. /**
  45635. * Gets the current render width
  45636. * @param useScreen defines if screen size must be used (or the current render target if any)
  45637. * @returns a number defining the current render width
  45638. */
  45639. getRenderWidth(useScreen?: boolean): number;
  45640. /**
  45641. * Gets the current render height
  45642. * @param useScreen defines if screen size must be used (or the current render target if any)
  45643. * @returns a number defining the current render height
  45644. */
  45645. getRenderHeight(useScreen?: boolean): number;
  45646. /**
  45647. * Set the WebGL's viewport
  45648. * @param viewport defines the viewport element to be used
  45649. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45650. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45651. */
  45652. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45653. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45654. /**
  45655. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45656. * @param pipelineContext defines the pipeline context to use
  45657. * @param uniformsNames defines the list of uniform names
  45658. * @returns an array of webGL uniform locations
  45659. */
  45660. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45661. /**
  45662. * Gets the lsit of active attributes for a given webGL program
  45663. * @param pipelineContext defines the pipeline context to use
  45664. * @param attributesNames defines the list of attribute names to get
  45665. * @returns an array of indices indicating the offset of each attribute
  45666. */
  45667. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45668. /**
  45669. * Binds an effect to the webGL context
  45670. * @param effect defines the effect to bind
  45671. */
  45672. bindSamplers(effect: Effect): void;
  45673. /**
  45674. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45675. * @param effect defines the effect to activate
  45676. */
  45677. enableEffect(effect: Effect): void;
  45678. /**
  45679. * Set various states to the webGL context
  45680. * @param culling defines backface culling state
  45681. * @param zOffset defines the value to apply to zOffset (0 by default)
  45682. * @param force defines if states must be applied even if cache is up to date
  45683. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45684. */
  45685. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45686. /**
  45687. * Set the value of an uniform to an array of int32
  45688. * @param uniform defines the webGL uniform location where to store the value
  45689. * @param array defines the array of int32 to store
  45690. */
  45691. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45692. /**
  45693. * Set the value of an uniform to an array of int32 (stored as vec2)
  45694. * @param uniform defines the webGL uniform location where to store the value
  45695. * @param array defines the array of int32 to store
  45696. */
  45697. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45698. /**
  45699. * Set the value of an uniform to an array of int32 (stored as vec3)
  45700. * @param uniform defines the webGL uniform location where to store the value
  45701. * @param array defines the array of int32 to store
  45702. */
  45703. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45704. /**
  45705. * Set the value of an uniform to an array of int32 (stored as vec4)
  45706. * @param uniform defines the webGL uniform location where to store the value
  45707. * @param array defines the array of int32 to store
  45708. */
  45709. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45710. /**
  45711. * Set the value of an uniform to an array of float32
  45712. * @param uniform defines the webGL uniform location where to store the value
  45713. * @param array defines the array of float32 to store
  45714. */
  45715. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45716. /**
  45717. * Set the value of an uniform to an array of float32 (stored as vec2)
  45718. * @param uniform defines the webGL uniform location where to store the value
  45719. * @param array defines the array of float32 to store
  45720. */
  45721. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45722. /**
  45723. * Set the value of an uniform to an array of float32 (stored as vec3)
  45724. * @param uniform defines the webGL uniform location where to store the value
  45725. * @param array defines the array of float32 to store
  45726. */
  45727. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45728. /**
  45729. * Set the value of an uniform to an array of float32 (stored as vec4)
  45730. * @param uniform defines the webGL uniform location where to store the value
  45731. * @param array defines the array of float32 to store
  45732. */
  45733. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45734. /**
  45735. * Set the value of an uniform to an array of number
  45736. * @param uniform defines the webGL uniform location where to store the value
  45737. * @param array defines the array of number to store
  45738. */
  45739. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45740. /**
  45741. * Set the value of an uniform to an array of number (stored as vec2)
  45742. * @param uniform defines the webGL uniform location where to store the value
  45743. * @param array defines the array of number to store
  45744. */
  45745. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45746. /**
  45747. * Set the value of an uniform to an array of number (stored as vec3)
  45748. * @param uniform defines the webGL uniform location where to store the value
  45749. * @param array defines the array of number to store
  45750. */
  45751. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45752. /**
  45753. * Set the value of an uniform to an array of number (stored as vec4)
  45754. * @param uniform defines the webGL uniform location where to store the value
  45755. * @param array defines the array of number to store
  45756. */
  45757. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45758. /**
  45759. * Set the value of an uniform to an array of float32 (stored as matrices)
  45760. * @param uniform defines the webGL uniform location where to store the value
  45761. * @param matrices defines the array of float32 to store
  45762. */
  45763. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45764. /**
  45765. * Set the value of an uniform to a matrix (3x3)
  45766. * @param uniform defines the webGL uniform location where to store the value
  45767. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45768. */
  45769. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45770. /**
  45771. * Set the value of an uniform to a matrix (2x2)
  45772. * @param uniform defines the webGL uniform location where to store the value
  45773. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45774. */
  45775. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45776. /**
  45777. * Set the value of an uniform to a number (float)
  45778. * @param uniform defines the webGL uniform location where to store the value
  45779. * @param value defines the float number to store
  45780. */
  45781. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45782. /**
  45783. * Set the value of an uniform to a vec2
  45784. * @param uniform defines the webGL uniform location where to store the value
  45785. * @param x defines the 1st component of the value
  45786. * @param y defines the 2nd component of the value
  45787. */
  45788. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45789. /**
  45790. * Set the value of an uniform to a vec3
  45791. * @param uniform defines the webGL uniform location where to store the value
  45792. * @param x defines the 1st component of the value
  45793. * @param y defines the 2nd component of the value
  45794. * @param z defines the 3rd component of the value
  45795. */
  45796. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45797. /**
  45798. * Set the value of an uniform to a boolean
  45799. * @param uniform defines the webGL uniform location where to store the value
  45800. * @param bool defines the boolean to store
  45801. */
  45802. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45803. /**
  45804. * Set the value of an uniform to a vec4
  45805. * @param uniform defines the webGL uniform location where to store the value
  45806. * @param x defines the 1st component of the value
  45807. * @param y defines the 2nd component of the value
  45808. * @param z defines the 3rd component of the value
  45809. * @param w defines the 4th component of the value
  45810. */
  45811. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45812. /**
  45813. * Sets the current alpha mode
  45814. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45815. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45816. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45817. */
  45818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45819. /**
  45820. * Bind webGl buffers directly to the webGL context
  45821. * @param vertexBuffers defines the vertex buffer to bind
  45822. * @param indexBuffer defines the index buffer to bind
  45823. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45824. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45825. * @param effect defines the effect associated with the vertex buffer
  45826. */
  45827. bindBuffers(vertexBuffers: {
  45828. [key: string]: VertexBuffer;
  45829. }, indexBuffer: DataBuffer, effect: Effect): void;
  45830. /**
  45831. * Force the entire cache to be cleared
  45832. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45833. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45834. */
  45835. wipeCaches(bruteForce?: boolean): void;
  45836. /**
  45837. * Send a draw order
  45838. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45839. * @param indexStart defines the starting index
  45840. * @param indexCount defines the number of index to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45844. /**
  45845. * Draw a list of indexed primitives
  45846. * @param fillMode defines the primitive to use
  45847. * @param indexStart defines the starting index
  45848. * @param indexCount defines the number of index to draw
  45849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45850. */
  45851. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45852. /**
  45853. * Draw a list of unindexed primitives
  45854. * @param fillMode defines the primitive to use
  45855. * @param verticesStart defines the index of first vertex to draw
  45856. * @param verticesCount defines the count of vertices to draw
  45857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45858. */
  45859. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45860. /** @hidden */
  45861. _createTexture(): WebGLTexture;
  45862. /** @hidden */
  45863. _releaseTexture(texture: InternalTexture): void;
  45864. /**
  45865. * Usually called from Texture.ts.
  45866. * Passed information to create a WebGLTexture
  45867. * @param urlArg defines a value which contains one of the following:
  45868. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45869. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45870. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45872. * @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)
  45873. * @param scene needed for loading to the correct scene
  45874. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45875. * @param onLoad optional callback to be called upon successful completion
  45876. * @param onError optional callback to be called upon failure
  45877. * @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
  45878. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45879. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45880. * @param forcedExtension defines the extension to use to pick the right loader
  45881. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45882. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45883. */
  45884. 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;
  45885. /**
  45886. * Creates a new render target texture
  45887. * @param size defines the size of the texture
  45888. * @param options defines the options used to create the texture
  45889. * @returns a new render target texture stored in an InternalTexture
  45890. */
  45891. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45892. /**
  45893. * Update the sampling mode of a given texture
  45894. * @param samplingMode defines the required sampling mode
  45895. * @param texture defines the texture to update
  45896. */
  45897. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45898. /**
  45899. * Binds the frame buffer to the specified texture.
  45900. * @param texture The texture to render to or null for the default canvas
  45901. * @param faceIndex The face of the texture to render to in case of cube texture
  45902. * @param requiredWidth The width of the target to render to
  45903. * @param requiredHeight The height of the target to render to
  45904. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45905. * @param depthStencilTexture The depth stencil texture to use to render
  45906. * @param lodLevel defines le lod level to bind to the frame buffer
  45907. */
  45908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45909. /**
  45910. * Unbind the current render target texture from the webGL context
  45911. * @param texture defines the render target texture to unbind
  45912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45914. */
  45915. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45916. /**
  45917. * Creates a dynamic vertex buffer
  45918. * @param vertices the data for the dynamic vertex buffer
  45919. * @returns the new WebGL dynamic buffer
  45920. */
  45921. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45922. /**
  45923. * Update the content of a dynamic texture
  45924. * @param texture defines the texture to update
  45925. * @param canvas defines the canvas containing the source
  45926. * @param invertY defines if data must be stored with Y axis inverted
  45927. * @param premulAlpha defines if alpha is stored as premultiplied
  45928. * @param format defines the format of the data
  45929. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45930. */
  45931. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45932. /**
  45933. * Gets a boolean indicating if all created effects are ready
  45934. * @returns true if all effects are ready
  45935. */
  45936. areAllEffectsReady(): boolean;
  45937. /**
  45938. * @hidden
  45939. * Get the current error code of the webGL context
  45940. * @returns the error code
  45941. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45942. */
  45943. getError(): number;
  45944. /** @hidden */
  45945. _getUnpackAlignement(): number;
  45946. /** @hidden */
  45947. _unpackFlipY(value: boolean): void;
  45948. /**
  45949. * Update a dynamic index buffer
  45950. * @param indexBuffer defines the target index buffer
  45951. * @param indices defines the data to update
  45952. * @param offset defines the offset in the target index buffer where update should start
  45953. */
  45954. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45955. /**
  45956. * Updates a dynamic vertex buffer.
  45957. * @param vertexBuffer the vertex buffer to update
  45958. * @param vertices the data used to update the vertex buffer
  45959. * @param byteOffset the byte offset of the data (optional)
  45960. * @param byteLength the byte length of the data (optional)
  45961. */
  45962. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45963. /** @hidden */
  45964. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45965. /** @hidden */
  45966. _bindTexture(channel: number, texture: InternalTexture): void;
  45967. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45968. /**
  45969. * 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
  45970. */
  45971. releaseEffects(): void;
  45972. displayLoadingUI(): void;
  45973. hideLoadingUI(): void;
  45974. /** @hidden */
  45975. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45976. /** @hidden */
  45977. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45978. /** @hidden */
  45979. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45980. /** @hidden */
  45981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45982. }
  45983. }
  45984. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45985. import { Nullable, int } from "babylonjs/types";
  45986. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45987. /** @hidden */
  45988. export class _OcclusionDataStorage {
  45989. /** @hidden */
  45990. occlusionInternalRetryCounter: number;
  45991. /** @hidden */
  45992. isOcclusionQueryInProgress: boolean;
  45993. /** @hidden */
  45994. isOccluded: boolean;
  45995. /** @hidden */
  45996. occlusionRetryCount: number;
  45997. /** @hidden */
  45998. occlusionType: number;
  45999. /** @hidden */
  46000. occlusionQueryAlgorithmType: number;
  46001. }
  46002. module "babylonjs/Engines/engine" {
  46003. interface Engine {
  46004. /**
  46005. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46006. * @return the new query
  46007. */
  46008. createQuery(): WebGLQuery;
  46009. /**
  46010. * Delete and release a webGL query
  46011. * @param query defines the query to delete
  46012. * @return the current engine
  46013. */
  46014. deleteQuery(query: WebGLQuery): Engine;
  46015. /**
  46016. * Check if a given query has resolved and got its value
  46017. * @param query defines the query to check
  46018. * @returns true if the query got its value
  46019. */
  46020. isQueryResultAvailable(query: WebGLQuery): boolean;
  46021. /**
  46022. * Gets the value of a given query
  46023. * @param query defines the query to check
  46024. * @returns the value of the query
  46025. */
  46026. getQueryResult(query: WebGLQuery): number;
  46027. /**
  46028. * Initiates an occlusion query
  46029. * @param algorithmType defines the algorithm to use
  46030. * @param query defines the query to use
  46031. * @returns the current engine
  46032. * @see http://doc.babylonjs.com/features/occlusionquery
  46033. */
  46034. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46035. /**
  46036. * Ends an occlusion query
  46037. * @see http://doc.babylonjs.com/features/occlusionquery
  46038. * @param algorithmType defines the algorithm to use
  46039. * @returns the current engine
  46040. */
  46041. endOcclusionQuery(algorithmType: number): Engine;
  46042. /**
  46043. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46044. * Please note that only one query can be issued at a time
  46045. * @returns a time token used to track the time span
  46046. */
  46047. startTimeQuery(): Nullable<_TimeToken>;
  46048. /**
  46049. * Ends a time query
  46050. * @param token defines the token used to measure the time span
  46051. * @returns the time spent (in ns)
  46052. */
  46053. endTimeQuery(token: _TimeToken): int;
  46054. /** @hidden */
  46055. _currentNonTimestampToken: Nullable<_TimeToken>;
  46056. /** @hidden */
  46057. _createTimeQuery(): WebGLQuery;
  46058. /** @hidden */
  46059. _deleteTimeQuery(query: WebGLQuery): void;
  46060. /** @hidden */
  46061. _getGlAlgorithmType(algorithmType: number): number;
  46062. /** @hidden */
  46063. _getTimeQueryResult(query: WebGLQuery): any;
  46064. /** @hidden */
  46065. _getTimeQueryAvailability(query: WebGLQuery): any;
  46066. }
  46067. }
  46068. module "babylonjs/Meshes/abstractMesh" {
  46069. interface AbstractMesh {
  46070. /**
  46071. * Backing filed
  46072. * @hidden
  46073. */
  46074. __occlusionDataStorage: _OcclusionDataStorage;
  46075. /**
  46076. * Access property
  46077. * @hidden
  46078. */
  46079. _occlusionDataStorage: _OcclusionDataStorage;
  46080. /**
  46081. * 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.
  46082. * The default value is -1 which means don't break the query and wait till the result
  46083. * @see http://doc.babylonjs.com/features/occlusionquery
  46084. */
  46085. occlusionRetryCount: number;
  46086. /**
  46087. * 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:
  46088. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46089. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46090. * * 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.
  46091. * @see http://doc.babylonjs.com/features/occlusionquery
  46092. */
  46093. occlusionType: number;
  46094. /**
  46095. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46096. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46097. * * 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.
  46098. * @see http://doc.babylonjs.com/features/occlusionquery
  46099. */
  46100. occlusionQueryAlgorithmType: number;
  46101. /**
  46102. * 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
  46103. * @see http://doc.babylonjs.com/features/occlusionquery
  46104. */
  46105. isOccluded: boolean;
  46106. /**
  46107. * Flag to check the progress status of the query
  46108. * @see http://doc.babylonjs.com/features/occlusionquery
  46109. */
  46110. isOcclusionQueryInProgress: boolean;
  46111. }
  46112. }
  46113. }
  46114. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46115. import { Nullable } from "babylonjs/types";
  46116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46117. /** @hidden */
  46118. export var _forceTransformFeedbackToBundle: boolean;
  46119. module "babylonjs/Engines/engine" {
  46120. interface Engine {
  46121. /**
  46122. * Creates a webGL transform feedback object
  46123. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46124. * @returns the webGL transform feedback object
  46125. */
  46126. createTransformFeedback(): WebGLTransformFeedback;
  46127. /**
  46128. * Delete a webGL transform feedback object
  46129. * @param value defines the webGL transform feedback object to delete
  46130. */
  46131. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46132. /**
  46133. * Bind a webGL transform feedback object to the webgl context
  46134. * @param value defines the webGL transform feedback object to bind
  46135. */
  46136. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46137. /**
  46138. * Begins a transform feedback operation
  46139. * @param usePoints defines if points or triangles must be used
  46140. */
  46141. beginTransformFeedback(usePoints: boolean): void;
  46142. /**
  46143. * Ends a transform feedback operation
  46144. */
  46145. endTransformFeedback(): void;
  46146. /**
  46147. * Specify the varyings to use with transform feedback
  46148. * @param program defines the associated webGL program
  46149. * @param value defines the list of strings representing the varying names
  46150. */
  46151. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46152. /**
  46153. * Bind a webGL buffer for a transform feedback operation
  46154. * @param value defines the webGL buffer to bind
  46155. */
  46156. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46157. }
  46158. }
  46159. }
  46160. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46161. import { Scene } from "babylonjs/scene";
  46162. import { Engine } from "babylonjs/Engines/engine";
  46163. import { Texture } from "babylonjs/Materials/Textures/texture";
  46164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46165. import "babylonjs/Engines/Extensions/engine.multiRender";
  46166. /**
  46167. * Creation options of the multi render target texture.
  46168. */
  46169. export interface IMultiRenderTargetOptions {
  46170. /**
  46171. * Define if the texture needs to create mip maps after render.
  46172. */
  46173. generateMipMaps?: boolean;
  46174. /**
  46175. * Define the types of all the draw buffers we want to create
  46176. */
  46177. types?: number[];
  46178. /**
  46179. * Define the sampling modes of all the draw buffers we want to create
  46180. */
  46181. samplingModes?: number[];
  46182. /**
  46183. * Define if a depth buffer is required
  46184. */
  46185. generateDepthBuffer?: boolean;
  46186. /**
  46187. * Define if a stencil buffer is required
  46188. */
  46189. generateStencilBuffer?: boolean;
  46190. /**
  46191. * Define if a depth texture is required instead of a depth buffer
  46192. */
  46193. generateDepthTexture?: boolean;
  46194. /**
  46195. * Define the number of desired draw buffers
  46196. */
  46197. textureCount?: number;
  46198. /**
  46199. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46200. */
  46201. doNotChangeAspectRatio?: boolean;
  46202. /**
  46203. * Define the default type of the buffers we are creating
  46204. */
  46205. defaultType?: number;
  46206. }
  46207. /**
  46208. * A multi render target, like a render target provides the ability to render to a texture.
  46209. * Unlike the render target, it can render to several draw buffers in one draw.
  46210. * This is specially interesting in deferred rendering or for any effects requiring more than
  46211. * just one color from a single pass.
  46212. */
  46213. export class MultiRenderTarget extends RenderTargetTexture {
  46214. private _internalTextures;
  46215. private _textures;
  46216. private _multiRenderTargetOptions;
  46217. /**
  46218. * Get if draw buffers are currently supported by the used hardware and browser.
  46219. */
  46220. readonly isSupported: boolean;
  46221. /**
  46222. * Get the list of textures generated by the multi render target.
  46223. */
  46224. readonly textures: Texture[];
  46225. /**
  46226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46227. */
  46228. readonly depthTexture: Texture;
  46229. /**
  46230. * Set the wrapping mode on U of all the textures we are rendering to.
  46231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46232. */
  46233. wrapU: number;
  46234. /**
  46235. * Set the wrapping mode on V of all the textures we are rendering to.
  46236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46237. */
  46238. wrapV: number;
  46239. /**
  46240. * Instantiate a new multi render target texture.
  46241. * A multi render target, like a render target provides the ability to render to a texture.
  46242. * Unlike the render target, it can render to several draw buffers in one draw.
  46243. * This is specially interesting in deferred rendering or for any effects requiring more than
  46244. * just one color from a single pass.
  46245. * @param name Define the name of the texture
  46246. * @param size Define the size of the buffers to render to
  46247. * @param count Define the number of target we are rendering into
  46248. * @param scene Define the scene the texture belongs to
  46249. * @param options Define the options used to create the multi render target
  46250. */
  46251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46252. /** @hidden */
  46253. _rebuild(): void;
  46254. private _createInternalTextures;
  46255. private _createTextures;
  46256. /**
  46257. * Define the number of samples used if MSAA is enabled.
  46258. */
  46259. samples: number;
  46260. /**
  46261. * Resize all the textures in the multi render target.
  46262. * Be carrefull as it will recreate all the data in the new texture.
  46263. * @param size Define the new size
  46264. */
  46265. resize(size: any): void;
  46266. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46267. /**
  46268. * Dispose the render targets and their associated resources
  46269. */
  46270. dispose(): void;
  46271. /**
  46272. * Release all the underlying texture used as draw buffers.
  46273. */
  46274. releaseInternalTextures(): void;
  46275. }
  46276. }
  46277. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46279. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46280. import { Nullable } from "babylonjs/types";
  46281. module "babylonjs/Engines/thinEngine" {
  46282. interface ThinEngine {
  46283. /**
  46284. * Unbind a list of render target textures from the webGL context
  46285. * This is used only when drawBuffer extension or webGL2 are active
  46286. * @param textures defines the render target textures to unbind
  46287. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46288. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46289. */
  46290. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46291. /**
  46292. * Create a multi render target texture
  46293. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46294. * @param size defines the size of the texture
  46295. * @param options defines the creation options
  46296. * @returns the cube texture as an InternalTexture
  46297. */
  46298. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46299. /**
  46300. * Update the sample count for a given multiple render target texture
  46301. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46302. * @param textures defines the textures to update
  46303. * @param samples defines the sample count to set
  46304. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46305. */
  46306. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46307. }
  46308. }
  46309. }
  46310. declare module "babylonjs/Engines/Extensions/engine.views" {
  46311. import { Camera } from "babylonjs/Cameras/camera";
  46312. import { Nullable } from "babylonjs/types";
  46313. /**
  46314. * Class used to define an additional view for the engine
  46315. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46316. */
  46317. export class EngineView {
  46318. /** Defines the canvas where to render the view */
  46319. target: HTMLCanvasElement;
  46320. /** Defines an optional camera used to render the view (will use active camera else) */
  46321. camera?: Camera;
  46322. }
  46323. module "babylonjs/Engines/engine" {
  46324. interface Engine {
  46325. /**
  46326. * Gets or sets the HTML element to use for attaching events
  46327. */
  46328. inputElement: Nullable<HTMLElement>;
  46329. /**
  46330. * Gets the current engine view
  46331. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46332. */
  46333. activeView: Nullable<EngineView>;
  46334. /** Gets or sets the list of views */
  46335. views: EngineView[];
  46336. /**
  46337. * Register a new child canvas
  46338. * @param canvas defines the canvas to register
  46339. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46340. * @returns the associated view
  46341. */
  46342. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46343. /**
  46344. * Remove a registered child canvas
  46345. * @param canvas defines the canvas to remove
  46346. * @returns the current engine
  46347. */
  46348. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46349. }
  46350. }
  46351. }
  46352. declare module "babylonjs/Engines/Extensions/index" {
  46353. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46354. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46355. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46356. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46357. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46358. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46359. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46360. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46361. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46362. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46363. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46364. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46365. export * from "babylonjs/Engines/Extensions/engine.views";
  46366. }
  46367. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46368. import { Nullable } from "babylonjs/types";
  46369. /**
  46370. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46371. */
  46372. export interface CubeMapInfo {
  46373. /**
  46374. * The pixel array for the front face.
  46375. * This is stored in format, left to right, up to down format.
  46376. */
  46377. front: Nullable<ArrayBufferView>;
  46378. /**
  46379. * The pixel array for the back face.
  46380. * This is stored in format, left to right, up to down format.
  46381. */
  46382. back: Nullable<ArrayBufferView>;
  46383. /**
  46384. * The pixel array for the left face.
  46385. * This is stored in format, left to right, up to down format.
  46386. */
  46387. left: Nullable<ArrayBufferView>;
  46388. /**
  46389. * The pixel array for the right face.
  46390. * This is stored in format, left to right, up to down format.
  46391. */
  46392. right: Nullable<ArrayBufferView>;
  46393. /**
  46394. * The pixel array for the up face.
  46395. * This is stored in format, left to right, up to down format.
  46396. */
  46397. up: Nullable<ArrayBufferView>;
  46398. /**
  46399. * The pixel array for the down face.
  46400. * This is stored in format, left to right, up to down format.
  46401. */
  46402. down: Nullable<ArrayBufferView>;
  46403. /**
  46404. * The size of the cubemap stored.
  46405. *
  46406. * Each faces will be size * size pixels.
  46407. */
  46408. size: number;
  46409. /**
  46410. * The format of the texture.
  46411. *
  46412. * RGBA, RGB.
  46413. */
  46414. format: number;
  46415. /**
  46416. * The type of the texture data.
  46417. *
  46418. * UNSIGNED_INT, FLOAT.
  46419. */
  46420. type: number;
  46421. /**
  46422. * Specifies whether the texture is in gamma space.
  46423. */
  46424. gammaSpace: boolean;
  46425. }
  46426. /**
  46427. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46428. */
  46429. export class PanoramaToCubeMapTools {
  46430. private static FACE_FRONT;
  46431. private static FACE_BACK;
  46432. private static FACE_RIGHT;
  46433. private static FACE_LEFT;
  46434. private static FACE_DOWN;
  46435. private static FACE_UP;
  46436. /**
  46437. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46438. *
  46439. * @param float32Array The source data.
  46440. * @param inputWidth The width of the input panorama.
  46441. * @param inputHeight The height of the input panorama.
  46442. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46443. * @return The cubemap data
  46444. */
  46445. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46446. private static CreateCubemapTexture;
  46447. private static CalcProjectionSpherical;
  46448. }
  46449. }
  46450. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46451. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46453. import { Nullable } from "babylonjs/types";
  46454. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46455. /**
  46456. * Helper class dealing with the extraction of spherical polynomial dataArray
  46457. * from a cube map.
  46458. */
  46459. export class CubeMapToSphericalPolynomialTools {
  46460. private static FileFaces;
  46461. /**
  46462. * Converts a texture to the according Spherical Polynomial data.
  46463. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46464. *
  46465. * @param texture The texture to extract the information from.
  46466. * @return The Spherical Polynomial data.
  46467. */
  46468. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46469. /**
  46470. * Converts a cubemap to the according Spherical Polynomial data.
  46471. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46472. *
  46473. * @param cubeInfo The Cube map to extract the information from.
  46474. * @return The Spherical Polynomial data.
  46475. */
  46476. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46477. }
  46478. }
  46479. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46480. import { Nullable } from "babylonjs/types";
  46481. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46482. module "babylonjs/Materials/Textures/baseTexture" {
  46483. interface BaseTexture {
  46484. /**
  46485. * Get the polynomial representation of the texture data.
  46486. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46487. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46488. */
  46489. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46490. }
  46491. }
  46492. }
  46493. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46495. /** @hidden */
  46496. export var rgbdEncodePixelShader: {
  46497. name: string;
  46498. shader: string;
  46499. };
  46500. }
  46501. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46503. /** @hidden */
  46504. export var rgbdDecodePixelShader: {
  46505. name: string;
  46506. shader: string;
  46507. };
  46508. }
  46509. declare module "babylonjs/Misc/environmentTextureTools" {
  46510. import { Nullable } from "babylonjs/types";
  46511. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46513. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46514. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46515. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46516. import "babylonjs/Shaders/rgbdEncode.fragment";
  46517. import "babylonjs/Shaders/rgbdDecode.fragment";
  46518. /**
  46519. * Raw texture data and descriptor sufficient for WebGL texture upload
  46520. */
  46521. export interface EnvironmentTextureInfo {
  46522. /**
  46523. * Version of the environment map
  46524. */
  46525. version: number;
  46526. /**
  46527. * Width of image
  46528. */
  46529. width: number;
  46530. /**
  46531. * Irradiance information stored in the file.
  46532. */
  46533. irradiance: any;
  46534. /**
  46535. * Specular information stored in the file.
  46536. */
  46537. specular: any;
  46538. }
  46539. /**
  46540. * Defines One Image in the file. It requires only the position in the file
  46541. * as well as the length.
  46542. */
  46543. interface BufferImageData {
  46544. /**
  46545. * Length of the image data.
  46546. */
  46547. length: number;
  46548. /**
  46549. * Position of the data from the null terminator delimiting the end of the JSON.
  46550. */
  46551. position: number;
  46552. }
  46553. /**
  46554. * Defines the specular data enclosed in the file.
  46555. * This corresponds to the version 1 of the data.
  46556. */
  46557. export interface EnvironmentTextureSpecularInfoV1 {
  46558. /**
  46559. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46560. */
  46561. specularDataPosition?: number;
  46562. /**
  46563. * This contains all the images data needed to reconstruct the cubemap.
  46564. */
  46565. mipmaps: Array<BufferImageData>;
  46566. /**
  46567. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46568. */
  46569. lodGenerationScale: number;
  46570. }
  46571. /**
  46572. * Sets of helpers addressing the serialization and deserialization of environment texture
  46573. * stored in a BabylonJS env file.
  46574. * Those files are usually stored as .env files.
  46575. */
  46576. export class EnvironmentTextureTools {
  46577. /**
  46578. * Magic number identifying the env file.
  46579. */
  46580. private static _MagicBytes;
  46581. /**
  46582. * Gets the environment info from an env file.
  46583. * @param data The array buffer containing the .env bytes.
  46584. * @returns the environment file info (the json header) if successfully parsed.
  46585. */
  46586. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46587. /**
  46588. * Creates an environment texture from a loaded cube texture.
  46589. * @param texture defines the cube texture to convert in env file
  46590. * @return a promise containing the environment data if succesfull.
  46591. */
  46592. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46593. /**
  46594. * Creates a JSON representation of the spherical data.
  46595. * @param texture defines the texture containing the polynomials
  46596. * @return the JSON representation of the spherical info
  46597. */
  46598. private static _CreateEnvTextureIrradiance;
  46599. /**
  46600. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46601. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46602. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46603. * @return the views described by info providing access to the underlying buffer
  46604. */
  46605. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46606. /**
  46607. * Uploads the texture info contained in the env file to the GPU.
  46608. * @param texture defines the internal texture to upload to
  46609. * @param arrayBuffer defines the buffer cotaining the data to load
  46610. * @param info defines the texture info retrieved through the GetEnvInfo method
  46611. * @returns a promise
  46612. */
  46613. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46614. private static _OnImageReadyAsync;
  46615. /**
  46616. * Uploads the levels of image data to the GPU.
  46617. * @param texture defines the internal texture to upload to
  46618. * @param imageData defines the array buffer views of image data [mipmap][face]
  46619. * @returns a promise
  46620. */
  46621. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46622. /**
  46623. * Uploads spherical polynomials information to the texture.
  46624. * @param texture defines the texture we are trying to upload the information to
  46625. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46626. */
  46627. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46628. /** @hidden */
  46629. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46630. }
  46631. }
  46632. declare module "babylonjs/Maths/math.vertexFormat" {
  46633. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46634. /**
  46635. * Contains position and normal vectors for a vertex
  46636. */
  46637. export class PositionNormalVertex {
  46638. /** the position of the vertex (defaut: 0,0,0) */
  46639. position: Vector3;
  46640. /** the normal of the vertex (defaut: 0,1,0) */
  46641. normal: Vector3;
  46642. /**
  46643. * Creates a PositionNormalVertex
  46644. * @param position the position of the vertex (defaut: 0,0,0)
  46645. * @param normal the normal of the vertex (defaut: 0,1,0)
  46646. */
  46647. constructor(
  46648. /** the position of the vertex (defaut: 0,0,0) */
  46649. position?: Vector3,
  46650. /** the normal of the vertex (defaut: 0,1,0) */
  46651. normal?: Vector3);
  46652. /**
  46653. * Clones the PositionNormalVertex
  46654. * @returns the cloned PositionNormalVertex
  46655. */
  46656. clone(): PositionNormalVertex;
  46657. }
  46658. /**
  46659. * Contains position, normal and uv vectors for a vertex
  46660. */
  46661. export class PositionNormalTextureVertex {
  46662. /** the position of the vertex (defaut: 0,0,0) */
  46663. position: Vector3;
  46664. /** the normal of the vertex (defaut: 0,1,0) */
  46665. normal: Vector3;
  46666. /** the uv of the vertex (default: 0,0) */
  46667. uv: Vector2;
  46668. /**
  46669. * Creates a PositionNormalTextureVertex
  46670. * @param position the position of the vertex (defaut: 0,0,0)
  46671. * @param normal the normal of the vertex (defaut: 0,1,0)
  46672. * @param uv the uv of the vertex (default: 0,0)
  46673. */
  46674. constructor(
  46675. /** the position of the vertex (defaut: 0,0,0) */
  46676. position?: Vector3,
  46677. /** the normal of the vertex (defaut: 0,1,0) */
  46678. normal?: Vector3,
  46679. /** the uv of the vertex (default: 0,0) */
  46680. uv?: Vector2);
  46681. /**
  46682. * Clones the PositionNormalTextureVertex
  46683. * @returns the cloned PositionNormalTextureVertex
  46684. */
  46685. clone(): PositionNormalTextureVertex;
  46686. }
  46687. }
  46688. declare module "babylonjs/Maths/math" {
  46689. export * from "babylonjs/Maths/math.axis";
  46690. export * from "babylonjs/Maths/math.color";
  46691. export * from "babylonjs/Maths/math.constants";
  46692. export * from "babylonjs/Maths/math.frustum";
  46693. export * from "babylonjs/Maths/math.path";
  46694. export * from "babylonjs/Maths/math.plane";
  46695. export * from "babylonjs/Maths/math.size";
  46696. export * from "babylonjs/Maths/math.vector";
  46697. export * from "babylonjs/Maths/math.vertexFormat";
  46698. export * from "babylonjs/Maths/math.viewport";
  46699. }
  46700. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46701. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46702. /** @hidden */
  46703. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46704. private _genericAttributeLocation;
  46705. private _varyingLocationCount;
  46706. private _varyingLocationMap;
  46707. private _replacements;
  46708. private _textureCount;
  46709. private _uniforms;
  46710. lineProcessor(line: string): string;
  46711. attributeProcessor(attribute: string): string;
  46712. varyingProcessor(varying: string, isFragment: boolean): string;
  46713. uniformProcessor(uniform: string): string;
  46714. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46715. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46716. }
  46717. }
  46718. declare module "babylonjs/Engines/nativeEngine" {
  46719. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46720. import { Engine } from "babylonjs/Engines/engine";
  46721. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46724. import { Effect } from "babylonjs/Materials/effect";
  46725. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46726. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46727. import { Scene } from "babylonjs/scene";
  46728. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46729. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46730. /**
  46731. * Container for accessors for natively-stored mesh data buffers.
  46732. */
  46733. class NativeDataBuffer extends DataBuffer {
  46734. /**
  46735. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46736. */
  46737. nativeIndexBuffer?: any;
  46738. /**
  46739. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46740. */
  46741. nativeVertexBuffer?: any;
  46742. }
  46743. /** @hidden */
  46744. class NativeTexture extends InternalTexture {
  46745. getInternalTexture(): InternalTexture;
  46746. getViewCount(): number;
  46747. }
  46748. /** @hidden */
  46749. export class NativeEngine extends Engine {
  46750. private readonly _native;
  46751. getHardwareScalingLevel(): number;
  46752. constructor();
  46753. /**
  46754. * Can be used to override the current requestAnimationFrame requester.
  46755. * @hidden
  46756. */
  46757. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46758. /**
  46759. * Override default engine behavior.
  46760. * @param color
  46761. * @param backBuffer
  46762. * @param depth
  46763. * @param stencil
  46764. */
  46765. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46766. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46767. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46768. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46769. recordVertexArrayObject(vertexBuffers: {
  46770. [key: string]: VertexBuffer;
  46771. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46772. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46773. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46774. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46775. /**
  46776. * Draw a list of indexed primitives
  46777. * @param fillMode defines the primitive to use
  46778. * @param indexStart defines the starting index
  46779. * @param indexCount defines the number of index to draw
  46780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46781. */
  46782. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46783. /**
  46784. * Draw a list of unindexed primitives
  46785. * @param fillMode defines the primitive to use
  46786. * @param verticesStart defines the index of first vertex to draw
  46787. * @param verticesCount defines the count of vertices to draw
  46788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46789. */
  46790. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46791. createPipelineContext(): IPipelineContext;
  46792. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46793. /** @hidden */
  46794. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46795. /** @hidden */
  46796. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46797. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46798. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46799. protected _setProgram(program: WebGLProgram): void;
  46800. _releaseEffect(effect: Effect): void;
  46801. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46802. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46803. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46804. bindSamplers(effect: Effect): void;
  46805. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46806. getRenderWidth(useScreen?: boolean): number;
  46807. getRenderHeight(useScreen?: boolean): number;
  46808. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46809. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46810. /**
  46811. * Set the z offset to apply to current rendering
  46812. * @param value defines the offset to apply
  46813. */
  46814. setZOffset(value: number): void;
  46815. /**
  46816. * Gets the current value of the zOffset
  46817. * @returns the current zOffset state
  46818. */
  46819. getZOffset(): number;
  46820. /**
  46821. * Enable or disable depth buffering
  46822. * @param enable defines the state to set
  46823. */
  46824. setDepthBuffer(enable: boolean): void;
  46825. /**
  46826. * Gets a boolean indicating if depth writing is enabled
  46827. * @returns the current depth writing state
  46828. */
  46829. getDepthWrite(): boolean;
  46830. /**
  46831. * Enable or disable depth writing
  46832. * @param enable defines the state to set
  46833. */
  46834. setDepthWrite(enable: boolean): void;
  46835. /**
  46836. * Enable or disable color writing
  46837. * @param enable defines the state to set
  46838. */
  46839. setColorWrite(enable: boolean): void;
  46840. /**
  46841. * Gets a boolean indicating if color writing is enabled
  46842. * @returns the current color writing state
  46843. */
  46844. getColorWrite(): boolean;
  46845. /**
  46846. * Sets alpha constants used by some alpha blending modes
  46847. * @param r defines the red component
  46848. * @param g defines the green component
  46849. * @param b defines the blue component
  46850. * @param a defines the alpha component
  46851. */
  46852. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46853. /**
  46854. * Sets the current alpha mode
  46855. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46856. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46857. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46858. */
  46859. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46860. /**
  46861. * Gets the current alpha mode
  46862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46863. * @returns the current alpha mode
  46864. */
  46865. getAlphaMode(): number;
  46866. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46867. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46868. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46869. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46870. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46871. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46872. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46873. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46874. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46875. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46876. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46877. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46878. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46879. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46880. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46881. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46882. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46883. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46884. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46885. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46886. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46887. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46888. wipeCaches(bruteForce?: boolean): void;
  46889. _createTexture(): WebGLTexture;
  46890. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46891. /**
  46892. * Usually called from BABYLON.Texture.ts.
  46893. * Passed information to create a WebGLTexture
  46894. * @param urlArg defines a value which contains one of the following:
  46895. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46896. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46897. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46898. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46899. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46900. * @param scene needed for loading to the correct scene
  46901. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46902. * @param onLoad optional callback to be called upon successful completion
  46903. * @param onError optional callback to be called upon failure
  46904. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46905. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46906. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46907. * @param forcedExtension defines the extension to use to pick the right loader
  46908. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46909. */
  46910. 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;
  46911. /**
  46912. * Creates a cube texture
  46913. * @param rootUrl defines the url where the files to load is located
  46914. * @param scene defines the current scene
  46915. * @param files defines the list of files to load (1 per face)
  46916. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46917. * @param onLoad defines an optional callback raised when the texture is loaded
  46918. * @param onError defines an optional callback raised if there is an issue to load the texture
  46919. * @param format defines the format of the data
  46920. * @param forcedExtension defines the extension to use to pick the right loader
  46921. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46922. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46923. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46924. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46925. * @returns the cube texture as an InternalTexture
  46926. */
  46927. 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;
  46928. private _getSamplingFilter;
  46929. private static _GetNativeTextureFormat;
  46930. createRenderTargetTexture(size: number | {
  46931. width: number;
  46932. height: number;
  46933. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46934. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46935. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46936. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46937. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46938. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46939. /**
  46940. * Updates a dynamic vertex buffer.
  46941. * @param vertexBuffer the vertex buffer to update
  46942. * @param data the data used to update the vertex buffer
  46943. * @param byteOffset the byte offset of the data (optional)
  46944. * @param byteLength the byte length of the data (optional)
  46945. */
  46946. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46947. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46948. private _updateAnisotropicLevel;
  46949. private _getAddressMode;
  46950. /** @hidden */
  46951. _bindTexture(channel: number, texture: InternalTexture): void;
  46952. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46953. releaseEffects(): void;
  46954. /** @hidden */
  46955. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46956. /** @hidden */
  46957. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46958. /** @hidden */
  46959. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46960. /** @hidden */
  46961. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46962. }
  46963. }
  46964. declare module "babylonjs/Engines/index" {
  46965. export * from "babylonjs/Engines/constants";
  46966. export * from "babylonjs/Engines/engineCapabilities";
  46967. export * from "babylonjs/Engines/instancingAttributeInfo";
  46968. export * from "babylonjs/Engines/thinEngine";
  46969. export * from "babylonjs/Engines/engine";
  46970. export * from "babylonjs/Engines/engineStore";
  46971. export * from "babylonjs/Engines/nullEngine";
  46972. export * from "babylonjs/Engines/Extensions/index";
  46973. export * from "babylonjs/Engines/IPipelineContext";
  46974. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46975. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46976. export * from "babylonjs/Engines/nativeEngine";
  46977. }
  46978. declare module "babylonjs/Events/clipboardEvents" {
  46979. /**
  46980. * Gather the list of clipboard event types as constants.
  46981. */
  46982. export class ClipboardEventTypes {
  46983. /**
  46984. * The clipboard event is fired when a copy command is active (pressed).
  46985. */
  46986. static readonly COPY: number;
  46987. /**
  46988. * The clipboard event is fired when a cut command is active (pressed).
  46989. */
  46990. static readonly CUT: number;
  46991. /**
  46992. * The clipboard event is fired when a paste command is active (pressed).
  46993. */
  46994. static readonly PASTE: number;
  46995. }
  46996. /**
  46997. * This class is used to store clipboard related info for the onClipboardObservable event.
  46998. */
  46999. export class ClipboardInfo {
  47000. /**
  47001. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47002. */
  47003. type: number;
  47004. /**
  47005. * Defines the related dom event
  47006. */
  47007. event: ClipboardEvent;
  47008. /**
  47009. *Creates an instance of ClipboardInfo.
  47010. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47011. * @param event Defines the related dom event
  47012. */
  47013. constructor(
  47014. /**
  47015. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47016. */
  47017. type: number,
  47018. /**
  47019. * Defines the related dom event
  47020. */
  47021. event: ClipboardEvent);
  47022. /**
  47023. * Get the clipboard event's type from the keycode.
  47024. * @param keyCode Defines the keyCode for the current keyboard event.
  47025. * @return {number}
  47026. */
  47027. static GetTypeFromCharacter(keyCode: number): number;
  47028. }
  47029. }
  47030. declare module "babylonjs/Events/index" {
  47031. export * from "babylonjs/Events/keyboardEvents";
  47032. export * from "babylonjs/Events/pointerEvents";
  47033. export * from "babylonjs/Events/clipboardEvents";
  47034. }
  47035. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47036. import { Scene } from "babylonjs/scene";
  47037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47038. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47039. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47040. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47041. /**
  47042. * Google Daydream controller
  47043. */
  47044. export class DaydreamController extends WebVRController {
  47045. /**
  47046. * Base Url for the controller model.
  47047. */
  47048. static MODEL_BASE_URL: string;
  47049. /**
  47050. * File name for the controller model.
  47051. */
  47052. static MODEL_FILENAME: string;
  47053. /**
  47054. * Gamepad Id prefix used to identify Daydream Controller.
  47055. */
  47056. static readonly GAMEPAD_ID_PREFIX: string;
  47057. /**
  47058. * Creates a new DaydreamController from a gamepad
  47059. * @param vrGamepad the gamepad that the controller should be created from
  47060. */
  47061. constructor(vrGamepad: any);
  47062. /**
  47063. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47064. * @param scene scene in which to add meshes
  47065. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47066. */
  47067. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47068. /**
  47069. * Called once for each button that changed state since the last frame
  47070. * @param buttonIdx Which button index changed
  47071. * @param state New state of the button
  47072. * @param changes Which properties on the state changed since last frame
  47073. */
  47074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47075. }
  47076. }
  47077. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47078. import { Scene } from "babylonjs/scene";
  47079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47080. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47081. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47082. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47083. /**
  47084. * Gear VR Controller
  47085. */
  47086. export class GearVRController extends WebVRController {
  47087. /**
  47088. * Base Url for the controller model.
  47089. */
  47090. static MODEL_BASE_URL: string;
  47091. /**
  47092. * File name for the controller model.
  47093. */
  47094. static MODEL_FILENAME: string;
  47095. /**
  47096. * Gamepad Id prefix used to identify this controller.
  47097. */
  47098. static readonly GAMEPAD_ID_PREFIX: string;
  47099. private readonly _buttonIndexToObservableNameMap;
  47100. /**
  47101. * Creates a new GearVRController from a gamepad
  47102. * @param vrGamepad the gamepad that the controller should be created from
  47103. */
  47104. constructor(vrGamepad: any);
  47105. /**
  47106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47107. * @param scene scene in which to add meshes
  47108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47109. */
  47110. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47111. /**
  47112. * Called once for each button that changed state since the last frame
  47113. * @param buttonIdx Which button index changed
  47114. * @param state New state of the button
  47115. * @param changes Which properties on the state changed since last frame
  47116. */
  47117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47118. }
  47119. }
  47120. declare module "babylonjs/Gamepads/Controllers/index" {
  47121. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47122. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47123. export * from "babylonjs/Gamepads/Controllers/genericController";
  47124. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47125. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47126. export * from "babylonjs/Gamepads/Controllers/viveController";
  47127. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47128. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47129. }
  47130. declare module "babylonjs/Gamepads/index" {
  47131. export * from "babylonjs/Gamepads/Controllers/index";
  47132. export * from "babylonjs/Gamepads/gamepad";
  47133. export * from "babylonjs/Gamepads/gamepadManager";
  47134. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47135. export * from "babylonjs/Gamepads/xboxGamepad";
  47136. export * from "babylonjs/Gamepads/dualShockGamepad";
  47137. }
  47138. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47139. import { Scene } from "babylonjs/scene";
  47140. import { Vector4 } from "babylonjs/Maths/math.vector";
  47141. import { Color4 } from "babylonjs/Maths/math.color";
  47142. import { Mesh } from "babylonjs/Meshes/mesh";
  47143. import { Nullable } from "babylonjs/types";
  47144. /**
  47145. * Class containing static functions to help procedurally build meshes
  47146. */
  47147. export class PolyhedronBuilder {
  47148. /**
  47149. * Creates a polyhedron mesh
  47150. * * 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
  47151. * * The parameter `size` (positive float, default 1) sets the polygon size
  47152. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47153. * * 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`
  47154. * * 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
  47155. * * 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)`)
  47156. * * 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
  47157. * * 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
  47158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47161. * @param name defines the name of the mesh
  47162. * @param options defines the options used to create the mesh
  47163. * @param scene defines the hosting scene
  47164. * @returns the polyhedron mesh
  47165. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47166. */
  47167. static CreatePolyhedron(name: string, options: {
  47168. type?: number;
  47169. size?: number;
  47170. sizeX?: number;
  47171. sizeY?: number;
  47172. sizeZ?: number;
  47173. custom?: any;
  47174. faceUV?: Vector4[];
  47175. faceColors?: Color4[];
  47176. flat?: boolean;
  47177. updatable?: boolean;
  47178. sideOrientation?: number;
  47179. frontUVs?: Vector4;
  47180. backUVs?: Vector4;
  47181. }, scene?: Nullable<Scene>): Mesh;
  47182. }
  47183. }
  47184. declare module "babylonjs/Gizmos/scaleGizmo" {
  47185. import { Observable } from "babylonjs/Misc/observable";
  47186. import { Nullable } from "babylonjs/types";
  47187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47188. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47189. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47191. /**
  47192. * Gizmo that enables scaling a mesh along 3 axis
  47193. */
  47194. export class ScaleGizmo extends Gizmo {
  47195. /**
  47196. * Internal gizmo used for interactions on the x axis
  47197. */
  47198. xGizmo: AxisScaleGizmo;
  47199. /**
  47200. * Internal gizmo used for interactions on the y axis
  47201. */
  47202. yGizmo: AxisScaleGizmo;
  47203. /**
  47204. * Internal gizmo used for interactions on the z axis
  47205. */
  47206. zGizmo: AxisScaleGizmo;
  47207. /**
  47208. * Internal gizmo used to scale all axis equally
  47209. */
  47210. uniformScaleGizmo: AxisScaleGizmo;
  47211. private _meshAttached;
  47212. private _updateGizmoRotationToMatchAttachedMesh;
  47213. private _snapDistance;
  47214. private _scaleRatio;
  47215. private _uniformScalingMesh;
  47216. private _octahedron;
  47217. /** Fires an event when any of it's sub gizmos are dragged */
  47218. onDragStartObservable: Observable<unknown>;
  47219. /** Fires an event when any of it's sub gizmos are released from dragging */
  47220. onDragEndObservable: Observable<unknown>;
  47221. attachedMesh: Nullable<AbstractMesh>;
  47222. /**
  47223. * Creates a ScaleGizmo
  47224. * @param gizmoLayer The utility layer the gizmo will be added to
  47225. */
  47226. constructor(gizmoLayer?: UtilityLayerRenderer);
  47227. updateGizmoRotationToMatchAttachedMesh: boolean;
  47228. /**
  47229. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47230. */
  47231. snapDistance: number;
  47232. /**
  47233. * Ratio for the scale of the gizmo (Default: 1)
  47234. */
  47235. scaleRatio: number;
  47236. /**
  47237. * Disposes of the gizmo
  47238. */
  47239. dispose(): void;
  47240. }
  47241. }
  47242. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47243. import { Observable } from "babylonjs/Misc/observable";
  47244. import { Nullable } from "babylonjs/types";
  47245. import { Vector3 } from "babylonjs/Maths/math.vector";
  47246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47247. import { Mesh } from "babylonjs/Meshes/mesh";
  47248. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47251. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47252. import { Color3 } from "babylonjs/Maths/math.color";
  47253. /**
  47254. * Single axis scale gizmo
  47255. */
  47256. export class AxisScaleGizmo extends Gizmo {
  47257. /**
  47258. * Drag behavior responsible for the gizmos dragging interactions
  47259. */
  47260. dragBehavior: PointerDragBehavior;
  47261. private _pointerObserver;
  47262. /**
  47263. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47264. */
  47265. snapDistance: number;
  47266. /**
  47267. * Event that fires each time the gizmo snaps to a new location.
  47268. * * snapDistance is the the change in distance
  47269. */
  47270. onSnapObservable: Observable<{
  47271. snapDistance: number;
  47272. }>;
  47273. /**
  47274. * If the scaling operation should be done on all axis (default: false)
  47275. */
  47276. uniformScaling: boolean;
  47277. private _isEnabled;
  47278. private _parent;
  47279. private _arrow;
  47280. private _coloredMaterial;
  47281. private _hoverMaterial;
  47282. /**
  47283. * Creates an AxisScaleGizmo
  47284. * @param gizmoLayer The utility layer the gizmo will be added to
  47285. * @param dragAxis The axis which the gizmo will be able to scale on
  47286. * @param color The color of the gizmo
  47287. */
  47288. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47289. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47290. /**
  47291. * If the gizmo is enabled
  47292. */
  47293. isEnabled: boolean;
  47294. /**
  47295. * Disposes of the gizmo
  47296. */
  47297. dispose(): void;
  47298. /**
  47299. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47300. * @param mesh The mesh to replace the default mesh of the gizmo
  47301. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47302. */
  47303. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47304. }
  47305. }
  47306. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47307. import { Observable } from "babylonjs/Misc/observable";
  47308. import { Nullable } from "babylonjs/types";
  47309. import { Vector3 } from "babylonjs/Maths/math.vector";
  47310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47311. import { Mesh } from "babylonjs/Meshes/mesh";
  47312. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47313. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47314. import { Color3 } from "babylonjs/Maths/math.color";
  47315. import "babylonjs/Meshes/Builders/boxBuilder";
  47316. /**
  47317. * Bounding box gizmo
  47318. */
  47319. export class BoundingBoxGizmo extends Gizmo {
  47320. private _lineBoundingBox;
  47321. private _rotateSpheresParent;
  47322. private _scaleBoxesParent;
  47323. private _boundingDimensions;
  47324. private _renderObserver;
  47325. private _pointerObserver;
  47326. private _scaleDragSpeed;
  47327. private _tmpQuaternion;
  47328. private _tmpVector;
  47329. private _tmpRotationMatrix;
  47330. /**
  47331. * 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)
  47332. */
  47333. ignoreChildren: boolean;
  47334. /**
  47335. * 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)
  47336. */
  47337. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47338. /**
  47339. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47340. */
  47341. rotationSphereSize: number;
  47342. /**
  47343. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47344. */
  47345. scaleBoxSize: number;
  47346. /**
  47347. * 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)
  47348. */
  47349. fixedDragMeshScreenSize: boolean;
  47350. /**
  47351. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47352. */
  47353. fixedDragMeshScreenSizeDistanceFactor: number;
  47354. /**
  47355. * Fired when a rotation sphere or scale box is dragged
  47356. */
  47357. onDragStartObservable: Observable<{}>;
  47358. /**
  47359. * Fired when a scale box is dragged
  47360. */
  47361. onScaleBoxDragObservable: Observable<{}>;
  47362. /**
  47363. * Fired when a scale box drag is ended
  47364. */
  47365. onScaleBoxDragEndObservable: Observable<{}>;
  47366. /**
  47367. * Fired when a rotation sphere is dragged
  47368. */
  47369. onRotationSphereDragObservable: Observable<{}>;
  47370. /**
  47371. * Fired when a rotation sphere drag is ended
  47372. */
  47373. onRotationSphereDragEndObservable: Observable<{}>;
  47374. /**
  47375. * 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)
  47376. */
  47377. scalePivot: Nullable<Vector3>;
  47378. /**
  47379. * Mesh used as a pivot to rotate the attached mesh
  47380. */
  47381. private _anchorMesh;
  47382. private _existingMeshScale;
  47383. private _dragMesh;
  47384. private pointerDragBehavior;
  47385. private coloredMaterial;
  47386. private hoverColoredMaterial;
  47387. /**
  47388. * Sets the color of the bounding box gizmo
  47389. * @param color the color to set
  47390. */
  47391. setColor(color: Color3): void;
  47392. /**
  47393. * Creates an BoundingBoxGizmo
  47394. * @param gizmoLayer The utility layer the gizmo will be added to
  47395. * @param color The color of the gizmo
  47396. */
  47397. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47398. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47399. private _selectNode;
  47400. /**
  47401. * Updates the bounding box information for the Gizmo
  47402. */
  47403. updateBoundingBox(): void;
  47404. private _updateRotationSpheres;
  47405. private _updateScaleBoxes;
  47406. /**
  47407. * Enables rotation on the specified axis and disables rotation on the others
  47408. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47409. */
  47410. setEnabledRotationAxis(axis: string): void;
  47411. /**
  47412. * Enables/disables scaling
  47413. * @param enable if scaling should be enabled
  47414. */
  47415. setEnabledScaling(enable: boolean): void;
  47416. private _updateDummy;
  47417. /**
  47418. * Enables a pointer drag behavior on the bounding box of the gizmo
  47419. */
  47420. enableDragBehavior(): void;
  47421. /**
  47422. * Disposes of the gizmo
  47423. */
  47424. dispose(): void;
  47425. /**
  47426. * 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)
  47427. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47428. * @returns the bounding box mesh with the passed in mesh as a child
  47429. */
  47430. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47431. /**
  47432. * CustomMeshes are not supported by this gizmo
  47433. * @param mesh The mesh to replace the default mesh of the gizmo
  47434. */
  47435. setCustomMesh(mesh: Mesh): void;
  47436. }
  47437. }
  47438. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47439. import { Observable } from "babylonjs/Misc/observable";
  47440. import { Nullable } from "babylonjs/types";
  47441. import { Vector3 } from "babylonjs/Maths/math.vector";
  47442. import { Color3 } from "babylonjs/Maths/math.color";
  47443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47444. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47445. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47446. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47447. import "babylonjs/Meshes/Builders/linesBuilder";
  47448. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47449. /**
  47450. * Single plane rotation gizmo
  47451. */
  47452. export class PlaneRotationGizmo extends Gizmo {
  47453. /**
  47454. * Drag behavior responsible for the gizmos dragging interactions
  47455. */
  47456. dragBehavior: PointerDragBehavior;
  47457. private _pointerObserver;
  47458. /**
  47459. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47460. */
  47461. snapDistance: number;
  47462. /**
  47463. * Event that fires each time the gizmo snaps to a new location.
  47464. * * snapDistance is the the change in distance
  47465. */
  47466. onSnapObservable: Observable<{
  47467. snapDistance: number;
  47468. }>;
  47469. private _isEnabled;
  47470. private _parent;
  47471. /**
  47472. * Creates a PlaneRotationGizmo
  47473. * @param gizmoLayer The utility layer the gizmo will be added to
  47474. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47475. * @param color The color of the gizmo
  47476. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47477. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47478. */
  47479. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47481. /**
  47482. * If the gizmo is enabled
  47483. */
  47484. isEnabled: boolean;
  47485. /**
  47486. * Disposes of the gizmo
  47487. */
  47488. dispose(): void;
  47489. }
  47490. }
  47491. declare module "babylonjs/Gizmos/rotationGizmo" {
  47492. import { Observable } from "babylonjs/Misc/observable";
  47493. import { Nullable } from "babylonjs/types";
  47494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47495. import { Mesh } from "babylonjs/Meshes/mesh";
  47496. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47497. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47498. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47499. /**
  47500. * Gizmo that enables rotating a mesh along 3 axis
  47501. */
  47502. export class RotationGizmo extends Gizmo {
  47503. /**
  47504. * Internal gizmo used for interactions on the x axis
  47505. */
  47506. xGizmo: PlaneRotationGizmo;
  47507. /**
  47508. * Internal gizmo used for interactions on the y axis
  47509. */
  47510. yGizmo: PlaneRotationGizmo;
  47511. /**
  47512. * Internal gizmo used for interactions on the z axis
  47513. */
  47514. zGizmo: PlaneRotationGizmo;
  47515. /** Fires an event when any of it's sub gizmos are dragged */
  47516. onDragStartObservable: Observable<unknown>;
  47517. /** Fires an event when any of it's sub gizmos are released from dragging */
  47518. onDragEndObservable: Observable<unknown>;
  47519. private _meshAttached;
  47520. attachedMesh: Nullable<AbstractMesh>;
  47521. /**
  47522. * Creates a RotationGizmo
  47523. * @param gizmoLayer The utility layer the gizmo will be added to
  47524. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47525. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47526. */
  47527. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47528. updateGizmoRotationToMatchAttachedMesh: boolean;
  47529. /**
  47530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47531. */
  47532. snapDistance: number;
  47533. /**
  47534. * Ratio for the scale of the gizmo (Default: 1)
  47535. */
  47536. scaleRatio: number;
  47537. /**
  47538. * Disposes of the gizmo
  47539. */
  47540. dispose(): void;
  47541. /**
  47542. * CustomMeshes are not supported by this gizmo
  47543. * @param mesh The mesh to replace the default mesh of the gizmo
  47544. */
  47545. setCustomMesh(mesh: Mesh): void;
  47546. }
  47547. }
  47548. declare module "babylonjs/Gizmos/gizmoManager" {
  47549. import { Observable } from "babylonjs/Misc/observable";
  47550. import { Nullable } from "babylonjs/types";
  47551. import { Scene, IDisposable } from "babylonjs/scene";
  47552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47553. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47554. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47555. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47556. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47557. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47558. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47559. /**
  47560. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47561. */
  47562. export class GizmoManager implements IDisposable {
  47563. private scene;
  47564. /**
  47565. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47566. */
  47567. gizmos: {
  47568. positionGizmo: Nullable<PositionGizmo>;
  47569. rotationGizmo: Nullable<RotationGizmo>;
  47570. scaleGizmo: Nullable<ScaleGizmo>;
  47571. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47572. };
  47573. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47574. clearGizmoOnEmptyPointerEvent: boolean;
  47575. /** Fires an event when the manager is attached to a mesh */
  47576. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47577. private _gizmosEnabled;
  47578. private _pointerObserver;
  47579. private _attachedMesh;
  47580. private _boundingBoxColor;
  47581. private _defaultUtilityLayer;
  47582. private _defaultKeepDepthUtilityLayer;
  47583. /**
  47584. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47585. */
  47586. boundingBoxDragBehavior: SixDofDragBehavior;
  47587. /**
  47588. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47589. */
  47590. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47591. /**
  47592. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47593. */
  47594. usePointerToAttachGizmos: boolean;
  47595. /**
  47596. * Utility layer that the bounding box gizmo belongs to
  47597. */
  47598. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47599. /**
  47600. * Utility layer that all gizmos besides bounding box belong to
  47601. */
  47602. readonly utilityLayer: UtilityLayerRenderer;
  47603. /**
  47604. * Instatiates a gizmo manager
  47605. * @param scene the scene to overlay the gizmos on top of
  47606. */
  47607. constructor(scene: Scene);
  47608. /**
  47609. * Attaches a set of gizmos to the specified mesh
  47610. * @param mesh The mesh the gizmo's should be attached to
  47611. */
  47612. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47613. /**
  47614. * If the position gizmo is enabled
  47615. */
  47616. positionGizmoEnabled: boolean;
  47617. /**
  47618. * If the rotation gizmo is enabled
  47619. */
  47620. rotationGizmoEnabled: boolean;
  47621. /**
  47622. * If the scale gizmo is enabled
  47623. */
  47624. scaleGizmoEnabled: boolean;
  47625. /**
  47626. * If the boundingBox gizmo is enabled
  47627. */
  47628. boundingBoxGizmoEnabled: boolean;
  47629. /**
  47630. * Disposes of the gizmo manager
  47631. */
  47632. dispose(): void;
  47633. }
  47634. }
  47635. declare module "babylonjs/Lights/directionalLight" {
  47636. import { Camera } from "babylonjs/Cameras/camera";
  47637. import { Scene } from "babylonjs/scene";
  47638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47640. import { Light } from "babylonjs/Lights/light";
  47641. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47642. import { Effect } from "babylonjs/Materials/effect";
  47643. /**
  47644. * A directional light is defined by a direction (what a surprise!).
  47645. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47646. * 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.
  47647. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47648. */
  47649. export class DirectionalLight extends ShadowLight {
  47650. private _shadowFrustumSize;
  47651. /**
  47652. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47653. */
  47654. /**
  47655. * Specifies a fix frustum size for the shadow generation.
  47656. */
  47657. shadowFrustumSize: number;
  47658. private _shadowOrthoScale;
  47659. /**
  47660. * Gets the shadow projection scale against the optimal computed one.
  47661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47663. */
  47664. /**
  47665. * Sets the shadow projection scale against the optimal computed one.
  47666. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47667. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47668. */
  47669. shadowOrthoScale: number;
  47670. /**
  47671. * Automatically compute the projection matrix to best fit (including all the casters)
  47672. * on each frame.
  47673. */
  47674. autoUpdateExtends: boolean;
  47675. private _orthoLeft;
  47676. private _orthoRight;
  47677. private _orthoTop;
  47678. private _orthoBottom;
  47679. /**
  47680. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47681. * The directional light is emitted from everywhere in the given direction.
  47682. * It can cast shadows.
  47683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47684. * @param name The friendly name of the light
  47685. * @param direction The direction of the light
  47686. * @param scene The scene the light belongs to
  47687. */
  47688. constructor(name: string, direction: Vector3, scene: Scene);
  47689. /**
  47690. * Returns the string "DirectionalLight".
  47691. * @return The class name
  47692. */
  47693. getClassName(): string;
  47694. /**
  47695. * Returns the integer 1.
  47696. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47697. */
  47698. getTypeID(): number;
  47699. /**
  47700. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47701. * Returns the DirectionalLight Shadow projection matrix.
  47702. */
  47703. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47704. /**
  47705. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47706. * Returns the DirectionalLight Shadow projection matrix.
  47707. */
  47708. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47709. /**
  47710. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47711. * Returns the DirectionalLight Shadow projection matrix.
  47712. */
  47713. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47714. protected _buildUniformLayout(): void;
  47715. /**
  47716. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47717. * @param effect The effect to update
  47718. * @param lightIndex The index of the light in the effect to update
  47719. * @returns The directional light
  47720. */
  47721. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47722. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47723. /**
  47724. * Gets the minZ used for shadow according to both the scene and the light.
  47725. *
  47726. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47727. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47728. * @param activeCamera The camera we are returning the min for
  47729. * @returns the depth min z
  47730. */
  47731. getDepthMinZ(activeCamera: Camera): number;
  47732. /**
  47733. * Gets the maxZ used for shadow according to both the scene and the light.
  47734. *
  47735. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47736. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47737. * @param activeCamera The camera we are returning the max for
  47738. * @returns the depth max z
  47739. */
  47740. getDepthMaxZ(activeCamera: Camera): number;
  47741. /**
  47742. * Prepares the list of defines specific to the light type.
  47743. * @param defines the list of defines
  47744. * @param lightIndex defines the index of the light for the effect
  47745. */
  47746. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47747. }
  47748. }
  47749. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47750. import { Mesh } from "babylonjs/Meshes/mesh";
  47751. /**
  47752. * Class containing static functions to help procedurally build meshes
  47753. */
  47754. export class HemisphereBuilder {
  47755. /**
  47756. * Creates a hemisphere mesh
  47757. * @param name defines the name of the mesh
  47758. * @param options defines the options used to create the mesh
  47759. * @param scene defines the hosting scene
  47760. * @returns the hemisphere mesh
  47761. */
  47762. static CreateHemisphere(name: string, options: {
  47763. segments?: number;
  47764. diameter?: number;
  47765. sideOrientation?: number;
  47766. }, scene: any): Mesh;
  47767. }
  47768. }
  47769. declare module "babylonjs/Lights/spotLight" {
  47770. import { Nullable } from "babylonjs/types";
  47771. import { Scene } from "babylonjs/scene";
  47772. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47774. import { Effect } from "babylonjs/Materials/effect";
  47775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47776. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47777. /**
  47778. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47779. * These values define a cone of light starting from the position, emitting toward the direction.
  47780. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47781. * and the exponent defines the speed of the decay of the light with distance (reach).
  47782. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47783. */
  47784. export class SpotLight extends ShadowLight {
  47785. private _angle;
  47786. private _innerAngle;
  47787. private _cosHalfAngle;
  47788. private _lightAngleScale;
  47789. private _lightAngleOffset;
  47790. /**
  47791. * Gets the cone angle of the spot light in Radians.
  47792. */
  47793. /**
  47794. * Sets the cone angle of the spot light in Radians.
  47795. */
  47796. angle: number;
  47797. /**
  47798. * Only used in gltf falloff mode, this defines the angle where
  47799. * the directional falloff will start before cutting at angle which could be seen
  47800. * as outer angle.
  47801. */
  47802. /**
  47803. * Only used in gltf falloff mode, this defines the angle where
  47804. * the directional falloff will start before cutting at angle which could be seen
  47805. * as outer angle.
  47806. */
  47807. innerAngle: number;
  47808. private _shadowAngleScale;
  47809. /**
  47810. * Allows scaling the angle of the light for shadow generation only.
  47811. */
  47812. /**
  47813. * Allows scaling the angle of the light for shadow generation only.
  47814. */
  47815. shadowAngleScale: number;
  47816. /**
  47817. * The light decay speed with the distance from the emission spot.
  47818. */
  47819. exponent: number;
  47820. private _projectionTextureMatrix;
  47821. /**
  47822. * Allows reading the projecton texture
  47823. */
  47824. readonly projectionTextureMatrix: Matrix;
  47825. protected _projectionTextureLightNear: number;
  47826. /**
  47827. * Gets the near clip of the Spotlight for texture projection.
  47828. */
  47829. /**
  47830. * Sets the near clip of the Spotlight for texture projection.
  47831. */
  47832. projectionTextureLightNear: number;
  47833. protected _projectionTextureLightFar: number;
  47834. /**
  47835. * Gets the far clip of the Spotlight for texture projection.
  47836. */
  47837. /**
  47838. * Sets the far clip of the Spotlight for texture projection.
  47839. */
  47840. projectionTextureLightFar: number;
  47841. protected _projectionTextureUpDirection: Vector3;
  47842. /**
  47843. * Gets the Up vector of the Spotlight for texture projection.
  47844. */
  47845. /**
  47846. * Sets the Up vector of the Spotlight for texture projection.
  47847. */
  47848. projectionTextureUpDirection: Vector3;
  47849. private _projectionTexture;
  47850. /**
  47851. * Gets the projection texture of the light.
  47852. */
  47853. /**
  47854. * Sets the projection texture of the light.
  47855. */
  47856. projectionTexture: Nullable<BaseTexture>;
  47857. private _projectionTextureViewLightDirty;
  47858. private _projectionTextureProjectionLightDirty;
  47859. private _projectionTextureDirty;
  47860. private _projectionTextureViewTargetVector;
  47861. private _projectionTextureViewLightMatrix;
  47862. private _projectionTextureProjectionLightMatrix;
  47863. private _projectionTextureScalingMatrix;
  47864. /**
  47865. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47866. * It can cast shadows.
  47867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47868. * @param name The light friendly name
  47869. * @param position The position of the spot light in the scene
  47870. * @param direction The direction of the light in the scene
  47871. * @param angle The cone angle of the light in Radians
  47872. * @param exponent The light decay speed with the distance from the emission spot
  47873. * @param scene The scene the lights belongs to
  47874. */
  47875. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47876. /**
  47877. * Returns the string "SpotLight".
  47878. * @returns the class name
  47879. */
  47880. getClassName(): string;
  47881. /**
  47882. * Returns the integer 2.
  47883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47884. */
  47885. getTypeID(): number;
  47886. /**
  47887. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47888. */
  47889. protected _setDirection(value: Vector3): void;
  47890. /**
  47891. * Overrides the position setter to recompute the projection texture view light Matrix.
  47892. */
  47893. protected _setPosition(value: Vector3): void;
  47894. /**
  47895. * 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.
  47896. * Returns the SpotLight.
  47897. */
  47898. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47899. protected _computeProjectionTextureViewLightMatrix(): void;
  47900. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47901. /**
  47902. * Main function for light texture projection matrix computing.
  47903. */
  47904. protected _computeProjectionTextureMatrix(): void;
  47905. protected _buildUniformLayout(): void;
  47906. private _computeAngleValues;
  47907. /**
  47908. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47909. * @param effect The effect to update
  47910. * @param lightIndex The index of the light in the effect to update
  47911. * @returns The spot light
  47912. */
  47913. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47914. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47915. /**
  47916. * Disposes the light and the associated resources.
  47917. */
  47918. dispose(): void;
  47919. /**
  47920. * Prepares the list of defines specific to the light type.
  47921. * @param defines the list of defines
  47922. * @param lightIndex defines the index of the light for the effect
  47923. */
  47924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47925. }
  47926. }
  47927. declare module "babylonjs/Gizmos/lightGizmo" {
  47928. import { Nullable } from "babylonjs/types";
  47929. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47931. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47932. import { Light } from "babylonjs/Lights/light";
  47933. /**
  47934. * Gizmo that enables viewing a light
  47935. */
  47936. export class LightGizmo extends Gizmo {
  47937. private _lightMesh;
  47938. private _material;
  47939. private cachedPosition;
  47940. private cachedForward;
  47941. /**
  47942. * Creates a LightGizmo
  47943. * @param gizmoLayer The utility layer the gizmo will be added to
  47944. */
  47945. constructor(gizmoLayer?: UtilityLayerRenderer);
  47946. private _light;
  47947. /**
  47948. * The light that the gizmo is attached to
  47949. */
  47950. light: Nullable<Light>;
  47951. /**
  47952. * Gets the material used to render the light gizmo
  47953. */
  47954. readonly material: StandardMaterial;
  47955. /**
  47956. * @hidden
  47957. * Updates the gizmo to match the attached mesh's position/rotation
  47958. */
  47959. protected _update(): void;
  47960. private static _Scale;
  47961. /**
  47962. * Creates the lines for a light mesh
  47963. */
  47964. private static _createLightLines;
  47965. /**
  47966. * Disposes of the light gizmo
  47967. */
  47968. dispose(): void;
  47969. private static _CreateHemisphericLightMesh;
  47970. private static _CreatePointLightMesh;
  47971. private static _CreateSpotLightMesh;
  47972. private static _CreateDirectionalLightMesh;
  47973. }
  47974. }
  47975. declare module "babylonjs/Gizmos/index" {
  47976. export * from "babylonjs/Gizmos/axisDragGizmo";
  47977. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47978. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47979. export * from "babylonjs/Gizmos/gizmo";
  47980. export * from "babylonjs/Gizmos/gizmoManager";
  47981. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47982. export * from "babylonjs/Gizmos/positionGizmo";
  47983. export * from "babylonjs/Gizmos/rotationGizmo";
  47984. export * from "babylonjs/Gizmos/scaleGizmo";
  47985. export * from "babylonjs/Gizmos/lightGizmo";
  47986. export * from "babylonjs/Gizmos/planeDragGizmo";
  47987. }
  47988. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47989. /** @hidden */
  47990. export var backgroundFragmentDeclaration: {
  47991. name: string;
  47992. shader: string;
  47993. };
  47994. }
  47995. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47996. /** @hidden */
  47997. export var backgroundUboDeclaration: {
  47998. name: string;
  47999. shader: string;
  48000. };
  48001. }
  48002. declare module "babylonjs/Shaders/background.fragment" {
  48003. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48004. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48005. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48006. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48007. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48008. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48009. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48010. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48011. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48012. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48013. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48014. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48015. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48016. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48017. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48018. /** @hidden */
  48019. export var backgroundPixelShader: {
  48020. name: string;
  48021. shader: string;
  48022. };
  48023. }
  48024. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48025. /** @hidden */
  48026. export var backgroundVertexDeclaration: {
  48027. name: string;
  48028. shader: string;
  48029. };
  48030. }
  48031. declare module "babylonjs/Shaders/background.vertex" {
  48032. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48033. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48035. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48036. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48037. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48038. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48039. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48040. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48041. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48042. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48043. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48044. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48045. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48046. /** @hidden */
  48047. export var backgroundVertexShader: {
  48048. name: string;
  48049. shader: string;
  48050. };
  48051. }
  48052. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48053. import { Nullable, int, float } from "babylonjs/types";
  48054. import { Scene } from "babylonjs/scene";
  48055. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48056. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48058. import { Mesh } from "babylonjs/Meshes/mesh";
  48059. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48060. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48061. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48063. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48064. import { Color3 } from "babylonjs/Maths/math.color";
  48065. import "babylonjs/Shaders/background.fragment";
  48066. import "babylonjs/Shaders/background.vertex";
  48067. /**
  48068. * Background material used to create an efficient environement around your scene.
  48069. */
  48070. export class BackgroundMaterial extends PushMaterial {
  48071. /**
  48072. * Standard reflectance value at parallel view angle.
  48073. */
  48074. static StandardReflectance0: number;
  48075. /**
  48076. * Standard reflectance value at grazing angle.
  48077. */
  48078. static StandardReflectance90: number;
  48079. protected _primaryColor: Color3;
  48080. /**
  48081. * Key light Color (multiply against the environement texture)
  48082. */
  48083. primaryColor: Color3;
  48084. protected __perceptualColor: Nullable<Color3>;
  48085. /**
  48086. * Experimental Internal Use Only.
  48087. *
  48088. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48089. * This acts as a helper to set the primary color to a more "human friendly" value.
  48090. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48091. * output color as close as possible from the chosen value.
  48092. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48093. * part of lighting setup.)
  48094. */
  48095. _perceptualColor: Nullable<Color3>;
  48096. protected _primaryColorShadowLevel: float;
  48097. /**
  48098. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48099. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48100. */
  48101. primaryColorShadowLevel: float;
  48102. protected _primaryColorHighlightLevel: float;
  48103. /**
  48104. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48105. * The primary color is used at the level chosen to define what the white area would look.
  48106. */
  48107. primaryColorHighlightLevel: float;
  48108. protected _reflectionTexture: Nullable<BaseTexture>;
  48109. /**
  48110. * Reflection Texture used in the material.
  48111. * Should be author in a specific way for the best result (refer to the documentation).
  48112. */
  48113. reflectionTexture: Nullable<BaseTexture>;
  48114. protected _reflectionBlur: float;
  48115. /**
  48116. * Reflection Texture level of blur.
  48117. *
  48118. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48119. * texture twice.
  48120. */
  48121. reflectionBlur: float;
  48122. protected _diffuseTexture: Nullable<BaseTexture>;
  48123. /**
  48124. * Diffuse Texture used in the material.
  48125. * Should be author in a specific way for the best result (refer to the documentation).
  48126. */
  48127. diffuseTexture: Nullable<BaseTexture>;
  48128. protected _shadowLights: Nullable<IShadowLight[]>;
  48129. /**
  48130. * Specify the list of lights casting shadow on the material.
  48131. * All scene shadow lights will be included if null.
  48132. */
  48133. shadowLights: Nullable<IShadowLight[]>;
  48134. protected _shadowLevel: float;
  48135. /**
  48136. * Helps adjusting the shadow to a softer level if required.
  48137. * 0 means black shadows and 1 means no shadows.
  48138. */
  48139. shadowLevel: float;
  48140. protected _sceneCenter: Vector3;
  48141. /**
  48142. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48143. * It is usually zero but might be interesting to modify according to your setup.
  48144. */
  48145. sceneCenter: Vector3;
  48146. protected _opacityFresnel: boolean;
  48147. /**
  48148. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48149. * This helps ensuring a nice transition when the camera goes under the ground.
  48150. */
  48151. opacityFresnel: boolean;
  48152. protected _reflectionFresnel: boolean;
  48153. /**
  48154. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48155. * This helps adding a mirror texture on the ground.
  48156. */
  48157. reflectionFresnel: boolean;
  48158. protected _reflectionFalloffDistance: number;
  48159. /**
  48160. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48161. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48162. */
  48163. reflectionFalloffDistance: number;
  48164. protected _reflectionAmount: number;
  48165. /**
  48166. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48167. */
  48168. reflectionAmount: number;
  48169. protected _reflectionReflectance0: number;
  48170. /**
  48171. * This specifies the weight of the reflection at grazing angle.
  48172. */
  48173. reflectionReflectance0: number;
  48174. protected _reflectionReflectance90: number;
  48175. /**
  48176. * This specifies the weight of the reflection at a perpendicular point of view.
  48177. */
  48178. reflectionReflectance90: number;
  48179. /**
  48180. * Sets the reflection reflectance fresnel values according to the default standard
  48181. * empirically know to work well :-)
  48182. */
  48183. reflectionStandardFresnelWeight: number;
  48184. protected _useRGBColor: boolean;
  48185. /**
  48186. * Helps to directly use the maps channels instead of their level.
  48187. */
  48188. useRGBColor: boolean;
  48189. protected _enableNoise: boolean;
  48190. /**
  48191. * This helps reducing the banding effect that could occur on the background.
  48192. */
  48193. enableNoise: boolean;
  48194. /**
  48195. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48196. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48197. * Recommended to be keep at 1.0 except for special cases.
  48198. */
  48199. fovMultiplier: number;
  48200. private _fovMultiplier;
  48201. /**
  48202. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48203. */
  48204. useEquirectangularFOV: boolean;
  48205. private _maxSimultaneousLights;
  48206. /**
  48207. * Number of Simultaneous lights allowed on the material.
  48208. */
  48209. maxSimultaneousLights: int;
  48210. /**
  48211. * Default configuration related to image processing available in the Background Material.
  48212. */
  48213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48214. /**
  48215. * Keep track of the image processing observer to allow dispose and replace.
  48216. */
  48217. private _imageProcessingObserver;
  48218. /**
  48219. * Attaches a new image processing configuration to the PBR Material.
  48220. * @param configuration (if null the scene configuration will be use)
  48221. */
  48222. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48223. /**
  48224. * Gets the image processing configuration used either in this material.
  48225. */
  48226. /**
  48227. * Sets the Default image processing configuration used either in the this material.
  48228. *
  48229. * If sets to null, the scene one is in use.
  48230. */
  48231. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48232. /**
  48233. * Gets wether the color curves effect is enabled.
  48234. */
  48235. /**
  48236. * Sets wether the color curves effect is enabled.
  48237. */
  48238. cameraColorCurvesEnabled: boolean;
  48239. /**
  48240. * Gets wether the color grading effect is enabled.
  48241. */
  48242. /**
  48243. * Gets wether the color grading effect is enabled.
  48244. */
  48245. cameraColorGradingEnabled: boolean;
  48246. /**
  48247. * Gets wether tonemapping is enabled or not.
  48248. */
  48249. /**
  48250. * Sets wether tonemapping is enabled or not
  48251. */
  48252. cameraToneMappingEnabled: boolean;
  48253. /**
  48254. * The camera exposure used on this material.
  48255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48256. * This corresponds to a photographic exposure.
  48257. */
  48258. /**
  48259. * The camera exposure used on this material.
  48260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48261. * This corresponds to a photographic exposure.
  48262. */
  48263. cameraExposure: float;
  48264. /**
  48265. * Gets The camera contrast used on this material.
  48266. */
  48267. /**
  48268. * Sets The camera contrast used on this material.
  48269. */
  48270. cameraContrast: float;
  48271. /**
  48272. * Gets the Color Grading 2D Lookup Texture.
  48273. */
  48274. /**
  48275. * Sets the Color Grading 2D Lookup Texture.
  48276. */
  48277. cameraColorGradingTexture: Nullable<BaseTexture>;
  48278. /**
  48279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48281. * 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;
  48282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48283. */
  48284. /**
  48285. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48286. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48287. * 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;
  48288. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48289. */
  48290. cameraColorCurves: Nullable<ColorCurves>;
  48291. /**
  48292. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48293. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48294. */
  48295. switchToBGR: boolean;
  48296. private _renderTargets;
  48297. private _reflectionControls;
  48298. private _white;
  48299. private _primaryShadowColor;
  48300. private _primaryHighlightColor;
  48301. /**
  48302. * Instantiates a Background Material in the given scene
  48303. * @param name The friendly name of the material
  48304. * @param scene The scene to add the material to
  48305. */
  48306. constructor(name: string, scene: Scene);
  48307. /**
  48308. * Gets a boolean indicating that current material needs to register RTT
  48309. */
  48310. readonly hasRenderTargetTextures: boolean;
  48311. /**
  48312. * The entire material has been created in order to prevent overdraw.
  48313. * @returns false
  48314. */
  48315. needAlphaTesting(): boolean;
  48316. /**
  48317. * The entire material has been created in order to prevent overdraw.
  48318. * @returns true if blending is enable
  48319. */
  48320. needAlphaBlending(): boolean;
  48321. /**
  48322. * Checks wether the material is ready to be rendered for a given mesh.
  48323. * @param mesh The mesh to render
  48324. * @param subMesh The submesh to check against
  48325. * @param useInstances Specify wether or not the material is used with instances
  48326. * @returns true if all the dependencies are ready (Textures, Effects...)
  48327. */
  48328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48329. /**
  48330. * Compute the primary color according to the chosen perceptual color.
  48331. */
  48332. private _computePrimaryColorFromPerceptualColor;
  48333. /**
  48334. * Compute the highlights and shadow colors according to their chosen levels.
  48335. */
  48336. private _computePrimaryColors;
  48337. /**
  48338. * Build the uniform buffer used in the material.
  48339. */
  48340. buildUniformLayout(): void;
  48341. /**
  48342. * Unbind the material.
  48343. */
  48344. unbind(): void;
  48345. /**
  48346. * Bind only the world matrix to the material.
  48347. * @param world The world matrix to bind.
  48348. */
  48349. bindOnlyWorldMatrix(world: Matrix): void;
  48350. /**
  48351. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48352. * @param world The world matrix to bind.
  48353. * @param subMesh The submesh to bind for.
  48354. */
  48355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48356. /**
  48357. * Checks to see if a texture is used in the material.
  48358. * @param texture - Base texture to use.
  48359. * @returns - Boolean specifying if a texture is used in the material.
  48360. */
  48361. hasTexture(texture: BaseTexture): boolean;
  48362. /**
  48363. * Dispose the material.
  48364. * @param forceDisposeEffect Force disposal of the associated effect.
  48365. * @param forceDisposeTextures Force disposal of the associated textures.
  48366. */
  48367. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48368. /**
  48369. * Clones the material.
  48370. * @param name The cloned name.
  48371. * @returns The cloned material.
  48372. */
  48373. clone(name: string): BackgroundMaterial;
  48374. /**
  48375. * Serializes the current material to its JSON representation.
  48376. * @returns The JSON representation.
  48377. */
  48378. serialize(): any;
  48379. /**
  48380. * Gets the class name of the material
  48381. * @returns "BackgroundMaterial"
  48382. */
  48383. getClassName(): string;
  48384. /**
  48385. * Parse a JSON input to create back a background material.
  48386. * @param source The JSON data to parse
  48387. * @param scene The scene to create the parsed material in
  48388. * @param rootUrl The root url of the assets the material depends upon
  48389. * @returns the instantiated BackgroundMaterial.
  48390. */
  48391. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48392. }
  48393. }
  48394. declare module "babylonjs/Helpers/environmentHelper" {
  48395. import { Observable } from "babylonjs/Misc/observable";
  48396. import { Nullable } from "babylonjs/types";
  48397. import { Scene } from "babylonjs/scene";
  48398. import { Vector3 } from "babylonjs/Maths/math.vector";
  48399. import { Color3 } from "babylonjs/Maths/math.color";
  48400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48401. import { Mesh } from "babylonjs/Meshes/mesh";
  48402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48403. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48404. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48405. import "babylonjs/Meshes/Builders/planeBuilder";
  48406. import "babylonjs/Meshes/Builders/boxBuilder";
  48407. /**
  48408. * Represents the different options available during the creation of
  48409. * a Environment helper.
  48410. *
  48411. * This can control the default ground, skybox and image processing setup of your scene.
  48412. */
  48413. export interface IEnvironmentHelperOptions {
  48414. /**
  48415. * Specifies wether or not to create a ground.
  48416. * True by default.
  48417. */
  48418. createGround: boolean;
  48419. /**
  48420. * Specifies the ground size.
  48421. * 15 by default.
  48422. */
  48423. groundSize: number;
  48424. /**
  48425. * The texture used on the ground for the main color.
  48426. * Comes from the BabylonJS CDN by default.
  48427. *
  48428. * Remarks: Can be either a texture or a url.
  48429. */
  48430. groundTexture: string | BaseTexture;
  48431. /**
  48432. * The color mixed in the ground texture by default.
  48433. * BabylonJS clearColor by default.
  48434. */
  48435. groundColor: Color3;
  48436. /**
  48437. * Specifies the ground opacity.
  48438. * 1 by default.
  48439. */
  48440. groundOpacity: number;
  48441. /**
  48442. * Enables the ground to receive shadows.
  48443. * True by default.
  48444. */
  48445. enableGroundShadow: boolean;
  48446. /**
  48447. * Helps preventing the shadow to be fully black on the ground.
  48448. * 0.5 by default.
  48449. */
  48450. groundShadowLevel: number;
  48451. /**
  48452. * Creates a mirror texture attach to the ground.
  48453. * false by default.
  48454. */
  48455. enableGroundMirror: boolean;
  48456. /**
  48457. * Specifies the ground mirror size ratio.
  48458. * 0.3 by default as the default kernel is 64.
  48459. */
  48460. groundMirrorSizeRatio: number;
  48461. /**
  48462. * Specifies the ground mirror blur kernel size.
  48463. * 64 by default.
  48464. */
  48465. groundMirrorBlurKernel: number;
  48466. /**
  48467. * Specifies the ground mirror visibility amount.
  48468. * 1 by default
  48469. */
  48470. groundMirrorAmount: number;
  48471. /**
  48472. * Specifies the ground mirror reflectance weight.
  48473. * This uses the standard weight of the background material to setup the fresnel effect
  48474. * of the mirror.
  48475. * 1 by default.
  48476. */
  48477. groundMirrorFresnelWeight: number;
  48478. /**
  48479. * Specifies the ground mirror Falloff distance.
  48480. * This can helps reducing the size of the reflection.
  48481. * 0 by Default.
  48482. */
  48483. groundMirrorFallOffDistance: number;
  48484. /**
  48485. * Specifies the ground mirror texture type.
  48486. * Unsigned Int by Default.
  48487. */
  48488. groundMirrorTextureType: number;
  48489. /**
  48490. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48491. * the shown objects.
  48492. */
  48493. groundYBias: number;
  48494. /**
  48495. * Specifies wether or not to create a skybox.
  48496. * True by default.
  48497. */
  48498. createSkybox: boolean;
  48499. /**
  48500. * Specifies the skybox size.
  48501. * 20 by default.
  48502. */
  48503. skyboxSize: number;
  48504. /**
  48505. * The texture used on the skybox for the main color.
  48506. * Comes from the BabylonJS CDN by default.
  48507. *
  48508. * Remarks: Can be either a texture or a url.
  48509. */
  48510. skyboxTexture: string | BaseTexture;
  48511. /**
  48512. * The color mixed in the skybox texture by default.
  48513. * BabylonJS clearColor by default.
  48514. */
  48515. skyboxColor: Color3;
  48516. /**
  48517. * The background rotation around the Y axis of the scene.
  48518. * This helps aligning the key lights of your scene with the background.
  48519. * 0 by default.
  48520. */
  48521. backgroundYRotation: number;
  48522. /**
  48523. * Compute automatically the size of the elements to best fit with the scene.
  48524. */
  48525. sizeAuto: boolean;
  48526. /**
  48527. * Default position of the rootMesh if autoSize is not true.
  48528. */
  48529. rootPosition: Vector3;
  48530. /**
  48531. * Sets up the image processing in the scene.
  48532. * true by default.
  48533. */
  48534. setupImageProcessing: boolean;
  48535. /**
  48536. * The texture used as your environment texture in the scene.
  48537. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48538. *
  48539. * Remarks: Can be either a texture or a url.
  48540. */
  48541. environmentTexture: string | BaseTexture;
  48542. /**
  48543. * The value of the exposure to apply to the scene.
  48544. * 0.6 by default if setupImageProcessing is true.
  48545. */
  48546. cameraExposure: number;
  48547. /**
  48548. * The value of the contrast to apply to the scene.
  48549. * 1.6 by default if setupImageProcessing is true.
  48550. */
  48551. cameraContrast: number;
  48552. /**
  48553. * Specifies wether or not tonemapping should be enabled in the scene.
  48554. * true by default if setupImageProcessing is true.
  48555. */
  48556. toneMappingEnabled: boolean;
  48557. }
  48558. /**
  48559. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48560. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48561. * It also helps with the default setup of your imageProcessing configuration.
  48562. */
  48563. export class EnvironmentHelper {
  48564. /**
  48565. * Default ground texture URL.
  48566. */
  48567. private static _groundTextureCDNUrl;
  48568. /**
  48569. * Default skybox texture URL.
  48570. */
  48571. private static _skyboxTextureCDNUrl;
  48572. /**
  48573. * Default environment texture URL.
  48574. */
  48575. private static _environmentTextureCDNUrl;
  48576. /**
  48577. * Creates the default options for the helper.
  48578. */
  48579. private static _getDefaultOptions;
  48580. private _rootMesh;
  48581. /**
  48582. * Gets the root mesh created by the helper.
  48583. */
  48584. readonly rootMesh: Mesh;
  48585. private _skybox;
  48586. /**
  48587. * Gets the skybox created by the helper.
  48588. */
  48589. readonly skybox: Nullable<Mesh>;
  48590. private _skyboxTexture;
  48591. /**
  48592. * Gets the skybox texture created by the helper.
  48593. */
  48594. readonly skyboxTexture: Nullable<BaseTexture>;
  48595. private _skyboxMaterial;
  48596. /**
  48597. * Gets the skybox material created by the helper.
  48598. */
  48599. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48600. private _ground;
  48601. /**
  48602. * Gets the ground mesh created by the helper.
  48603. */
  48604. readonly ground: Nullable<Mesh>;
  48605. private _groundTexture;
  48606. /**
  48607. * Gets the ground texture created by the helper.
  48608. */
  48609. readonly groundTexture: Nullable<BaseTexture>;
  48610. private _groundMirror;
  48611. /**
  48612. * Gets the ground mirror created by the helper.
  48613. */
  48614. readonly groundMirror: Nullable<MirrorTexture>;
  48615. /**
  48616. * Gets the ground mirror render list to helps pushing the meshes
  48617. * you wish in the ground reflection.
  48618. */
  48619. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48620. private _groundMaterial;
  48621. /**
  48622. * Gets the ground material created by the helper.
  48623. */
  48624. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48625. /**
  48626. * Stores the creation options.
  48627. */
  48628. private readonly _scene;
  48629. private _options;
  48630. /**
  48631. * This observable will be notified with any error during the creation of the environment,
  48632. * mainly texture creation errors.
  48633. */
  48634. onErrorObservable: Observable<{
  48635. message?: string;
  48636. exception?: any;
  48637. }>;
  48638. /**
  48639. * constructor
  48640. * @param options Defines the options we want to customize the helper
  48641. * @param scene The scene to add the material to
  48642. */
  48643. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48644. /**
  48645. * Updates the background according to the new options
  48646. * @param options
  48647. */
  48648. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48649. /**
  48650. * Sets the primary color of all the available elements.
  48651. * @param color the main color to affect to the ground and the background
  48652. */
  48653. setMainColor(color: Color3): void;
  48654. /**
  48655. * Setup the image processing according to the specified options.
  48656. */
  48657. private _setupImageProcessing;
  48658. /**
  48659. * Setup the environment texture according to the specified options.
  48660. */
  48661. private _setupEnvironmentTexture;
  48662. /**
  48663. * Setup the background according to the specified options.
  48664. */
  48665. private _setupBackground;
  48666. /**
  48667. * Get the scene sizes according to the setup.
  48668. */
  48669. private _getSceneSize;
  48670. /**
  48671. * Setup the ground according to the specified options.
  48672. */
  48673. private _setupGround;
  48674. /**
  48675. * Setup the ground material according to the specified options.
  48676. */
  48677. private _setupGroundMaterial;
  48678. /**
  48679. * Setup the ground diffuse texture according to the specified options.
  48680. */
  48681. private _setupGroundDiffuseTexture;
  48682. /**
  48683. * Setup the ground mirror texture according to the specified options.
  48684. */
  48685. private _setupGroundMirrorTexture;
  48686. /**
  48687. * Setup the ground to receive the mirror texture.
  48688. */
  48689. private _setupMirrorInGroundMaterial;
  48690. /**
  48691. * Setup the skybox according to the specified options.
  48692. */
  48693. private _setupSkybox;
  48694. /**
  48695. * Setup the skybox material according to the specified options.
  48696. */
  48697. private _setupSkyboxMaterial;
  48698. /**
  48699. * Setup the skybox reflection texture according to the specified options.
  48700. */
  48701. private _setupSkyboxReflectionTexture;
  48702. private _errorHandler;
  48703. /**
  48704. * Dispose all the elements created by the Helper.
  48705. */
  48706. dispose(): void;
  48707. }
  48708. }
  48709. declare module "babylonjs/Helpers/photoDome" {
  48710. import { Observable } from "babylonjs/Misc/observable";
  48711. import { Nullable } from "babylonjs/types";
  48712. import { Scene } from "babylonjs/scene";
  48713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48714. import { Mesh } from "babylonjs/Meshes/mesh";
  48715. import { Texture } from "babylonjs/Materials/Textures/texture";
  48716. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48717. import "babylonjs/Meshes/Builders/sphereBuilder";
  48718. /**
  48719. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48720. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48721. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48722. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48723. */
  48724. export class PhotoDome extends TransformNode {
  48725. /**
  48726. * Define the image as a Monoscopic panoramic 360 image.
  48727. */
  48728. static readonly MODE_MONOSCOPIC: number;
  48729. /**
  48730. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48731. */
  48732. static readonly MODE_TOPBOTTOM: number;
  48733. /**
  48734. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48735. */
  48736. static readonly MODE_SIDEBYSIDE: number;
  48737. private _useDirectMapping;
  48738. /**
  48739. * The texture being displayed on the sphere
  48740. */
  48741. protected _photoTexture: Texture;
  48742. /**
  48743. * Gets or sets the texture being displayed on the sphere
  48744. */
  48745. photoTexture: Texture;
  48746. /**
  48747. * Observable raised when an error occured while loading the 360 image
  48748. */
  48749. onLoadErrorObservable: Observable<string>;
  48750. /**
  48751. * The skybox material
  48752. */
  48753. protected _material: BackgroundMaterial;
  48754. /**
  48755. * The surface used for the skybox
  48756. */
  48757. protected _mesh: Mesh;
  48758. /**
  48759. * Gets the mesh used for the skybox.
  48760. */
  48761. readonly mesh: Mesh;
  48762. /**
  48763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48764. * Also see the options.resolution property.
  48765. */
  48766. fovMultiplier: number;
  48767. private _imageMode;
  48768. /**
  48769. * Gets or set the current video mode for the video. It can be:
  48770. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48771. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48772. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48773. */
  48774. imageMode: number;
  48775. /**
  48776. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48777. * @param name Element's name, child elements will append suffixes for their own names.
  48778. * @param urlsOfPhoto defines the url of the photo to display
  48779. * @param options defines an object containing optional or exposed sub element properties
  48780. * @param onError defines a callback called when an error occured while loading the texture
  48781. */
  48782. constructor(name: string, urlOfPhoto: string, options: {
  48783. resolution?: number;
  48784. size?: number;
  48785. useDirectMapping?: boolean;
  48786. faceForward?: boolean;
  48787. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48788. private _onBeforeCameraRenderObserver;
  48789. private _changeImageMode;
  48790. /**
  48791. * Releases resources associated with this node.
  48792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48794. */
  48795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48796. }
  48797. }
  48798. declare module "babylonjs/Misc/rgbdTextureTools" {
  48799. import "babylonjs/Shaders/rgbdDecode.fragment";
  48800. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48801. import { Texture } from "babylonjs/Materials/Textures/texture";
  48802. /**
  48803. * Class used to host RGBD texture specific utilities
  48804. */
  48805. export class RGBDTextureTools {
  48806. /**
  48807. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48808. * @param texture the texture to expand.
  48809. */
  48810. static ExpandRGBDTexture(texture: Texture): void;
  48811. }
  48812. }
  48813. declare module "babylonjs/Misc/brdfTextureTools" {
  48814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48815. import { Scene } from "babylonjs/scene";
  48816. /**
  48817. * Class used to host texture specific utilities
  48818. */
  48819. export class BRDFTextureTools {
  48820. /**
  48821. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48822. * @param scene defines the hosting scene
  48823. * @returns the environment BRDF texture
  48824. */
  48825. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48826. private static _environmentBRDFBase64Texture;
  48827. }
  48828. }
  48829. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48830. import { Nullable } from "babylonjs/types";
  48831. import { Color3 } from "babylonjs/Maths/math.color";
  48832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48833. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48835. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48836. import { Engine } from "babylonjs/Engines/engine";
  48837. import { Scene } from "babylonjs/scene";
  48838. /**
  48839. * @hidden
  48840. */
  48841. export interface IMaterialClearCoatDefines {
  48842. CLEARCOAT: boolean;
  48843. CLEARCOAT_DEFAULTIOR: boolean;
  48844. CLEARCOAT_TEXTURE: boolean;
  48845. CLEARCOAT_TEXTUREDIRECTUV: number;
  48846. CLEARCOAT_BUMP: boolean;
  48847. CLEARCOAT_BUMPDIRECTUV: number;
  48848. CLEARCOAT_TINT: boolean;
  48849. CLEARCOAT_TINT_TEXTURE: boolean;
  48850. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48851. /** @hidden */
  48852. _areTexturesDirty: boolean;
  48853. }
  48854. /**
  48855. * Define the code related to the clear coat parameters of the pbr material.
  48856. */
  48857. export class PBRClearCoatConfiguration {
  48858. /**
  48859. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48860. * The default fits with a polyurethane material.
  48861. */
  48862. private static readonly _DefaultIndexOfRefraction;
  48863. private _isEnabled;
  48864. /**
  48865. * Defines if the clear coat is enabled in the material.
  48866. */
  48867. isEnabled: boolean;
  48868. /**
  48869. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48870. */
  48871. intensity: number;
  48872. /**
  48873. * Defines the clear coat layer roughness.
  48874. */
  48875. roughness: number;
  48876. private _indexOfRefraction;
  48877. /**
  48878. * Defines the index of refraction of the clear coat.
  48879. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48880. * The default fits with a polyurethane material.
  48881. * Changing the default value is more performance intensive.
  48882. */
  48883. indexOfRefraction: number;
  48884. private _texture;
  48885. /**
  48886. * Stores the clear coat values in a texture.
  48887. */
  48888. texture: Nullable<BaseTexture>;
  48889. private _bumpTexture;
  48890. /**
  48891. * Define the clear coat specific bump texture.
  48892. */
  48893. bumpTexture: Nullable<BaseTexture>;
  48894. private _isTintEnabled;
  48895. /**
  48896. * Defines if the clear coat tint is enabled in the material.
  48897. */
  48898. isTintEnabled: boolean;
  48899. /**
  48900. * Defines the clear coat tint of the material.
  48901. * This is only use if tint is enabled
  48902. */
  48903. tintColor: Color3;
  48904. /**
  48905. * Defines the distance at which the tint color should be found in the
  48906. * clear coat media.
  48907. * This is only use if tint is enabled
  48908. */
  48909. tintColorAtDistance: number;
  48910. /**
  48911. * Defines the clear coat layer thickness.
  48912. * This is only use if tint is enabled
  48913. */
  48914. tintThickness: number;
  48915. private _tintTexture;
  48916. /**
  48917. * Stores the clear tint values in a texture.
  48918. * rgb is tint
  48919. * a is a thickness factor
  48920. */
  48921. tintTexture: Nullable<BaseTexture>;
  48922. /** @hidden */
  48923. private _internalMarkAllSubMeshesAsTexturesDirty;
  48924. /** @hidden */
  48925. _markAllSubMeshesAsTexturesDirty(): void;
  48926. /**
  48927. * Instantiate a new istance of clear coat configuration.
  48928. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48929. */
  48930. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48931. /**
  48932. * Gets wehter the submesh is ready to be used or not.
  48933. * @param defines the list of "defines" to update.
  48934. * @param scene defines the scene the material belongs to.
  48935. * @param engine defines the engine the material belongs to.
  48936. * @param disableBumpMap defines wether the material disables bump or not.
  48937. * @returns - boolean indicating that the submesh is ready or not.
  48938. */
  48939. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48940. /**
  48941. * Checks to see if a texture is used in the material.
  48942. * @param defines the list of "defines" to update.
  48943. * @param scene defines the scene to the material belongs to.
  48944. */
  48945. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48946. /**
  48947. * Binds the material data.
  48948. * @param uniformBuffer defines the Uniform buffer to fill in.
  48949. * @param scene defines the scene the material belongs to.
  48950. * @param engine defines the engine the material belongs to.
  48951. * @param disableBumpMap defines wether the material disables bump or not.
  48952. * @param isFrozen defines wether the material is frozen or not.
  48953. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48954. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48955. */
  48956. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48957. /**
  48958. * Checks to see if a texture is used in the material.
  48959. * @param texture - Base texture to use.
  48960. * @returns - Boolean specifying if a texture is used in the material.
  48961. */
  48962. hasTexture(texture: BaseTexture): boolean;
  48963. /**
  48964. * Returns an array of the actively used textures.
  48965. * @param activeTextures Array of BaseTextures
  48966. */
  48967. getActiveTextures(activeTextures: BaseTexture[]): void;
  48968. /**
  48969. * Returns the animatable textures.
  48970. * @param animatables Array of animatable textures.
  48971. */
  48972. getAnimatables(animatables: IAnimatable[]): void;
  48973. /**
  48974. * Disposes the resources of the material.
  48975. * @param forceDisposeTextures - Forces the disposal of all textures.
  48976. */
  48977. dispose(forceDisposeTextures?: boolean): void;
  48978. /**
  48979. * Get the current class name of the texture useful for serialization or dynamic coding.
  48980. * @returns "PBRClearCoatConfiguration"
  48981. */
  48982. getClassName(): string;
  48983. /**
  48984. * Add fallbacks to the effect fallbacks list.
  48985. * @param defines defines the Base texture to use.
  48986. * @param fallbacks defines the current fallback list.
  48987. * @param currentRank defines the current fallback rank.
  48988. * @returns the new fallback rank.
  48989. */
  48990. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48991. /**
  48992. * Add the required uniforms to the current list.
  48993. * @param uniforms defines the current uniform list.
  48994. */
  48995. static AddUniforms(uniforms: string[]): void;
  48996. /**
  48997. * Add the required samplers to the current list.
  48998. * @param samplers defines the current sampler list.
  48999. */
  49000. static AddSamplers(samplers: string[]): void;
  49001. /**
  49002. * Add the required uniforms to the current buffer.
  49003. * @param uniformBuffer defines the current uniform buffer.
  49004. */
  49005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49006. /**
  49007. * Makes a duplicate of the current configuration into another one.
  49008. * @param clearCoatConfiguration define the config where to copy the info
  49009. */
  49010. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49011. /**
  49012. * Serializes this clear coat configuration.
  49013. * @returns - An object with the serialized config.
  49014. */
  49015. serialize(): any;
  49016. /**
  49017. * Parses a anisotropy Configuration from a serialized object.
  49018. * @param source - Serialized object.
  49019. * @param scene Defines the scene we are parsing for
  49020. * @param rootUrl Defines the rootUrl to load from
  49021. */
  49022. parse(source: any, scene: Scene, rootUrl: string): void;
  49023. }
  49024. }
  49025. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49026. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49028. import { Vector2 } from "babylonjs/Maths/math.vector";
  49029. import { Scene } from "babylonjs/scene";
  49030. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49031. import { Nullable } from "babylonjs/types";
  49032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49033. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49034. /**
  49035. * @hidden
  49036. */
  49037. export interface IMaterialAnisotropicDefines {
  49038. ANISOTROPIC: boolean;
  49039. ANISOTROPIC_TEXTURE: boolean;
  49040. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49041. MAINUV1: boolean;
  49042. _areTexturesDirty: boolean;
  49043. _needUVs: boolean;
  49044. }
  49045. /**
  49046. * Define the code related to the anisotropic parameters of the pbr material.
  49047. */
  49048. export class PBRAnisotropicConfiguration {
  49049. private _isEnabled;
  49050. /**
  49051. * Defines if the anisotropy is enabled in the material.
  49052. */
  49053. isEnabled: boolean;
  49054. /**
  49055. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49056. */
  49057. intensity: number;
  49058. /**
  49059. * Defines if the effect is along the tangents, bitangents or in between.
  49060. * By default, the effect is "strectching" the highlights along the tangents.
  49061. */
  49062. direction: Vector2;
  49063. private _texture;
  49064. /**
  49065. * Stores the anisotropy values in a texture.
  49066. * rg is direction (like normal from -1 to 1)
  49067. * b is a intensity
  49068. */
  49069. texture: Nullable<BaseTexture>;
  49070. /** @hidden */
  49071. private _internalMarkAllSubMeshesAsTexturesDirty;
  49072. /** @hidden */
  49073. _markAllSubMeshesAsTexturesDirty(): void;
  49074. /**
  49075. * Instantiate a new istance of anisotropy configuration.
  49076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49077. */
  49078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49079. /**
  49080. * Specifies that the submesh is ready to be used.
  49081. * @param defines the list of "defines" to update.
  49082. * @param scene defines the scene the material belongs to.
  49083. * @returns - boolean indicating that the submesh is ready or not.
  49084. */
  49085. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49086. /**
  49087. * Checks to see if a texture is used in the material.
  49088. * @param defines the list of "defines" to update.
  49089. * @param mesh the mesh we are preparing the defines for.
  49090. * @param scene defines the scene the material belongs to.
  49091. */
  49092. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49093. /**
  49094. * Binds the material data.
  49095. * @param uniformBuffer defines the Uniform buffer to fill in.
  49096. * @param scene defines the scene the material belongs to.
  49097. * @param isFrozen defines wether the material is frozen or not.
  49098. */
  49099. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49100. /**
  49101. * Checks to see if a texture is used in the material.
  49102. * @param texture - Base texture to use.
  49103. * @returns - Boolean specifying if a texture is used in the material.
  49104. */
  49105. hasTexture(texture: BaseTexture): boolean;
  49106. /**
  49107. * Returns an array of the actively used textures.
  49108. * @param activeTextures Array of BaseTextures
  49109. */
  49110. getActiveTextures(activeTextures: BaseTexture[]): void;
  49111. /**
  49112. * Returns the animatable textures.
  49113. * @param animatables Array of animatable textures.
  49114. */
  49115. getAnimatables(animatables: IAnimatable[]): void;
  49116. /**
  49117. * Disposes the resources of the material.
  49118. * @param forceDisposeTextures - Forces the disposal of all textures.
  49119. */
  49120. dispose(forceDisposeTextures?: boolean): void;
  49121. /**
  49122. * Get the current class name of the texture useful for serialization or dynamic coding.
  49123. * @returns "PBRAnisotropicConfiguration"
  49124. */
  49125. getClassName(): string;
  49126. /**
  49127. * Add fallbacks to the effect fallbacks list.
  49128. * @param defines defines the Base texture to use.
  49129. * @param fallbacks defines the current fallback list.
  49130. * @param currentRank defines the current fallback rank.
  49131. * @returns the new fallback rank.
  49132. */
  49133. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49134. /**
  49135. * Add the required uniforms to the current list.
  49136. * @param uniforms defines the current uniform list.
  49137. */
  49138. static AddUniforms(uniforms: string[]): void;
  49139. /**
  49140. * Add the required uniforms to the current buffer.
  49141. * @param uniformBuffer defines the current uniform buffer.
  49142. */
  49143. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49144. /**
  49145. * Add the required samplers to the current list.
  49146. * @param samplers defines the current sampler list.
  49147. */
  49148. static AddSamplers(samplers: string[]): void;
  49149. /**
  49150. * Makes a duplicate of the current configuration into another one.
  49151. * @param anisotropicConfiguration define the config where to copy the info
  49152. */
  49153. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49154. /**
  49155. * Serializes this anisotropy configuration.
  49156. * @returns - An object with the serialized config.
  49157. */
  49158. serialize(): any;
  49159. /**
  49160. * Parses a anisotropy Configuration from a serialized object.
  49161. * @param source - Serialized object.
  49162. * @param scene Defines the scene we are parsing for
  49163. * @param rootUrl Defines the rootUrl to load from
  49164. */
  49165. parse(source: any, scene: Scene, rootUrl: string): void;
  49166. }
  49167. }
  49168. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49169. import { Scene } from "babylonjs/scene";
  49170. /**
  49171. * @hidden
  49172. */
  49173. export interface IMaterialBRDFDefines {
  49174. BRDF_V_HEIGHT_CORRELATED: boolean;
  49175. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49176. SPHERICAL_HARMONICS: boolean;
  49177. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49178. /** @hidden */
  49179. _areMiscDirty: boolean;
  49180. }
  49181. /**
  49182. * Define the code related to the BRDF parameters of the pbr material.
  49183. */
  49184. export class PBRBRDFConfiguration {
  49185. /**
  49186. * Default value used for the energy conservation.
  49187. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49188. */
  49189. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49190. /**
  49191. * Default value used for the Smith Visibility Height Correlated mode.
  49192. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49193. */
  49194. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49195. /**
  49196. * Default value used for the IBL diffuse part.
  49197. * This can help switching back to the polynomials mode globally which is a tiny bit
  49198. * less GPU intensive at the drawback of a lower quality.
  49199. */
  49200. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49201. /**
  49202. * Default value used for activating energy conservation for the specular workflow.
  49203. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49204. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49205. */
  49206. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49207. private _useEnergyConservation;
  49208. /**
  49209. * Defines if the material uses energy conservation.
  49210. */
  49211. useEnergyConservation: boolean;
  49212. private _useSmithVisibilityHeightCorrelated;
  49213. /**
  49214. * LEGACY Mode set to false
  49215. * Defines if the material uses height smith correlated visibility term.
  49216. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49217. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49218. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49219. * Not relying on height correlated will also disable energy conservation.
  49220. */
  49221. useSmithVisibilityHeightCorrelated: boolean;
  49222. private _useSphericalHarmonics;
  49223. /**
  49224. * LEGACY Mode set to false
  49225. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49226. * diffuse part of the IBL.
  49227. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49228. * to the ground truth.
  49229. */
  49230. useSphericalHarmonics: boolean;
  49231. private _useSpecularGlossinessInputEnergyConservation;
  49232. /**
  49233. * Defines if the material uses energy conservation, when the specular workflow is active.
  49234. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49235. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49236. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49237. */
  49238. useSpecularGlossinessInputEnergyConservation: boolean;
  49239. /** @hidden */
  49240. private _internalMarkAllSubMeshesAsMiscDirty;
  49241. /** @hidden */
  49242. _markAllSubMeshesAsMiscDirty(): void;
  49243. /**
  49244. * Instantiate a new istance of clear coat configuration.
  49245. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49246. */
  49247. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49248. /**
  49249. * Checks to see if a texture is used in the material.
  49250. * @param defines the list of "defines" to update.
  49251. */
  49252. prepareDefines(defines: IMaterialBRDFDefines): void;
  49253. /**
  49254. * Get the current class name of the texture useful for serialization or dynamic coding.
  49255. * @returns "PBRClearCoatConfiguration"
  49256. */
  49257. getClassName(): string;
  49258. /**
  49259. * Makes a duplicate of the current configuration into another one.
  49260. * @param brdfConfiguration define the config where to copy the info
  49261. */
  49262. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49263. /**
  49264. * Serializes this BRDF configuration.
  49265. * @returns - An object with the serialized config.
  49266. */
  49267. serialize(): any;
  49268. /**
  49269. * Parses a anisotropy Configuration from a serialized object.
  49270. * @param source - Serialized object.
  49271. * @param scene Defines the scene we are parsing for
  49272. * @param rootUrl Defines the rootUrl to load from
  49273. */
  49274. parse(source: any, scene: Scene, rootUrl: string): void;
  49275. }
  49276. }
  49277. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49278. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49279. import { Color3 } from "babylonjs/Maths/math.color";
  49280. import { Scene } from "babylonjs/scene";
  49281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49282. import { Nullable } from "babylonjs/types";
  49283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49284. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49285. /**
  49286. * @hidden
  49287. */
  49288. export interface IMaterialSheenDefines {
  49289. SHEEN: boolean;
  49290. SHEEN_TEXTURE: boolean;
  49291. SHEEN_TEXTUREDIRECTUV: number;
  49292. SHEEN_LINKWITHALBEDO: boolean;
  49293. /** @hidden */
  49294. _areTexturesDirty: boolean;
  49295. }
  49296. /**
  49297. * Define the code related to the Sheen parameters of the pbr material.
  49298. */
  49299. export class PBRSheenConfiguration {
  49300. private _isEnabled;
  49301. /**
  49302. * Defines if the material uses sheen.
  49303. */
  49304. isEnabled: boolean;
  49305. private _linkSheenWithAlbedo;
  49306. /**
  49307. * Defines if the sheen is linked to the sheen color.
  49308. */
  49309. linkSheenWithAlbedo: boolean;
  49310. /**
  49311. * Defines the sheen intensity.
  49312. */
  49313. intensity: number;
  49314. /**
  49315. * Defines the sheen color.
  49316. */
  49317. color: Color3;
  49318. private _texture;
  49319. /**
  49320. * Stores the sheen tint values in a texture.
  49321. * rgb is tint
  49322. * a is a intensity
  49323. */
  49324. texture: Nullable<BaseTexture>;
  49325. /** @hidden */
  49326. private _internalMarkAllSubMeshesAsTexturesDirty;
  49327. /** @hidden */
  49328. _markAllSubMeshesAsTexturesDirty(): void;
  49329. /**
  49330. * Instantiate a new istance of clear coat configuration.
  49331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49332. */
  49333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49334. /**
  49335. * Specifies that the submesh is ready to be used.
  49336. * @param defines the list of "defines" to update.
  49337. * @param scene defines the scene the material belongs to.
  49338. * @returns - boolean indicating that the submesh is ready or not.
  49339. */
  49340. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49341. /**
  49342. * Checks to see if a texture is used in the material.
  49343. * @param defines the list of "defines" to update.
  49344. * @param scene defines the scene the material belongs to.
  49345. */
  49346. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49347. /**
  49348. * Binds the material data.
  49349. * @param uniformBuffer defines the Uniform buffer to fill in.
  49350. * @param scene defines the scene the material belongs to.
  49351. * @param isFrozen defines wether the material is frozen or not.
  49352. */
  49353. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49354. /**
  49355. * Checks to see if a texture is used in the material.
  49356. * @param texture - Base texture to use.
  49357. * @returns - Boolean specifying if a texture is used in the material.
  49358. */
  49359. hasTexture(texture: BaseTexture): boolean;
  49360. /**
  49361. * Returns an array of the actively used textures.
  49362. * @param activeTextures Array of BaseTextures
  49363. */
  49364. getActiveTextures(activeTextures: BaseTexture[]): void;
  49365. /**
  49366. * Returns the animatable textures.
  49367. * @param animatables Array of animatable textures.
  49368. */
  49369. getAnimatables(animatables: IAnimatable[]): void;
  49370. /**
  49371. * Disposes the resources of the material.
  49372. * @param forceDisposeTextures - Forces the disposal of all textures.
  49373. */
  49374. dispose(forceDisposeTextures?: boolean): void;
  49375. /**
  49376. * Get the current class name of the texture useful for serialization or dynamic coding.
  49377. * @returns "PBRSheenConfiguration"
  49378. */
  49379. getClassName(): string;
  49380. /**
  49381. * Add fallbacks to the effect fallbacks list.
  49382. * @param defines defines the Base texture to use.
  49383. * @param fallbacks defines the current fallback list.
  49384. * @param currentRank defines the current fallback rank.
  49385. * @returns the new fallback rank.
  49386. */
  49387. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49388. /**
  49389. * Add the required uniforms to the current list.
  49390. * @param uniforms defines the current uniform list.
  49391. */
  49392. static AddUniforms(uniforms: string[]): void;
  49393. /**
  49394. * Add the required uniforms to the current buffer.
  49395. * @param uniformBuffer defines the current uniform buffer.
  49396. */
  49397. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49398. /**
  49399. * Add the required samplers to the current list.
  49400. * @param samplers defines the current sampler list.
  49401. */
  49402. static AddSamplers(samplers: string[]): void;
  49403. /**
  49404. * Makes a duplicate of the current configuration into another one.
  49405. * @param sheenConfiguration define the config where to copy the info
  49406. */
  49407. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49408. /**
  49409. * Serializes this BRDF configuration.
  49410. * @returns - An object with the serialized config.
  49411. */
  49412. serialize(): any;
  49413. /**
  49414. * Parses a anisotropy Configuration from a serialized object.
  49415. * @param source - Serialized object.
  49416. * @param scene Defines the scene we are parsing for
  49417. * @param rootUrl Defines the rootUrl to load from
  49418. */
  49419. parse(source: any, scene: Scene, rootUrl: string): void;
  49420. }
  49421. }
  49422. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49423. import { Nullable } from "babylonjs/types";
  49424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49425. import { Color3 } from "babylonjs/Maths/math.color";
  49426. import { SmartArray } from "babylonjs/Misc/smartArray";
  49427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49429. import { Effect } from "babylonjs/Materials/effect";
  49430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49431. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49432. import { Engine } from "babylonjs/Engines/engine";
  49433. import { Scene } from "babylonjs/scene";
  49434. /**
  49435. * @hidden
  49436. */
  49437. export interface IMaterialSubSurfaceDefines {
  49438. SUBSURFACE: boolean;
  49439. SS_REFRACTION: boolean;
  49440. SS_TRANSLUCENCY: boolean;
  49441. SS_SCATERRING: boolean;
  49442. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49443. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49444. SS_REFRACTIONMAP_3D: boolean;
  49445. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49446. SS_LODINREFRACTIONALPHA: boolean;
  49447. SS_GAMMAREFRACTION: boolean;
  49448. SS_RGBDREFRACTION: boolean;
  49449. SS_LINEARSPECULARREFRACTION: boolean;
  49450. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49451. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49452. /** @hidden */
  49453. _areTexturesDirty: boolean;
  49454. }
  49455. /**
  49456. * Define the code related to the sub surface parameters of the pbr material.
  49457. */
  49458. export class PBRSubSurfaceConfiguration {
  49459. private _isRefractionEnabled;
  49460. /**
  49461. * Defines if the refraction is enabled in the material.
  49462. */
  49463. isRefractionEnabled: boolean;
  49464. private _isTranslucencyEnabled;
  49465. /**
  49466. * Defines if the translucency is enabled in the material.
  49467. */
  49468. isTranslucencyEnabled: boolean;
  49469. private _isScatteringEnabled;
  49470. /**
  49471. * Defines the refraction intensity of the material.
  49472. * The refraction when enabled replaces the Diffuse part of the material.
  49473. * The intensity helps transitionning between diffuse and refraction.
  49474. */
  49475. refractionIntensity: number;
  49476. /**
  49477. * Defines the translucency intensity of the material.
  49478. * When translucency has been enabled, this defines how much of the "translucency"
  49479. * is addded to the diffuse part of the material.
  49480. */
  49481. translucencyIntensity: number;
  49482. /**
  49483. * Defines the scattering intensity of the material.
  49484. * When scattering has been enabled, this defines how much of the "scattered light"
  49485. * is addded to the diffuse part of the material.
  49486. */
  49487. scatteringIntensity: number;
  49488. private _thicknessTexture;
  49489. /**
  49490. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49491. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49492. * 0 would mean minimumThickness
  49493. * 1 would mean maximumThickness
  49494. * The other channels might be use as a mask to vary the different effects intensity.
  49495. */
  49496. thicknessTexture: Nullable<BaseTexture>;
  49497. private _refractionTexture;
  49498. /**
  49499. * Defines the texture to use for refraction.
  49500. */
  49501. refractionTexture: Nullable<BaseTexture>;
  49502. private _indexOfRefraction;
  49503. /**
  49504. * Defines the index of refraction used in the material.
  49505. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49506. */
  49507. indexOfRefraction: number;
  49508. private _invertRefractionY;
  49509. /**
  49510. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49511. */
  49512. invertRefractionY: boolean;
  49513. private _linkRefractionWithTransparency;
  49514. /**
  49515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49516. * Materials half opaque for instance using refraction could benefit from this control.
  49517. */
  49518. linkRefractionWithTransparency: boolean;
  49519. /**
  49520. * Defines the minimum thickness stored in the thickness map.
  49521. * If no thickness map is defined, this value will be used to simulate thickness.
  49522. */
  49523. minimumThickness: number;
  49524. /**
  49525. * Defines the maximum thickness stored in the thickness map.
  49526. */
  49527. maximumThickness: number;
  49528. /**
  49529. * Defines the volume tint of the material.
  49530. * This is used for both translucency and scattering.
  49531. */
  49532. tintColor: Color3;
  49533. /**
  49534. * Defines the distance at which the tint color should be found in the media.
  49535. * This is used for refraction only.
  49536. */
  49537. tintColorAtDistance: number;
  49538. /**
  49539. * Defines how far each channel transmit through the media.
  49540. * It is defined as a color to simplify it selection.
  49541. */
  49542. diffusionDistance: Color3;
  49543. private _useMaskFromThicknessTexture;
  49544. /**
  49545. * Stores the intensity of the different subsurface effects in the thickness texture.
  49546. * * the green channel is the translucency intensity.
  49547. * * the blue channel is the scattering intensity.
  49548. * * the alpha channel is the refraction intensity.
  49549. */
  49550. useMaskFromThicknessTexture: boolean;
  49551. /** @hidden */
  49552. private _internalMarkAllSubMeshesAsTexturesDirty;
  49553. /** @hidden */
  49554. _markAllSubMeshesAsTexturesDirty(): void;
  49555. /**
  49556. * Instantiate a new istance of sub surface configuration.
  49557. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49558. */
  49559. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49560. /**
  49561. * Gets wehter the submesh is ready to be used or not.
  49562. * @param defines the list of "defines" to update.
  49563. * @param scene defines the scene the material belongs to.
  49564. * @returns - boolean indicating that the submesh is ready or not.
  49565. */
  49566. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49567. /**
  49568. * Checks to see if a texture is used in the material.
  49569. * @param defines the list of "defines" to update.
  49570. * @param scene defines the scene to the material belongs to.
  49571. */
  49572. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49573. /**
  49574. * Binds the material data.
  49575. * @param uniformBuffer defines the Uniform buffer to fill in.
  49576. * @param scene defines the scene the material belongs to.
  49577. * @param engine defines the engine the material belongs to.
  49578. * @param isFrozen defines wether the material is frozen or not.
  49579. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49580. */
  49581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49582. /**
  49583. * Unbinds the material from the mesh.
  49584. * @param activeEffect defines the effect that should be unbound from.
  49585. * @returns true if unbound, otherwise false
  49586. */
  49587. unbind(activeEffect: Effect): boolean;
  49588. /**
  49589. * Returns the texture used for refraction or null if none is used.
  49590. * @param scene defines the scene the material belongs to.
  49591. * @returns - Refraction texture if present. If no refraction texture and refraction
  49592. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49593. */
  49594. private _getRefractionTexture;
  49595. /**
  49596. * Returns true if alpha blending should be disabled.
  49597. */
  49598. readonly disableAlphaBlending: boolean;
  49599. /**
  49600. * Fills the list of render target textures.
  49601. * @param renderTargets the list of render targets to update
  49602. */
  49603. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49604. /**
  49605. * Checks to see if a texture is used in the material.
  49606. * @param texture - Base texture to use.
  49607. * @returns - Boolean specifying if a texture is used in the material.
  49608. */
  49609. hasTexture(texture: BaseTexture): boolean;
  49610. /**
  49611. * Gets a boolean indicating that current material needs to register RTT
  49612. * @returns true if this uses a render target otherwise false.
  49613. */
  49614. hasRenderTargetTextures(): boolean;
  49615. /**
  49616. * Returns an array of the actively used textures.
  49617. * @param activeTextures Array of BaseTextures
  49618. */
  49619. getActiveTextures(activeTextures: BaseTexture[]): void;
  49620. /**
  49621. * Returns the animatable textures.
  49622. * @param animatables Array of animatable textures.
  49623. */
  49624. getAnimatables(animatables: IAnimatable[]): void;
  49625. /**
  49626. * Disposes the resources of the material.
  49627. * @param forceDisposeTextures - Forces the disposal of all textures.
  49628. */
  49629. dispose(forceDisposeTextures?: boolean): void;
  49630. /**
  49631. * Get the current class name of the texture useful for serialization or dynamic coding.
  49632. * @returns "PBRSubSurfaceConfiguration"
  49633. */
  49634. getClassName(): string;
  49635. /**
  49636. * Add fallbacks to the effect fallbacks list.
  49637. * @param defines defines the Base texture to use.
  49638. * @param fallbacks defines the current fallback list.
  49639. * @param currentRank defines the current fallback rank.
  49640. * @returns the new fallback rank.
  49641. */
  49642. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49643. /**
  49644. * Add the required uniforms to the current list.
  49645. * @param uniforms defines the current uniform list.
  49646. */
  49647. static AddUniforms(uniforms: string[]): void;
  49648. /**
  49649. * Add the required samplers to the current list.
  49650. * @param samplers defines the current sampler list.
  49651. */
  49652. static AddSamplers(samplers: string[]): void;
  49653. /**
  49654. * Add the required uniforms to the current buffer.
  49655. * @param uniformBuffer defines the current uniform buffer.
  49656. */
  49657. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49658. /**
  49659. * Makes a duplicate of the current configuration into another one.
  49660. * @param configuration define the config where to copy the info
  49661. */
  49662. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49663. /**
  49664. * Serializes this Sub Surface configuration.
  49665. * @returns - An object with the serialized config.
  49666. */
  49667. serialize(): any;
  49668. /**
  49669. * Parses a anisotropy Configuration from a serialized object.
  49670. * @param source - Serialized object.
  49671. * @param scene Defines the scene we are parsing for
  49672. * @param rootUrl Defines the rootUrl to load from
  49673. */
  49674. parse(source: any, scene: Scene, rootUrl: string): void;
  49675. }
  49676. }
  49677. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49678. /** @hidden */
  49679. export var pbrFragmentDeclaration: {
  49680. name: string;
  49681. shader: string;
  49682. };
  49683. }
  49684. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49685. /** @hidden */
  49686. export var pbrUboDeclaration: {
  49687. name: string;
  49688. shader: string;
  49689. };
  49690. }
  49691. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49692. /** @hidden */
  49693. export var pbrFragmentExtraDeclaration: {
  49694. name: string;
  49695. shader: string;
  49696. };
  49697. }
  49698. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49699. /** @hidden */
  49700. export var pbrFragmentSamplersDeclaration: {
  49701. name: string;
  49702. shader: string;
  49703. };
  49704. }
  49705. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49706. /** @hidden */
  49707. export var pbrHelperFunctions: {
  49708. name: string;
  49709. shader: string;
  49710. };
  49711. }
  49712. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49713. /** @hidden */
  49714. export var harmonicsFunctions: {
  49715. name: string;
  49716. shader: string;
  49717. };
  49718. }
  49719. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49720. /** @hidden */
  49721. export var pbrDirectLightingSetupFunctions: {
  49722. name: string;
  49723. shader: string;
  49724. };
  49725. }
  49726. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49727. /** @hidden */
  49728. export var pbrDirectLightingFalloffFunctions: {
  49729. name: string;
  49730. shader: string;
  49731. };
  49732. }
  49733. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49734. /** @hidden */
  49735. export var pbrBRDFFunctions: {
  49736. name: string;
  49737. shader: string;
  49738. };
  49739. }
  49740. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49741. /** @hidden */
  49742. export var pbrDirectLightingFunctions: {
  49743. name: string;
  49744. shader: string;
  49745. };
  49746. }
  49747. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49748. /** @hidden */
  49749. export var pbrIBLFunctions: {
  49750. name: string;
  49751. shader: string;
  49752. };
  49753. }
  49754. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49755. /** @hidden */
  49756. export var pbrDebug: {
  49757. name: string;
  49758. shader: string;
  49759. };
  49760. }
  49761. declare module "babylonjs/Shaders/pbr.fragment" {
  49762. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49763. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49764. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49765. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49766. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49767. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49768. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49769. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49770. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49771. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49772. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49773. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49775. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49776. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49777. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49778. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49779. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49780. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49781. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49782. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49783. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49785. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49786. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49787. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49788. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49789. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49790. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49791. /** @hidden */
  49792. export var pbrPixelShader: {
  49793. name: string;
  49794. shader: string;
  49795. };
  49796. }
  49797. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49798. /** @hidden */
  49799. export var pbrVertexDeclaration: {
  49800. name: string;
  49801. shader: string;
  49802. };
  49803. }
  49804. declare module "babylonjs/Shaders/pbr.vertex" {
  49805. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49806. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49807. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49808. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49809. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49810. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49811. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49812. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49813. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49814. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49815. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49820. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49821. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49822. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49823. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49824. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49825. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49826. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49827. /** @hidden */
  49828. export var pbrVertexShader: {
  49829. name: string;
  49830. shader: string;
  49831. };
  49832. }
  49833. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49834. import { Nullable } from "babylonjs/types";
  49835. import { Scene } from "babylonjs/scene";
  49836. import { Matrix } from "babylonjs/Maths/math.vector";
  49837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49839. import { Mesh } from "babylonjs/Meshes/mesh";
  49840. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49841. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49842. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49843. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49844. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49845. import { Color3 } from "babylonjs/Maths/math.color";
  49846. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49847. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49848. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49849. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49851. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49852. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49853. import "babylonjs/Shaders/pbr.fragment";
  49854. import "babylonjs/Shaders/pbr.vertex";
  49855. /**
  49856. * Manages the defines for the PBR Material.
  49857. * @hidden
  49858. */
  49859. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49860. PBR: boolean;
  49861. MAINUV1: boolean;
  49862. MAINUV2: boolean;
  49863. UV1: boolean;
  49864. UV2: boolean;
  49865. ALBEDO: boolean;
  49866. ALBEDODIRECTUV: number;
  49867. VERTEXCOLOR: boolean;
  49868. AMBIENT: boolean;
  49869. AMBIENTDIRECTUV: number;
  49870. AMBIENTINGRAYSCALE: boolean;
  49871. OPACITY: boolean;
  49872. VERTEXALPHA: boolean;
  49873. OPACITYDIRECTUV: number;
  49874. OPACITYRGB: boolean;
  49875. ALPHATEST: boolean;
  49876. DEPTHPREPASS: boolean;
  49877. ALPHABLEND: boolean;
  49878. ALPHAFROMALBEDO: boolean;
  49879. ALPHATESTVALUE: string;
  49880. SPECULAROVERALPHA: boolean;
  49881. RADIANCEOVERALPHA: boolean;
  49882. ALPHAFRESNEL: boolean;
  49883. LINEARALPHAFRESNEL: boolean;
  49884. PREMULTIPLYALPHA: boolean;
  49885. EMISSIVE: boolean;
  49886. EMISSIVEDIRECTUV: number;
  49887. REFLECTIVITY: boolean;
  49888. REFLECTIVITYDIRECTUV: number;
  49889. SPECULARTERM: boolean;
  49890. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49891. MICROSURFACEAUTOMATIC: boolean;
  49892. LODBASEDMICROSFURACE: boolean;
  49893. MICROSURFACEMAP: boolean;
  49894. MICROSURFACEMAPDIRECTUV: number;
  49895. METALLICWORKFLOW: boolean;
  49896. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49897. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49898. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49899. AOSTOREINMETALMAPRED: boolean;
  49900. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49901. ENVIRONMENTBRDF: boolean;
  49902. ENVIRONMENTBRDF_RGBD: boolean;
  49903. NORMAL: boolean;
  49904. TANGENT: boolean;
  49905. BUMP: boolean;
  49906. BUMPDIRECTUV: number;
  49907. OBJECTSPACE_NORMALMAP: boolean;
  49908. PARALLAX: boolean;
  49909. PARALLAXOCCLUSION: boolean;
  49910. NORMALXYSCALE: boolean;
  49911. LIGHTMAP: boolean;
  49912. LIGHTMAPDIRECTUV: number;
  49913. USELIGHTMAPASSHADOWMAP: boolean;
  49914. GAMMALIGHTMAP: boolean;
  49915. RGBDLIGHTMAP: boolean;
  49916. REFLECTION: boolean;
  49917. REFLECTIONMAP_3D: boolean;
  49918. REFLECTIONMAP_SPHERICAL: boolean;
  49919. REFLECTIONMAP_PLANAR: boolean;
  49920. REFLECTIONMAP_CUBIC: boolean;
  49921. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49922. REFLECTIONMAP_PROJECTION: boolean;
  49923. REFLECTIONMAP_SKYBOX: boolean;
  49924. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49925. REFLECTIONMAP_EXPLICIT: boolean;
  49926. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49927. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49928. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49929. INVERTCUBICMAP: boolean;
  49930. USESPHERICALFROMREFLECTIONMAP: boolean;
  49931. USEIRRADIANCEMAP: boolean;
  49932. SPHERICAL_HARMONICS: boolean;
  49933. USESPHERICALINVERTEX: boolean;
  49934. REFLECTIONMAP_OPPOSITEZ: boolean;
  49935. LODINREFLECTIONALPHA: boolean;
  49936. GAMMAREFLECTION: boolean;
  49937. RGBDREFLECTION: boolean;
  49938. LINEARSPECULARREFLECTION: boolean;
  49939. RADIANCEOCCLUSION: boolean;
  49940. HORIZONOCCLUSION: boolean;
  49941. INSTANCES: boolean;
  49942. NUM_BONE_INFLUENCERS: number;
  49943. BonesPerMesh: number;
  49944. BONETEXTURE: boolean;
  49945. NONUNIFORMSCALING: boolean;
  49946. MORPHTARGETS: boolean;
  49947. MORPHTARGETS_NORMAL: boolean;
  49948. MORPHTARGETS_TANGENT: boolean;
  49949. MORPHTARGETS_UV: boolean;
  49950. NUM_MORPH_INFLUENCERS: number;
  49951. IMAGEPROCESSING: boolean;
  49952. VIGNETTE: boolean;
  49953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49954. VIGNETTEBLENDMODEOPAQUE: boolean;
  49955. TONEMAPPING: boolean;
  49956. TONEMAPPING_ACES: boolean;
  49957. CONTRAST: boolean;
  49958. COLORCURVES: boolean;
  49959. COLORGRADING: boolean;
  49960. COLORGRADING3D: boolean;
  49961. SAMPLER3DGREENDEPTH: boolean;
  49962. SAMPLER3DBGRMAP: boolean;
  49963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49964. EXPOSURE: boolean;
  49965. MULTIVIEW: boolean;
  49966. USEPHYSICALLIGHTFALLOFF: boolean;
  49967. USEGLTFLIGHTFALLOFF: boolean;
  49968. TWOSIDEDLIGHTING: boolean;
  49969. SHADOWFLOAT: boolean;
  49970. CLIPPLANE: boolean;
  49971. CLIPPLANE2: boolean;
  49972. CLIPPLANE3: boolean;
  49973. CLIPPLANE4: boolean;
  49974. POINTSIZE: boolean;
  49975. FOG: boolean;
  49976. LOGARITHMICDEPTH: boolean;
  49977. FORCENORMALFORWARD: boolean;
  49978. SPECULARAA: boolean;
  49979. CLEARCOAT: boolean;
  49980. CLEARCOAT_DEFAULTIOR: boolean;
  49981. CLEARCOAT_TEXTURE: boolean;
  49982. CLEARCOAT_TEXTUREDIRECTUV: number;
  49983. CLEARCOAT_BUMP: boolean;
  49984. CLEARCOAT_BUMPDIRECTUV: number;
  49985. CLEARCOAT_TINT: boolean;
  49986. CLEARCOAT_TINT_TEXTURE: boolean;
  49987. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49988. ANISOTROPIC: boolean;
  49989. ANISOTROPIC_TEXTURE: boolean;
  49990. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49991. BRDF_V_HEIGHT_CORRELATED: boolean;
  49992. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49993. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49994. SHEEN: boolean;
  49995. SHEEN_TEXTURE: boolean;
  49996. SHEEN_TEXTUREDIRECTUV: number;
  49997. SHEEN_LINKWITHALBEDO: boolean;
  49998. SUBSURFACE: boolean;
  49999. SS_REFRACTION: boolean;
  50000. SS_TRANSLUCENCY: boolean;
  50001. SS_SCATERRING: boolean;
  50002. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50003. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50004. SS_REFRACTIONMAP_3D: boolean;
  50005. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50006. SS_LODINREFRACTIONALPHA: boolean;
  50007. SS_GAMMAREFRACTION: boolean;
  50008. SS_RGBDREFRACTION: boolean;
  50009. SS_LINEARSPECULARREFRACTION: boolean;
  50010. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50011. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50012. UNLIT: boolean;
  50013. DEBUGMODE: number;
  50014. /**
  50015. * Initializes the PBR Material defines.
  50016. */
  50017. constructor();
  50018. /**
  50019. * Resets the PBR Material defines.
  50020. */
  50021. reset(): void;
  50022. }
  50023. /**
  50024. * The Physically based material base class of BJS.
  50025. *
  50026. * This offers the main features of a standard PBR material.
  50027. * For more information, please refer to the documentation :
  50028. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50029. */
  50030. export abstract class PBRBaseMaterial extends PushMaterial {
  50031. /**
  50032. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50033. */
  50034. static readonly PBRMATERIAL_OPAQUE: number;
  50035. /**
  50036. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50037. */
  50038. static readonly PBRMATERIAL_ALPHATEST: number;
  50039. /**
  50040. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50041. */
  50042. static readonly PBRMATERIAL_ALPHABLEND: number;
  50043. /**
  50044. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50045. * They are also discarded below the alpha cutoff threshold to improve performances.
  50046. */
  50047. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50048. /**
  50049. * Defines the default value of how much AO map is occluding the analytical lights
  50050. * (point spot...).
  50051. */
  50052. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50053. /**
  50054. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50055. */
  50056. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50057. /**
  50058. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50059. * to enhance interoperability with other engines.
  50060. */
  50061. static readonly LIGHTFALLOFF_GLTF: number;
  50062. /**
  50063. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50064. * to enhance interoperability with other materials.
  50065. */
  50066. static readonly LIGHTFALLOFF_STANDARD: number;
  50067. /**
  50068. * Intensity of the direct lights e.g. the four lights available in your scene.
  50069. * This impacts both the direct diffuse and specular highlights.
  50070. */
  50071. protected _directIntensity: number;
  50072. /**
  50073. * Intensity of the emissive part of the material.
  50074. * This helps controlling the emissive effect without modifying the emissive color.
  50075. */
  50076. protected _emissiveIntensity: number;
  50077. /**
  50078. * Intensity of the environment e.g. how much the environment will light the object
  50079. * either through harmonics for rough material or through the refelction for shiny ones.
  50080. */
  50081. protected _environmentIntensity: number;
  50082. /**
  50083. * This is a special control allowing the reduction of the specular highlights coming from the
  50084. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50085. */
  50086. protected _specularIntensity: number;
  50087. /**
  50088. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50089. */
  50090. private _lightingInfos;
  50091. /**
  50092. * Debug Control allowing disabling the bump map on this material.
  50093. */
  50094. protected _disableBumpMap: boolean;
  50095. /**
  50096. * AKA Diffuse Texture in standard nomenclature.
  50097. */
  50098. protected _albedoTexture: Nullable<BaseTexture>;
  50099. /**
  50100. * AKA Occlusion Texture in other nomenclature.
  50101. */
  50102. protected _ambientTexture: Nullable<BaseTexture>;
  50103. /**
  50104. * AKA Occlusion Texture Intensity in other nomenclature.
  50105. */
  50106. protected _ambientTextureStrength: number;
  50107. /**
  50108. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50109. * 1 means it completely occludes it
  50110. * 0 mean it has no impact
  50111. */
  50112. protected _ambientTextureImpactOnAnalyticalLights: number;
  50113. /**
  50114. * Stores the alpha values in a texture.
  50115. */
  50116. protected _opacityTexture: Nullable<BaseTexture>;
  50117. /**
  50118. * Stores the reflection values in a texture.
  50119. */
  50120. protected _reflectionTexture: Nullable<BaseTexture>;
  50121. /**
  50122. * Stores the emissive values in a texture.
  50123. */
  50124. protected _emissiveTexture: Nullable<BaseTexture>;
  50125. /**
  50126. * AKA Specular texture in other nomenclature.
  50127. */
  50128. protected _reflectivityTexture: Nullable<BaseTexture>;
  50129. /**
  50130. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50131. */
  50132. protected _metallicTexture: Nullable<BaseTexture>;
  50133. /**
  50134. * Specifies the metallic scalar of the metallic/roughness workflow.
  50135. * Can also be used to scale the metalness values of the metallic texture.
  50136. */
  50137. protected _metallic: Nullable<number>;
  50138. /**
  50139. * Specifies the roughness scalar of the metallic/roughness workflow.
  50140. * Can also be used to scale the roughness values of the metallic texture.
  50141. */
  50142. protected _roughness: Nullable<number>;
  50143. /**
  50144. * Specifies the an F0 factor to help configuring the material F0.
  50145. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50146. * to 0.5 the previously hard coded value stays the same.
  50147. * Can also be used to scale the F0 values of the metallic texture.
  50148. */
  50149. protected _metallicF0Factor: number;
  50150. /**
  50151. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50152. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50153. * your expectation as it multiplies with the texture data.
  50154. */
  50155. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50156. /**
  50157. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50158. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50159. */
  50160. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50161. /**
  50162. * Stores surface normal data used to displace a mesh in a texture.
  50163. */
  50164. protected _bumpTexture: Nullable<BaseTexture>;
  50165. /**
  50166. * Stores the pre-calculated light information of a mesh in a texture.
  50167. */
  50168. protected _lightmapTexture: Nullable<BaseTexture>;
  50169. /**
  50170. * The color of a material in ambient lighting.
  50171. */
  50172. protected _ambientColor: Color3;
  50173. /**
  50174. * AKA Diffuse Color in other nomenclature.
  50175. */
  50176. protected _albedoColor: Color3;
  50177. /**
  50178. * AKA Specular Color in other nomenclature.
  50179. */
  50180. protected _reflectivityColor: Color3;
  50181. /**
  50182. * The color applied when light is reflected from a material.
  50183. */
  50184. protected _reflectionColor: Color3;
  50185. /**
  50186. * The color applied when light is emitted from a material.
  50187. */
  50188. protected _emissiveColor: Color3;
  50189. /**
  50190. * AKA Glossiness in other nomenclature.
  50191. */
  50192. protected _microSurface: number;
  50193. /**
  50194. * Specifies that the material will use the light map as a show map.
  50195. */
  50196. protected _useLightmapAsShadowmap: boolean;
  50197. /**
  50198. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50199. * makes the reflect vector face the model (under horizon).
  50200. */
  50201. protected _useHorizonOcclusion: boolean;
  50202. /**
  50203. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50204. * too much the area relying on ambient texture to define their ambient occlusion.
  50205. */
  50206. protected _useRadianceOcclusion: boolean;
  50207. /**
  50208. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50209. */
  50210. protected _useAlphaFromAlbedoTexture: boolean;
  50211. /**
  50212. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50213. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50214. */
  50215. protected _useSpecularOverAlpha: boolean;
  50216. /**
  50217. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50218. */
  50219. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50220. /**
  50221. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50222. */
  50223. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50224. /**
  50225. * Specifies if the metallic texture contains the roughness information in its green channel.
  50226. */
  50227. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50228. /**
  50229. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50230. */
  50231. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50232. /**
  50233. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50234. */
  50235. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50236. /**
  50237. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50238. */
  50239. protected _useAmbientInGrayScale: boolean;
  50240. /**
  50241. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50242. * The material will try to infer what glossiness each pixel should be.
  50243. */
  50244. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50245. /**
  50246. * Defines the falloff type used in this material.
  50247. * It by default is Physical.
  50248. */
  50249. protected _lightFalloff: number;
  50250. /**
  50251. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50252. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50253. */
  50254. protected _useRadianceOverAlpha: boolean;
  50255. /**
  50256. * Allows using an object space normal map (instead of tangent space).
  50257. */
  50258. protected _useObjectSpaceNormalMap: boolean;
  50259. /**
  50260. * Allows using the bump map in parallax mode.
  50261. */
  50262. protected _useParallax: boolean;
  50263. /**
  50264. * Allows using the bump map in parallax occlusion mode.
  50265. */
  50266. protected _useParallaxOcclusion: boolean;
  50267. /**
  50268. * Controls the scale bias of the parallax mode.
  50269. */
  50270. protected _parallaxScaleBias: number;
  50271. /**
  50272. * If sets to true, disables all the lights affecting the material.
  50273. */
  50274. protected _disableLighting: boolean;
  50275. /**
  50276. * Number of Simultaneous lights allowed on the material.
  50277. */
  50278. protected _maxSimultaneousLights: number;
  50279. /**
  50280. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50281. */
  50282. protected _invertNormalMapX: boolean;
  50283. /**
  50284. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50285. */
  50286. protected _invertNormalMapY: boolean;
  50287. /**
  50288. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50289. */
  50290. protected _twoSidedLighting: boolean;
  50291. /**
  50292. * Defines the alpha limits in alpha test mode.
  50293. */
  50294. protected _alphaCutOff: number;
  50295. /**
  50296. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50297. */
  50298. protected _forceAlphaTest: boolean;
  50299. /**
  50300. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50301. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50302. */
  50303. protected _useAlphaFresnel: boolean;
  50304. /**
  50305. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50306. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50307. */
  50308. protected _useLinearAlphaFresnel: boolean;
  50309. /**
  50310. * The transparency mode of the material.
  50311. */
  50312. protected _transparencyMode: Nullable<number>;
  50313. /**
  50314. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50315. * from cos thetav and roughness:
  50316. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50317. */
  50318. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50319. /**
  50320. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50321. */
  50322. protected _forceIrradianceInFragment: boolean;
  50323. /**
  50324. * Force normal to face away from face.
  50325. */
  50326. protected _forceNormalForward: boolean;
  50327. /**
  50328. * Enables specular anti aliasing in the PBR shader.
  50329. * It will both interacts on the Geometry for analytical and IBL lighting.
  50330. * It also prefilter the roughness map based on the bump values.
  50331. */
  50332. protected _enableSpecularAntiAliasing: boolean;
  50333. /**
  50334. * Default configuration related to image processing available in the PBR Material.
  50335. */
  50336. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50337. /**
  50338. * Keep track of the image processing observer to allow dispose and replace.
  50339. */
  50340. private _imageProcessingObserver;
  50341. /**
  50342. * Attaches a new image processing configuration to the PBR Material.
  50343. * @param configuration
  50344. */
  50345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50346. /**
  50347. * Stores the available render targets.
  50348. */
  50349. private _renderTargets;
  50350. /**
  50351. * Sets the global ambient color for the material used in lighting calculations.
  50352. */
  50353. private _globalAmbientColor;
  50354. /**
  50355. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50356. */
  50357. private _useLogarithmicDepth;
  50358. /**
  50359. * If set to true, no lighting calculations will be applied.
  50360. */
  50361. private _unlit;
  50362. private _debugMode;
  50363. /**
  50364. * @hidden
  50365. * This is reserved for the inspector.
  50366. * Defines the material debug mode.
  50367. * It helps seeing only some components of the material while troubleshooting.
  50368. */
  50369. debugMode: number;
  50370. /**
  50371. * @hidden
  50372. * This is reserved for the inspector.
  50373. * Specify from where on screen the debug mode should start.
  50374. * The value goes from -1 (full screen) to 1 (not visible)
  50375. * It helps with side by side comparison against the final render
  50376. * This defaults to -1
  50377. */
  50378. private debugLimit;
  50379. /**
  50380. * @hidden
  50381. * This is reserved for the inspector.
  50382. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50383. * You can use the factor to better multiply the final value.
  50384. */
  50385. private debugFactor;
  50386. /**
  50387. * Defines the clear coat layer parameters for the material.
  50388. */
  50389. readonly clearCoat: PBRClearCoatConfiguration;
  50390. /**
  50391. * Defines the anisotropic parameters for the material.
  50392. */
  50393. readonly anisotropy: PBRAnisotropicConfiguration;
  50394. /**
  50395. * Defines the BRDF parameters for the material.
  50396. */
  50397. readonly brdf: PBRBRDFConfiguration;
  50398. /**
  50399. * Defines the Sheen parameters for the material.
  50400. */
  50401. readonly sheen: PBRSheenConfiguration;
  50402. /**
  50403. * Defines the SubSurface parameters for the material.
  50404. */
  50405. readonly subSurface: PBRSubSurfaceConfiguration;
  50406. /**
  50407. * Custom callback helping to override the default shader used in the material.
  50408. */
  50409. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50410. protected _rebuildInParallel: boolean;
  50411. /**
  50412. * Instantiates a new PBRMaterial instance.
  50413. *
  50414. * @param name The material name
  50415. * @param scene The scene the material will be use in.
  50416. */
  50417. constructor(name: string, scene: Scene);
  50418. /**
  50419. * Gets a boolean indicating that current material needs to register RTT
  50420. */
  50421. readonly hasRenderTargetTextures: boolean;
  50422. /**
  50423. * Gets the name of the material class.
  50424. */
  50425. getClassName(): string;
  50426. /**
  50427. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50428. */
  50429. /**
  50430. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50431. */
  50432. useLogarithmicDepth: boolean;
  50433. /**
  50434. * Gets the current transparency mode.
  50435. */
  50436. /**
  50437. * Sets the transparency mode of the material.
  50438. *
  50439. * | Value | Type | Description |
  50440. * | ----- | ----------------------------------- | ----------- |
  50441. * | 0 | OPAQUE | |
  50442. * | 1 | ALPHATEST | |
  50443. * | 2 | ALPHABLEND | |
  50444. * | 3 | ALPHATESTANDBLEND | |
  50445. *
  50446. */
  50447. transparencyMode: Nullable<number>;
  50448. /**
  50449. * Returns true if alpha blending should be disabled.
  50450. */
  50451. private readonly _disableAlphaBlending;
  50452. /**
  50453. * Specifies whether or not this material should be rendered in alpha blend mode.
  50454. */
  50455. needAlphaBlending(): boolean;
  50456. /**
  50457. * Specifies if the mesh will require alpha blending.
  50458. * @param mesh - BJS mesh.
  50459. */
  50460. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50461. /**
  50462. * Specifies whether or not this material should be rendered in alpha test mode.
  50463. */
  50464. needAlphaTesting(): boolean;
  50465. /**
  50466. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50467. */
  50468. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50469. /**
  50470. * Gets the texture used for the alpha test.
  50471. */
  50472. getAlphaTestTexture(): Nullable<BaseTexture>;
  50473. /**
  50474. * Specifies that the submesh is ready to be used.
  50475. * @param mesh - BJS mesh.
  50476. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50477. * @param useInstances - Specifies that instances should be used.
  50478. * @returns - boolean indicating that the submesh is ready or not.
  50479. */
  50480. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50481. /**
  50482. * Specifies if the material uses metallic roughness workflow.
  50483. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50484. */
  50485. isMetallicWorkflow(): boolean;
  50486. private _prepareEffect;
  50487. private _prepareDefines;
  50488. /**
  50489. * Force shader compilation
  50490. */
  50491. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50492. /**
  50493. * Initializes the uniform buffer layout for the shader.
  50494. */
  50495. buildUniformLayout(): void;
  50496. /**
  50497. * Unbinds the material from the mesh
  50498. */
  50499. unbind(): void;
  50500. /**
  50501. * Binds the submesh data.
  50502. * @param world - The world matrix.
  50503. * @param mesh - The BJS mesh.
  50504. * @param subMesh - A submesh of the BJS mesh.
  50505. */
  50506. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50507. /**
  50508. * Returns the animatable textures.
  50509. * @returns - Array of animatable textures.
  50510. */
  50511. getAnimatables(): IAnimatable[];
  50512. /**
  50513. * Returns the texture used for reflections.
  50514. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50515. */
  50516. private _getReflectionTexture;
  50517. /**
  50518. * Returns an array of the actively used textures.
  50519. * @returns - Array of BaseTextures
  50520. */
  50521. getActiveTextures(): BaseTexture[];
  50522. /**
  50523. * Checks to see if a texture is used in the material.
  50524. * @param texture - Base texture to use.
  50525. * @returns - Boolean specifying if a texture is used in the material.
  50526. */
  50527. hasTexture(texture: BaseTexture): boolean;
  50528. /**
  50529. * Disposes the resources of the material.
  50530. * @param forceDisposeEffect - Forces the disposal of effects.
  50531. * @param forceDisposeTextures - Forces the disposal of all textures.
  50532. */
  50533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50534. }
  50535. }
  50536. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50537. import { Nullable } from "babylonjs/types";
  50538. import { Scene } from "babylonjs/scene";
  50539. import { Color3 } from "babylonjs/Maths/math.color";
  50540. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50541. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50543. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50544. /**
  50545. * The Physically based material of BJS.
  50546. *
  50547. * This offers the main features of a standard PBR material.
  50548. * For more information, please refer to the documentation :
  50549. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50550. */
  50551. export class PBRMaterial extends PBRBaseMaterial {
  50552. /**
  50553. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50554. */
  50555. static readonly PBRMATERIAL_OPAQUE: number;
  50556. /**
  50557. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50558. */
  50559. static readonly PBRMATERIAL_ALPHATEST: number;
  50560. /**
  50561. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50562. */
  50563. static readonly PBRMATERIAL_ALPHABLEND: number;
  50564. /**
  50565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50566. * They are also discarded below the alpha cutoff threshold to improve performances.
  50567. */
  50568. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50569. /**
  50570. * Defines the default value of how much AO map is occluding the analytical lights
  50571. * (point spot...).
  50572. */
  50573. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50574. /**
  50575. * Intensity of the direct lights e.g. the four lights available in your scene.
  50576. * This impacts both the direct diffuse and specular highlights.
  50577. */
  50578. directIntensity: number;
  50579. /**
  50580. * Intensity of the emissive part of the material.
  50581. * This helps controlling the emissive effect without modifying the emissive color.
  50582. */
  50583. emissiveIntensity: number;
  50584. /**
  50585. * Intensity of the environment e.g. how much the environment will light the object
  50586. * either through harmonics for rough material or through the refelction for shiny ones.
  50587. */
  50588. environmentIntensity: number;
  50589. /**
  50590. * This is a special control allowing the reduction of the specular highlights coming from the
  50591. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50592. */
  50593. specularIntensity: number;
  50594. /**
  50595. * Debug Control allowing disabling the bump map on this material.
  50596. */
  50597. disableBumpMap: boolean;
  50598. /**
  50599. * AKA Diffuse Texture in standard nomenclature.
  50600. */
  50601. albedoTexture: BaseTexture;
  50602. /**
  50603. * AKA Occlusion Texture in other nomenclature.
  50604. */
  50605. ambientTexture: BaseTexture;
  50606. /**
  50607. * AKA Occlusion Texture Intensity in other nomenclature.
  50608. */
  50609. ambientTextureStrength: number;
  50610. /**
  50611. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50612. * 1 means it completely occludes it
  50613. * 0 mean it has no impact
  50614. */
  50615. ambientTextureImpactOnAnalyticalLights: number;
  50616. /**
  50617. * Stores the alpha values in a texture.
  50618. */
  50619. opacityTexture: BaseTexture;
  50620. /**
  50621. * Stores the reflection values in a texture.
  50622. */
  50623. reflectionTexture: Nullable<BaseTexture>;
  50624. /**
  50625. * Stores the emissive values in a texture.
  50626. */
  50627. emissiveTexture: BaseTexture;
  50628. /**
  50629. * AKA Specular texture in other nomenclature.
  50630. */
  50631. reflectivityTexture: BaseTexture;
  50632. /**
  50633. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50634. */
  50635. metallicTexture: BaseTexture;
  50636. /**
  50637. * Specifies the metallic scalar of the metallic/roughness workflow.
  50638. * Can also be used to scale the metalness values of the metallic texture.
  50639. */
  50640. metallic: Nullable<number>;
  50641. /**
  50642. * Specifies the roughness scalar of the metallic/roughness workflow.
  50643. * Can also be used to scale the roughness values of the metallic texture.
  50644. */
  50645. roughness: Nullable<number>;
  50646. /**
  50647. * Specifies the an F0 factor to help configuring the material F0.
  50648. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50649. * to 0.5 the previously hard coded value stays the same.
  50650. * Can also be used to scale the F0 values of the metallic texture.
  50651. */
  50652. metallicF0Factor: number;
  50653. /**
  50654. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50655. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50656. * your expectation as it multiplies with the texture data.
  50657. */
  50658. useMetallicF0FactorFromMetallicTexture: boolean;
  50659. /**
  50660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50662. */
  50663. microSurfaceTexture: BaseTexture;
  50664. /**
  50665. * Stores surface normal data used to displace a mesh in a texture.
  50666. */
  50667. bumpTexture: BaseTexture;
  50668. /**
  50669. * Stores the pre-calculated light information of a mesh in a texture.
  50670. */
  50671. lightmapTexture: BaseTexture;
  50672. /**
  50673. * Stores the refracted light information in a texture.
  50674. */
  50675. refractionTexture: Nullable<BaseTexture>;
  50676. /**
  50677. * The color of a material in ambient lighting.
  50678. */
  50679. ambientColor: Color3;
  50680. /**
  50681. * AKA Diffuse Color in other nomenclature.
  50682. */
  50683. albedoColor: Color3;
  50684. /**
  50685. * AKA Specular Color in other nomenclature.
  50686. */
  50687. reflectivityColor: Color3;
  50688. /**
  50689. * The color reflected from the material.
  50690. */
  50691. reflectionColor: Color3;
  50692. /**
  50693. * The color emitted from the material.
  50694. */
  50695. emissiveColor: Color3;
  50696. /**
  50697. * AKA Glossiness in other nomenclature.
  50698. */
  50699. microSurface: number;
  50700. /**
  50701. * source material index of refraction (IOR)' / 'destination material IOR.
  50702. */
  50703. indexOfRefraction: number;
  50704. /**
  50705. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50706. */
  50707. invertRefractionY: boolean;
  50708. /**
  50709. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50710. * Materials half opaque for instance using refraction could benefit from this control.
  50711. */
  50712. linkRefractionWithTransparency: boolean;
  50713. /**
  50714. * If true, the light map contains occlusion information instead of lighting info.
  50715. */
  50716. useLightmapAsShadowmap: boolean;
  50717. /**
  50718. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50719. */
  50720. useAlphaFromAlbedoTexture: boolean;
  50721. /**
  50722. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50723. */
  50724. forceAlphaTest: boolean;
  50725. /**
  50726. * Defines the alpha limits in alpha test mode.
  50727. */
  50728. alphaCutOff: number;
  50729. /**
  50730. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50731. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50732. */
  50733. useSpecularOverAlpha: boolean;
  50734. /**
  50735. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50736. */
  50737. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50738. /**
  50739. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50740. */
  50741. useRoughnessFromMetallicTextureAlpha: boolean;
  50742. /**
  50743. * Specifies if the metallic texture contains the roughness information in its green channel.
  50744. */
  50745. useRoughnessFromMetallicTextureGreen: boolean;
  50746. /**
  50747. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50748. */
  50749. useMetallnessFromMetallicTextureBlue: boolean;
  50750. /**
  50751. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50752. */
  50753. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50754. /**
  50755. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50756. */
  50757. useAmbientInGrayScale: boolean;
  50758. /**
  50759. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50760. * The material will try to infer what glossiness each pixel should be.
  50761. */
  50762. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50763. /**
  50764. * BJS is using an harcoded light falloff based on a manually sets up range.
  50765. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50766. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50767. */
  50768. /**
  50769. * BJS is using an harcoded light falloff based on a manually sets up range.
  50770. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50771. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50772. */
  50773. usePhysicalLightFalloff: boolean;
  50774. /**
  50775. * In order to support the falloff compatibility with gltf, a special mode has been added
  50776. * to reproduce the gltf light falloff.
  50777. */
  50778. /**
  50779. * In order to support the falloff compatibility with gltf, a special mode has been added
  50780. * to reproduce the gltf light falloff.
  50781. */
  50782. useGLTFLightFalloff: boolean;
  50783. /**
  50784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50786. */
  50787. useRadianceOverAlpha: boolean;
  50788. /**
  50789. * Allows using an object space normal map (instead of tangent space).
  50790. */
  50791. useObjectSpaceNormalMap: boolean;
  50792. /**
  50793. * Allows using the bump map in parallax mode.
  50794. */
  50795. useParallax: boolean;
  50796. /**
  50797. * Allows using the bump map in parallax occlusion mode.
  50798. */
  50799. useParallaxOcclusion: boolean;
  50800. /**
  50801. * Controls the scale bias of the parallax mode.
  50802. */
  50803. parallaxScaleBias: number;
  50804. /**
  50805. * If sets to true, disables all the lights affecting the material.
  50806. */
  50807. disableLighting: boolean;
  50808. /**
  50809. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50810. */
  50811. forceIrradianceInFragment: boolean;
  50812. /**
  50813. * Number of Simultaneous lights allowed on the material.
  50814. */
  50815. maxSimultaneousLights: number;
  50816. /**
  50817. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50818. */
  50819. invertNormalMapX: boolean;
  50820. /**
  50821. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50822. */
  50823. invertNormalMapY: boolean;
  50824. /**
  50825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50826. */
  50827. twoSidedLighting: boolean;
  50828. /**
  50829. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50830. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50831. */
  50832. useAlphaFresnel: boolean;
  50833. /**
  50834. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50835. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50836. */
  50837. useLinearAlphaFresnel: boolean;
  50838. /**
  50839. * Let user defines the brdf lookup texture used for IBL.
  50840. * A default 8bit version is embedded but you could point at :
  50841. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50842. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50843. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50844. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50845. */
  50846. environmentBRDFTexture: Nullable<BaseTexture>;
  50847. /**
  50848. * Force normal to face away from face.
  50849. */
  50850. forceNormalForward: boolean;
  50851. /**
  50852. * Enables specular anti aliasing in the PBR shader.
  50853. * It will both interacts on the Geometry for analytical and IBL lighting.
  50854. * It also prefilter the roughness map based on the bump values.
  50855. */
  50856. enableSpecularAntiAliasing: boolean;
  50857. /**
  50858. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50859. * makes the reflect vector face the model (under horizon).
  50860. */
  50861. useHorizonOcclusion: boolean;
  50862. /**
  50863. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50864. * too much the area relying on ambient texture to define their ambient occlusion.
  50865. */
  50866. useRadianceOcclusion: boolean;
  50867. /**
  50868. * If set to true, no lighting calculations will be applied.
  50869. */
  50870. unlit: boolean;
  50871. /**
  50872. * Gets the image processing configuration used either in this material.
  50873. */
  50874. /**
  50875. * Sets the Default image processing configuration used either in the this material.
  50876. *
  50877. * If sets to null, the scene one is in use.
  50878. */
  50879. imageProcessingConfiguration: ImageProcessingConfiguration;
  50880. /**
  50881. * Gets wether the color curves effect is enabled.
  50882. */
  50883. /**
  50884. * Sets wether the color curves effect is enabled.
  50885. */
  50886. cameraColorCurvesEnabled: boolean;
  50887. /**
  50888. * Gets wether the color grading effect is enabled.
  50889. */
  50890. /**
  50891. * Gets wether the color grading effect is enabled.
  50892. */
  50893. cameraColorGradingEnabled: boolean;
  50894. /**
  50895. * Gets wether tonemapping is enabled or not.
  50896. */
  50897. /**
  50898. * Sets wether tonemapping is enabled or not
  50899. */
  50900. cameraToneMappingEnabled: boolean;
  50901. /**
  50902. * The camera exposure used on this material.
  50903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50904. * This corresponds to a photographic exposure.
  50905. */
  50906. /**
  50907. * The camera exposure used on this material.
  50908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50909. * This corresponds to a photographic exposure.
  50910. */
  50911. cameraExposure: number;
  50912. /**
  50913. * Gets The camera contrast used on this material.
  50914. */
  50915. /**
  50916. * Sets The camera contrast used on this material.
  50917. */
  50918. cameraContrast: number;
  50919. /**
  50920. * Gets the Color Grading 2D Lookup Texture.
  50921. */
  50922. /**
  50923. * Sets the Color Grading 2D Lookup Texture.
  50924. */
  50925. cameraColorGradingTexture: Nullable<BaseTexture>;
  50926. /**
  50927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50929. * 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;
  50930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50931. */
  50932. /**
  50933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50935. * 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;
  50936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50937. */
  50938. cameraColorCurves: Nullable<ColorCurves>;
  50939. /**
  50940. * Instantiates a new PBRMaterial instance.
  50941. *
  50942. * @param name The material name
  50943. * @param scene The scene the material will be use in.
  50944. */
  50945. constructor(name: string, scene: Scene);
  50946. /**
  50947. * Returns the name of this material class.
  50948. */
  50949. getClassName(): string;
  50950. /**
  50951. * Makes a duplicate of the current material.
  50952. * @param name - name to use for the new material.
  50953. */
  50954. clone(name: string): PBRMaterial;
  50955. /**
  50956. * Serializes this PBR Material.
  50957. * @returns - An object with the serialized material.
  50958. */
  50959. serialize(): any;
  50960. /**
  50961. * Parses a PBR Material from a serialized object.
  50962. * @param source - Serialized object.
  50963. * @param scene - BJS scene instance.
  50964. * @param rootUrl - url for the scene object
  50965. * @returns - PBRMaterial
  50966. */
  50967. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50968. }
  50969. }
  50970. declare module "babylonjs/Misc/dds" {
  50971. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50973. import { Nullable } from "babylonjs/types";
  50974. import { Scene } from "babylonjs/scene";
  50975. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50976. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50977. /**
  50978. * Direct draw surface info
  50979. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50980. */
  50981. export interface DDSInfo {
  50982. /**
  50983. * Width of the texture
  50984. */
  50985. width: number;
  50986. /**
  50987. * Width of the texture
  50988. */
  50989. height: number;
  50990. /**
  50991. * Number of Mipmaps for the texture
  50992. * @see https://en.wikipedia.org/wiki/Mipmap
  50993. */
  50994. mipmapCount: number;
  50995. /**
  50996. * If the textures format is a known fourCC format
  50997. * @see https://www.fourcc.org/
  50998. */
  50999. isFourCC: boolean;
  51000. /**
  51001. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51002. */
  51003. isRGB: boolean;
  51004. /**
  51005. * If the texture is a lumincance format
  51006. */
  51007. isLuminance: boolean;
  51008. /**
  51009. * If this is a cube texture
  51010. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51011. */
  51012. isCube: boolean;
  51013. /**
  51014. * If the texture is a compressed format eg. FOURCC_DXT1
  51015. */
  51016. isCompressed: boolean;
  51017. /**
  51018. * The dxgiFormat of the texture
  51019. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51020. */
  51021. dxgiFormat: number;
  51022. /**
  51023. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51024. */
  51025. textureType: number;
  51026. /**
  51027. * Sphericle polynomial created for the dds texture
  51028. */
  51029. sphericalPolynomial?: SphericalPolynomial;
  51030. }
  51031. /**
  51032. * Class used to provide DDS decompression tools
  51033. */
  51034. export class DDSTools {
  51035. /**
  51036. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51037. */
  51038. static StoreLODInAlphaChannel: boolean;
  51039. /**
  51040. * Gets DDS information from an array buffer
  51041. * @param arrayBuffer defines the array buffer to read data from
  51042. * @returns the DDS information
  51043. */
  51044. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51045. private static _FloatView;
  51046. private static _Int32View;
  51047. private static _ToHalfFloat;
  51048. private static _FromHalfFloat;
  51049. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51050. private static _GetHalfFloatRGBAArrayBuffer;
  51051. private static _GetFloatRGBAArrayBuffer;
  51052. private static _GetFloatAsUIntRGBAArrayBuffer;
  51053. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51054. private static _GetRGBAArrayBuffer;
  51055. private static _ExtractLongWordOrder;
  51056. private static _GetRGBArrayBuffer;
  51057. private static _GetLuminanceArrayBuffer;
  51058. /**
  51059. * Uploads DDS Levels to a Babylon Texture
  51060. * @hidden
  51061. */
  51062. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51063. }
  51064. module "babylonjs/Engines/thinEngine" {
  51065. interface ThinEngine {
  51066. /**
  51067. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51068. * @param rootUrl defines the url where the file to load is located
  51069. * @param scene defines the current scene
  51070. * @param lodScale defines scale to apply to the mip map selection
  51071. * @param lodOffset defines offset to apply to the mip map selection
  51072. * @param onLoad defines an optional callback raised when the texture is loaded
  51073. * @param onError defines an optional callback raised if there is an issue to load the texture
  51074. * @param format defines the format of the data
  51075. * @param forcedExtension defines the extension to use to pick the right loader
  51076. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51077. * @returns the cube texture as an InternalTexture
  51078. */
  51079. 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;
  51080. }
  51081. }
  51082. }
  51083. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51084. import { Nullable } from "babylonjs/types";
  51085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51086. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51087. /**
  51088. * Implementation of the DDS Texture Loader.
  51089. * @hidden
  51090. */
  51091. export class _DDSTextureLoader implements IInternalTextureLoader {
  51092. /**
  51093. * Defines wether the loader supports cascade loading the different faces.
  51094. */
  51095. readonly supportCascades: boolean;
  51096. /**
  51097. * This returns if the loader support the current file information.
  51098. * @param extension defines the file extension of the file being loaded
  51099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51100. * @param fallback defines the fallback internal texture if any
  51101. * @param isBase64 defines whether the texture is encoded as a base64
  51102. * @param isBuffer defines whether the texture data are stored as a buffer
  51103. * @returns true if the loader can load the specified file
  51104. */
  51105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51106. /**
  51107. * Transform the url before loading if required.
  51108. * @param rootUrl the url of the texture
  51109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51110. * @returns the transformed texture
  51111. */
  51112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51113. /**
  51114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51115. * @param rootUrl the url of the texture
  51116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51117. * @returns the fallback texture
  51118. */
  51119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51120. /**
  51121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51122. * @param data contains the texture data
  51123. * @param texture defines the BabylonJS internal texture
  51124. * @param createPolynomials will be true if polynomials have been requested
  51125. * @param onLoad defines the callback to trigger once the texture is ready
  51126. * @param onError defines the callback to trigger in case of error
  51127. */
  51128. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51129. /**
  51130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51131. * @param data contains the texture data
  51132. * @param texture defines the BabylonJS internal texture
  51133. * @param callback defines the method to call once ready to upload
  51134. */
  51135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51136. }
  51137. }
  51138. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51139. import { Nullable } from "babylonjs/types";
  51140. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51141. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51142. /**
  51143. * Implementation of the ENV Texture Loader.
  51144. * @hidden
  51145. */
  51146. export class _ENVTextureLoader implements IInternalTextureLoader {
  51147. /**
  51148. * Defines wether the loader supports cascade loading the different faces.
  51149. */
  51150. readonly supportCascades: boolean;
  51151. /**
  51152. * This returns if the loader support the current file information.
  51153. * @param extension defines the file extension of the file being loaded
  51154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51155. * @param fallback defines the fallback internal texture if any
  51156. * @param isBase64 defines whether the texture is encoded as a base64
  51157. * @param isBuffer defines whether the texture data are stored as a buffer
  51158. * @returns true if the loader can load the specified file
  51159. */
  51160. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51161. /**
  51162. * Transform the url before loading if required.
  51163. * @param rootUrl the url of the texture
  51164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51165. * @returns the transformed texture
  51166. */
  51167. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51168. /**
  51169. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51170. * @param rootUrl the url of the texture
  51171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51172. * @returns the fallback texture
  51173. */
  51174. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51175. /**
  51176. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51177. * @param data contains the texture data
  51178. * @param texture defines the BabylonJS internal texture
  51179. * @param createPolynomials will be true if polynomials have been requested
  51180. * @param onLoad defines the callback to trigger once the texture is ready
  51181. * @param onError defines the callback to trigger in case of error
  51182. */
  51183. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51184. /**
  51185. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51186. * @param data contains the texture data
  51187. * @param texture defines the BabylonJS internal texture
  51188. * @param callback defines the method to call once ready to upload
  51189. */
  51190. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51191. }
  51192. }
  51193. declare module "babylonjs/Misc/khronosTextureContainer" {
  51194. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51195. /**
  51196. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51197. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51198. */
  51199. export class KhronosTextureContainer {
  51200. /** contents of the KTX container file */
  51201. arrayBuffer: any;
  51202. private static HEADER_LEN;
  51203. private static COMPRESSED_2D;
  51204. private static COMPRESSED_3D;
  51205. private static TEX_2D;
  51206. private static TEX_3D;
  51207. /**
  51208. * Gets the openGL type
  51209. */
  51210. glType: number;
  51211. /**
  51212. * Gets the openGL type size
  51213. */
  51214. glTypeSize: number;
  51215. /**
  51216. * Gets the openGL format
  51217. */
  51218. glFormat: number;
  51219. /**
  51220. * Gets the openGL internal format
  51221. */
  51222. glInternalFormat: number;
  51223. /**
  51224. * Gets the base internal format
  51225. */
  51226. glBaseInternalFormat: number;
  51227. /**
  51228. * Gets image width in pixel
  51229. */
  51230. pixelWidth: number;
  51231. /**
  51232. * Gets image height in pixel
  51233. */
  51234. pixelHeight: number;
  51235. /**
  51236. * Gets image depth in pixels
  51237. */
  51238. pixelDepth: number;
  51239. /**
  51240. * Gets the number of array elements
  51241. */
  51242. numberOfArrayElements: number;
  51243. /**
  51244. * Gets the number of faces
  51245. */
  51246. numberOfFaces: number;
  51247. /**
  51248. * Gets the number of mipmap levels
  51249. */
  51250. numberOfMipmapLevels: number;
  51251. /**
  51252. * Gets the bytes of key value data
  51253. */
  51254. bytesOfKeyValueData: number;
  51255. /**
  51256. * Gets the load type
  51257. */
  51258. loadType: number;
  51259. /**
  51260. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51261. */
  51262. isInvalid: boolean;
  51263. /**
  51264. * Creates a new KhronosTextureContainer
  51265. * @param arrayBuffer contents of the KTX container file
  51266. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51267. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51268. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51269. */
  51270. constructor(
  51271. /** contents of the KTX container file */
  51272. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51273. /**
  51274. * Uploads KTX content to a Babylon Texture.
  51275. * It is assumed that the texture has already been created & is currently bound
  51276. * @hidden
  51277. */
  51278. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51279. private _upload2DCompressedLevels;
  51280. }
  51281. }
  51282. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51283. import { Nullable } from "babylonjs/types";
  51284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51285. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51286. /**
  51287. * Implementation of the KTX Texture Loader.
  51288. * @hidden
  51289. */
  51290. export class _KTXTextureLoader implements IInternalTextureLoader {
  51291. /**
  51292. * Defines wether the loader supports cascade loading the different faces.
  51293. */
  51294. readonly supportCascades: boolean;
  51295. /**
  51296. * This returns if the loader support the current file information.
  51297. * @param extension defines the file extension of the file being loaded
  51298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51299. * @param fallback defines the fallback internal texture if any
  51300. * @param isBase64 defines whether the texture is encoded as a base64
  51301. * @param isBuffer defines whether the texture data are stored as a buffer
  51302. * @returns true if the loader can load the specified file
  51303. */
  51304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51305. /**
  51306. * Transform the url before loading if required.
  51307. * @param rootUrl the url of the texture
  51308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51309. * @returns the transformed texture
  51310. */
  51311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51312. /**
  51313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51314. * @param rootUrl the url of the texture
  51315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51316. * @returns the fallback texture
  51317. */
  51318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51319. /**
  51320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51321. * @param data contains the texture data
  51322. * @param texture defines the BabylonJS internal texture
  51323. * @param createPolynomials will be true if polynomials have been requested
  51324. * @param onLoad defines the callback to trigger once the texture is ready
  51325. * @param onError defines the callback to trigger in case of error
  51326. */
  51327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51328. /**
  51329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51330. * @param data contains the texture data
  51331. * @param texture defines the BabylonJS internal texture
  51332. * @param callback defines the method to call once ready to upload
  51333. */
  51334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51335. }
  51336. }
  51337. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51338. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51339. import { Scene } from "babylonjs/scene";
  51340. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51341. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51342. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51343. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51344. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51345. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51347. /**
  51348. * Options for the default xr helper
  51349. */
  51350. export class WebXRDefaultExperienceOptions {
  51351. /**
  51352. * Floor meshes that should be used for teleporting
  51353. */
  51354. floorMeshes: Array<AbstractMesh>;
  51355. /**
  51356. * Enable or disable default UI to enter XR
  51357. */
  51358. disableDefaultUI: boolean;
  51359. }
  51360. /**
  51361. * Default experience which provides a similar setup to the previous webVRExperience
  51362. */
  51363. export class WebXRDefaultExperience {
  51364. /**
  51365. * Base experience
  51366. */
  51367. baseExperience: WebXRExperienceHelper;
  51368. /**
  51369. * Input experience extension
  51370. */
  51371. input: WebXRInput;
  51372. /**
  51373. * Loads the controller models
  51374. */
  51375. controllerModelLoader: WebXRControllerModelLoader;
  51376. /**
  51377. * Enables laser pointer and selection
  51378. */
  51379. pointerSelection: WebXRControllerPointerSelection;
  51380. /**
  51381. * Enables teleportation
  51382. */
  51383. teleportation: WebXRControllerTeleportation;
  51384. /**
  51385. * Enables ui for enetering/exiting xr
  51386. */
  51387. enterExitUI: WebXREnterExitUI;
  51388. /**
  51389. * Default target xr should render to
  51390. */
  51391. renderTarget: WebXRRenderTarget;
  51392. /**
  51393. * Creates the default xr experience
  51394. * @param scene scene
  51395. * @param options options for basic configuration
  51396. * @returns resulting WebXRDefaultExperience
  51397. */
  51398. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51399. private constructor();
  51400. /**
  51401. * DIsposes of the experience helper
  51402. */
  51403. dispose(): void;
  51404. }
  51405. }
  51406. declare module "babylonjs/Helpers/sceneHelpers" {
  51407. import { Nullable } from "babylonjs/types";
  51408. import { Mesh } from "babylonjs/Meshes/mesh";
  51409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51410. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51411. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51412. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51413. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51414. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51415. import "babylonjs/Meshes/Builders/boxBuilder";
  51416. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51417. /** @hidden */
  51418. export var _forceSceneHelpersToBundle: boolean;
  51419. module "babylonjs/scene" {
  51420. interface Scene {
  51421. /**
  51422. * Creates a default light for the scene.
  51423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51424. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51425. */
  51426. createDefaultLight(replace?: boolean): void;
  51427. /**
  51428. * Creates a default camera for the scene.
  51429. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51431. * @param replace has default false, when true replaces the active camera in the scene
  51432. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51433. */
  51434. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51435. /**
  51436. * Creates a default camera and a default light.
  51437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51438. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51439. * @param replace has the default false, when true replaces the active camera/light in the scene
  51440. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51441. */
  51442. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51443. /**
  51444. * Creates a new sky box
  51445. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51446. * @param environmentTexture defines the texture to use as environment texture
  51447. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51448. * @param scale defines the overall scale of the skybox
  51449. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51450. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51451. * @returns a new mesh holding the sky box
  51452. */
  51453. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51454. /**
  51455. * Creates a new environment
  51456. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51457. * @param options defines the options you can use to configure the environment
  51458. * @returns the new EnvironmentHelper
  51459. */
  51460. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51461. /**
  51462. * Creates a new VREXperienceHelper
  51463. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51464. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51465. * @returns a new VREXperienceHelper
  51466. */
  51467. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51468. /**
  51469. * Creates a new WebXRDefaultExperience
  51470. * @see http://doc.babylonjs.com/how_to/webxr
  51471. * @param options experience options
  51472. * @returns a promise for a new WebXRDefaultExperience
  51473. */
  51474. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51475. }
  51476. }
  51477. }
  51478. declare module "babylonjs/Helpers/videoDome" {
  51479. import { Scene } from "babylonjs/scene";
  51480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51481. import { Mesh } from "babylonjs/Meshes/mesh";
  51482. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51483. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51484. import "babylonjs/Meshes/Builders/sphereBuilder";
  51485. /**
  51486. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51487. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51488. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51489. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51490. */
  51491. export class VideoDome extends TransformNode {
  51492. /**
  51493. * Define the video source as a Monoscopic panoramic 360 video.
  51494. */
  51495. static readonly MODE_MONOSCOPIC: number;
  51496. /**
  51497. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51498. */
  51499. static readonly MODE_TOPBOTTOM: number;
  51500. /**
  51501. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51502. */
  51503. static readonly MODE_SIDEBYSIDE: number;
  51504. private _halfDome;
  51505. private _useDirectMapping;
  51506. /**
  51507. * The video texture being displayed on the sphere
  51508. */
  51509. protected _videoTexture: VideoTexture;
  51510. /**
  51511. * Gets the video texture being displayed on the sphere
  51512. */
  51513. readonly videoTexture: VideoTexture;
  51514. /**
  51515. * The skybox material
  51516. */
  51517. protected _material: BackgroundMaterial;
  51518. /**
  51519. * The surface used for the skybox
  51520. */
  51521. protected _mesh: Mesh;
  51522. /**
  51523. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51524. */
  51525. private _halfDomeMask;
  51526. /**
  51527. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51528. * Also see the options.resolution property.
  51529. */
  51530. fovMultiplier: number;
  51531. private _videoMode;
  51532. /**
  51533. * Gets or set the current video mode for the video. It can be:
  51534. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51535. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51536. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51537. */
  51538. videoMode: number;
  51539. /**
  51540. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51541. *
  51542. */
  51543. /**
  51544. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51545. */
  51546. halfDome: boolean;
  51547. /**
  51548. * Oberserver used in Stereoscopic VR Mode.
  51549. */
  51550. private _onBeforeCameraRenderObserver;
  51551. /**
  51552. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51553. * @param name Element's name, child elements will append suffixes for their own names.
  51554. * @param urlsOrVideo defines the url(s) or the video element to use
  51555. * @param options An object containing optional or exposed sub element properties
  51556. */
  51557. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51558. resolution?: number;
  51559. clickToPlay?: boolean;
  51560. autoPlay?: boolean;
  51561. loop?: boolean;
  51562. size?: number;
  51563. poster?: string;
  51564. faceForward?: boolean;
  51565. useDirectMapping?: boolean;
  51566. halfDomeMode?: boolean;
  51567. }, scene: Scene);
  51568. private _changeVideoMode;
  51569. /**
  51570. * Releases resources associated with this node.
  51571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51573. */
  51574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51575. }
  51576. }
  51577. declare module "babylonjs/Helpers/index" {
  51578. export * from "babylonjs/Helpers/environmentHelper";
  51579. export * from "babylonjs/Helpers/photoDome";
  51580. export * from "babylonjs/Helpers/sceneHelpers";
  51581. export * from "babylonjs/Helpers/videoDome";
  51582. }
  51583. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51584. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51585. import { IDisposable } from "babylonjs/scene";
  51586. import { Engine } from "babylonjs/Engines/engine";
  51587. /**
  51588. * This class can be used to get instrumentation data from a Babylon engine
  51589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51590. */
  51591. export class EngineInstrumentation implements IDisposable {
  51592. /**
  51593. * Define the instrumented engine.
  51594. */
  51595. engine: Engine;
  51596. private _captureGPUFrameTime;
  51597. private _gpuFrameTimeToken;
  51598. private _gpuFrameTime;
  51599. private _captureShaderCompilationTime;
  51600. private _shaderCompilationTime;
  51601. private _onBeginFrameObserver;
  51602. private _onEndFrameObserver;
  51603. private _onBeforeShaderCompilationObserver;
  51604. private _onAfterShaderCompilationObserver;
  51605. /**
  51606. * Gets the perf counter used for GPU frame time
  51607. */
  51608. readonly gpuFrameTimeCounter: PerfCounter;
  51609. /**
  51610. * Gets the GPU frame time capture status
  51611. */
  51612. /**
  51613. * Enable or disable the GPU frame time capture
  51614. */
  51615. captureGPUFrameTime: boolean;
  51616. /**
  51617. * Gets the perf counter used for shader compilation time
  51618. */
  51619. readonly shaderCompilationTimeCounter: PerfCounter;
  51620. /**
  51621. * Gets the shader compilation time capture status
  51622. */
  51623. /**
  51624. * Enable or disable the shader compilation time capture
  51625. */
  51626. captureShaderCompilationTime: boolean;
  51627. /**
  51628. * Instantiates a new engine instrumentation.
  51629. * This class can be used to get instrumentation data from a Babylon engine
  51630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51631. * @param engine Defines the engine to instrument
  51632. */
  51633. constructor(
  51634. /**
  51635. * Define the instrumented engine.
  51636. */
  51637. engine: Engine);
  51638. /**
  51639. * Dispose and release associated resources.
  51640. */
  51641. dispose(): void;
  51642. }
  51643. }
  51644. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51645. import { Scene, IDisposable } from "babylonjs/scene";
  51646. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51647. /**
  51648. * This class can be used to get instrumentation data from a Babylon engine
  51649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51650. */
  51651. export class SceneInstrumentation implements IDisposable {
  51652. /**
  51653. * Defines the scene to instrument
  51654. */
  51655. scene: Scene;
  51656. private _captureActiveMeshesEvaluationTime;
  51657. private _activeMeshesEvaluationTime;
  51658. private _captureRenderTargetsRenderTime;
  51659. private _renderTargetsRenderTime;
  51660. private _captureFrameTime;
  51661. private _frameTime;
  51662. private _captureRenderTime;
  51663. private _renderTime;
  51664. private _captureInterFrameTime;
  51665. private _interFrameTime;
  51666. private _captureParticlesRenderTime;
  51667. private _particlesRenderTime;
  51668. private _captureSpritesRenderTime;
  51669. private _spritesRenderTime;
  51670. private _capturePhysicsTime;
  51671. private _physicsTime;
  51672. private _captureAnimationsTime;
  51673. private _animationsTime;
  51674. private _captureCameraRenderTime;
  51675. private _cameraRenderTime;
  51676. private _onBeforeActiveMeshesEvaluationObserver;
  51677. private _onAfterActiveMeshesEvaluationObserver;
  51678. private _onBeforeRenderTargetsRenderObserver;
  51679. private _onAfterRenderTargetsRenderObserver;
  51680. private _onAfterRenderObserver;
  51681. private _onBeforeDrawPhaseObserver;
  51682. private _onAfterDrawPhaseObserver;
  51683. private _onBeforeAnimationsObserver;
  51684. private _onBeforeParticlesRenderingObserver;
  51685. private _onAfterParticlesRenderingObserver;
  51686. private _onBeforeSpritesRenderingObserver;
  51687. private _onAfterSpritesRenderingObserver;
  51688. private _onBeforePhysicsObserver;
  51689. private _onAfterPhysicsObserver;
  51690. private _onAfterAnimationsObserver;
  51691. private _onBeforeCameraRenderObserver;
  51692. private _onAfterCameraRenderObserver;
  51693. /**
  51694. * Gets the perf counter used for active meshes evaluation time
  51695. */
  51696. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51697. /**
  51698. * Gets the active meshes evaluation time capture status
  51699. */
  51700. /**
  51701. * Enable or disable the active meshes evaluation time capture
  51702. */
  51703. captureActiveMeshesEvaluationTime: boolean;
  51704. /**
  51705. * Gets the perf counter used for render targets render time
  51706. */
  51707. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51708. /**
  51709. * Gets the render targets render time capture status
  51710. */
  51711. /**
  51712. * Enable or disable the render targets render time capture
  51713. */
  51714. captureRenderTargetsRenderTime: boolean;
  51715. /**
  51716. * Gets the perf counter used for particles render time
  51717. */
  51718. readonly particlesRenderTimeCounter: PerfCounter;
  51719. /**
  51720. * Gets the particles render time capture status
  51721. */
  51722. /**
  51723. * Enable or disable the particles render time capture
  51724. */
  51725. captureParticlesRenderTime: boolean;
  51726. /**
  51727. * Gets the perf counter used for sprites render time
  51728. */
  51729. readonly spritesRenderTimeCounter: PerfCounter;
  51730. /**
  51731. * Gets the sprites render time capture status
  51732. */
  51733. /**
  51734. * Enable or disable the sprites render time capture
  51735. */
  51736. captureSpritesRenderTime: boolean;
  51737. /**
  51738. * Gets the perf counter used for physics time
  51739. */
  51740. readonly physicsTimeCounter: PerfCounter;
  51741. /**
  51742. * Gets the physics time capture status
  51743. */
  51744. /**
  51745. * Enable or disable the physics time capture
  51746. */
  51747. capturePhysicsTime: boolean;
  51748. /**
  51749. * Gets the perf counter used for animations time
  51750. */
  51751. readonly animationsTimeCounter: PerfCounter;
  51752. /**
  51753. * Gets the animations time capture status
  51754. */
  51755. /**
  51756. * Enable or disable the animations time capture
  51757. */
  51758. captureAnimationsTime: boolean;
  51759. /**
  51760. * Gets the perf counter used for frame time capture
  51761. */
  51762. readonly frameTimeCounter: PerfCounter;
  51763. /**
  51764. * Gets the frame time capture status
  51765. */
  51766. /**
  51767. * Enable or disable the frame time capture
  51768. */
  51769. captureFrameTime: boolean;
  51770. /**
  51771. * Gets the perf counter used for inter-frames time capture
  51772. */
  51773. readonly interFrameTimeCounter: PerfCounter;
  51774. /**
  51775. * Gets the inter-frames time capture status
  51776. */
  51777. /**
  51778. * Enable or disable the inter-frames time capture
  51779. */
  51780. captureInterFrameTime: boolean;
  51781. /**
  51782. * Gets the perf counter used for render time capture
  51783. */
  51784. readonly renderTimeCounter: PerfCounter;
  51785. /**
  51786. * Gets the render time capture status
  51787. */
  51788. /**
  51789. * Enable or disable the render time capture
  51790. */
  51791. captureRenderTime: boolean;
  51792. /**
  51793. * Gets the perf counter used for camera render time capture
  51794. */
  51795. readonly cameraRenderTimeCounter: PerfCounter;
  51796. /**
  51797. * Gets the camera render time capture status
  51798. */
  51799. /**
  51800. * Enable or disable the camera render time capture
  51801. */
  51802. captureCameraRenderTime: boolean;
  51803. /**
  51804. * Gets the perf counter used for draw calls
  51805. */
  51806. readonly drawCallsCounter: PerfCounter;
  51807. /**
  51808. * Instantiates a new scene instrumentation.
  51809. * This class can be used to get instrumentation data from a Babylon engine
  51810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51811. * @param scene Defines the scene to instrument
  51812. */
  51813. constructor(
  51814. /**
  51815. * Defines the scene to instrument
  51816. */
  51817. scene: Scene);
  51818. /**
  51819. * Dispose and release associated resources.
  51820. */
  51821. dispose(): void;
  51822. }
  51823. }
  51824. declare module "babylonjs/Instrumentation/index" {
  51825. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51826. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51827. export * from "babylonjs/Instrumentation/timeToken";
  51828. }
  51829. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51830. /** @hidden */
  51831. export var glowMapGenerationPixelShader: {
  51832. name: string;
  51833. shader: string;
  51834. };
  51835. }
  51836. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51837. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51840. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51842. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51843. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51844. /** @hidden */
  51845. export var glowMapGenerationVertexShader: {
  51846. name: string;
  51847. shader: string;
  51848. };
  51849. }
  51850. declare module "babylonjs/Layers/effectLayer" {
  51851. import { Observable } from "babylonjs/Misc/observable";
  51852. import { Nullable } from "babylonjs/types";
  51853. import { Camera } from "babylonjs/Cameras/camera";
  51854. import { Scene } from "babylonjs/scene";
  51855. import { ISize } from "babylonjs/Maths/math.size";
  51856. import { Color4 } from "babylonjs/Maths/math.color";
  51857. import { Engine } from "babylonjs/Engines/engine";
  51858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51860. import { Mesh } from "babylonjs/Meshes/mesh";
  51861. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51864. import { Effect } from "babylonjs/Materials/effect";
  51865. import { Material } from "babylonjs/Materials/material";
  51866. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51867. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51868. /**
  51869. * Effect layer options. This helps customizing the behaviour
  51870. * of the effect layer.
  51871. */
  51872. export interface IEffectLayerOptions {
  51873. /**
  51874. * Multiplication factor apply to the canvas size to compute the render target size
  51875. * used to generated the objects (the smaller the faster).
  51876. */
  51877. mainTextureRatio: number;
  51878. /**
  51879. * Enforces a fixed size texture to ensure effect stability across devices.
  51880. */
  51881. mainTextureFixedSize?: number;
  51882. /**
  51883. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51884. */
  51885. alphaBlendingMode: number;
  51886. /**
  51887. * The camera attached to the layer.
  51888. */
  51889. camera: Nullable<Camera>;
  51890. /**
  51891. * The rendering group to draw the layer in.
  51892. */
  51893. renderingGroupId: number;
  51894. }
  51895. /**
  51896. * The effect layer Helps adding post process effect blended with the main pass.
  51897. *
  51898. * This can be for instance use to generate glow or higlight effects on the scene.
  51899. *
  51900. * The effect layer class can not be used directly and is intented to inherited from to be
  51901. * customized per effects.
  51902. */
  51903. export abstract class EffectLayer {
  51904. private _vertexBuffers;
  51905. private _indexBuffer;
  51906. private _cachedDefines;
  51907. private _effectLayerMapGenerationEffect;
  51908. private _effectLayerOptions;
  51909. private _mergeEffect;
  51910. protected _scene: Scene;
  51911. protected _engine: Engine;
  51912. protected _maxSize: number;
  51913. protected _mainTextureDesiredSize: ISize;
  51914. protected _mainTexture: RenderTargetTexture;
  51915. protected _shouldRender: boolean;
  51916. protected _postProcesses: PostProcess[];
  51917. protected _textures: BaseTexture[];
  51918. protected _emissiveTextureAndColor: {
  51919. texture: Nullable<BaseTexture>;
  51920. color: Color4;
  51921. };
  51922. /**
  51923. * The name of the layer
  51924. */
  51925. name: string;
  51926. /**
  51927. * The clear color of the texture used to generate the glow map.
  51928. */
  51929. neutralColor: Color4;
  51930. /**
  51931. * Specifies wether the highlight layer is enabled or not.
  51932. */
  51933. isEnabled: boolean;
  51934. /**
  51935. * Gets the camera attached to the layer.
  51936. */
  51937. readonly camera: Nullable<Camera>;
  51938. /**
  51939. * Gets the rendering group id the layer should render in.
  51940. */
  51941. renderingGroupId: number;
  51942. /**
  51943. * An event triggered when the effect layer has been disposed.
  51944. */
  51945. onDisposeObservable: Observable<EffectLayer>;
  51946. /**
  51947. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51948. */
  51949. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51950. /**
  51951. * An event triggered when the generated texture is being merged in the scene.
  51952. */
  51953. onBeforeComposeObservable: Observable<EffectLayer>;
  51954. /**
  51955. * An event triggered when the mesh is rendered into the effect render target.
  51956. */
  51957. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51958. /**
  51959. * An event triggered after the mesh has been rendered into the effect render target.
  51960. */
  51961. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51962. /**
  51963. * An event triggered when the generated texture has been merged in the scene.
  51964. */
  51965. onAfterComposeObservable: Observable<EffectLayer>;
  51966. /**
  51967. * An event triggered when the efffect layer changes its size.
  51968. */
  51969. onSizeChangedObservable: Observable<EffectLayer>;
  51970. /** @hidden */
  51971. static _SceneComponentInitialization: (scene: Scene) => void;
  51972. /**
  51973. * Instantiates a new effect Layer and references it in the scene.
  51974. * @param name The name of the layer
  51975. * @param scene The scene to use the layer in
  51976. */
  51977. constructor(
  51978. /** The Friendly of the effect in the scene */
  51979. name: string, scene: Scene);
  51980. /**
  51981. * Get the effect name of the layer.
  51982. * @return The effect name
  51983. */
  51984. abstract getEffectName(): string;
  51985. /**
  51986. * Checks for the readiness of the element composing the layer.
  51987. * @param subMesh the mesh to check for
  51988. * @param useInstances specify wether or not to use instances to render the mesh
  51989. * @return true if ready otherwise, false
  51990. */
  51991. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51992. /**
  51993. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51994. * @returns true if the effect requires stencil during the main canvas render pass.
  51995. */
  51996. abstract needStencil(): boolean;
  51997. /**
  51998. * Create the merge effect. This is the shader use to blit the information back
  51999. * to the main canvas at the end of the scene rendering.
  52000. * @returns The effect containing the shader used to merge the effect on the main canvas
  52001. */
  52002. protected abstract _createMergeEffect(): Effect;
  52003. /**
  52004. * Creates the render target textures and post processes used in the effect layer.
  52005. */
  52006. protected abstract _createTextureAndPostProcesses(): void;
  52007. /**
  52008. * Implementation specific of rendering the generating effect on the main canvas.
  52009. * @param effect The effect used to render through
  52010. */
  52011. protected abstract _internalRender(effect: Effect): void;
  52012. /**
  52013. * Sets the required values for both the emissive texture and and the main color.
  52014. */
  52015. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52016. /**
  52017. * Free any resources and references associated to a mesh.
  52018. * Internal use
  52019. * @param mesh The mesh to free.
  52020. */
  52021. abstract _disposeMesh(mesh: Mesh): void;
  52022. /**
  52023. * Serializes this layer (Glow or Highlight for example)
  52024. * @returns a serialized layer object
  52025. */
  52026. abstract serialize?(): any;
  52027. /**
  52028. * Initializes the effect layer with the required options.
  52029. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52030. */
  52031. protected _init(options: Partial<IEffectLayerOptions>): void;
  52032. /**
  52033. * Generates the index buffer of the full screen quad blending to the main canvas.
  52034. */
  52035. private _generateIndexBuffer;
  52036. /**
  52037. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52038. */
  52039. private _generateVertexBuffer;
  52040. /**
  52041. * Sets the main texture desired size which is the closest power of two
  52042. * of the engine canvas size.
  52043. */
  52044. private _setMainTextureSize;
  52045. /**
  52046. * Creates the main texture for the effect layer.
  52047. */
  52048. protected _createMainTexture(): void;
  52049. /**
  52050. * Adds specific effects defines.
  52051. * @param defines The defines to add specifics to.
  52052. */
  52053. protected _addCustomEffectDefines(defines: string[]): void;
  52054. /**
  52055. * Checks for the readiness of the element composing the layer.
  52056. * @param subMesh the mesh to check for
  52057. * @param useInstances specify wether or not to use instances to render the mesh
  52058. * @param emissiveTexture the associated emissive texture used to generate the glow
  52059. * @return true if ready otherwise, false
  52060. */
  52061. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52062. /**
  52063. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52064. */
  52065. render(): void;
  52066. /**
  52067. * Determine if a given mesh will be used in the current effect.
  52068. * @param mesh mesh to test
  52069. * @returns true if the mesh will be used
  52070. */
  52071. hasMesh(mesh: AbstractMesh): boolean;
  52072. /**
  52073. * Returns true if the layer contains information to display, otherwise false.
  52074. * @returns true if the glow layer should be rendered
  52075. */
  52076. shouldRender(): boolean;
  52077. /**
  52078. * Returns true if the mesh should render, otherwise false.
  52079. * @param mesh The mesh to render
  52080. * @returns true if it should render otherwise false
  52081. */
  52082. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52083. /**
  52084. * Returns true if the mesh can be rendered, otherwise false.
  52085. * @param mesh The mesh to render
  52086. * @param material The material used on the mesh
  52087. * @returns true if it can be rendered otherwise false
  52088. */
  52089. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52090. /**
  52091. * Returns true if the mesh should render, otherwise false.
  52092. * @param mesh The mesh to render
  52093. * @returns true if it should render otherwise false
  52094. */
  52095. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52096. /**
  52097. * Renders the submesh passed in parameter to the generation map.
  52098. */
  52099. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52100. /**
  52101. * Defines wether the current material of the mesh should be use to render the effect.
  52102. * @param mesh defines the current mesh to render
  52103. */
  52104. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52105. /**
  52106. * Rebuild the required buffers.
  52107. * @hidden Internal use only.
  52108. */
  52109. _rebuild(): void;
  52110. /**
  52111. * Dispose only the render target textures and post process.
  52112. */
  52113. private _disposeTextureAndPostProcesses;
  52114. /**
  52115. * Dispose the highlight layer and free resources.
  52116. */
  52117. dispose(): void;
  52118. /**
  52119. * Gets the class name of the effect layer
  52120. * @returns the string with the class name of the effect layer
  52121. */
  52122. getClassName(): string;
  52123. /**
  52124. * Creates an effect layer from parsed effect layer data
  52125. * @param parsedEffectLayer defines effect layer data
  52126. * @param scene defines the current scene
  52127. * @param rootUrl defines the root URL containing the effect layer information
  52128. * @returns a parsed effect Layer
  52129. */
  52130. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52131. }
  52132. }
  52133. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52134. import { Scene } from "babylonjs/scene";
  52135. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52136. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52137. import { AbstractScene } from "babylonjs/abstractScene";
  52138. module "babylonjs/abstractScene" {
  52139. interface AbstractScene {
  52140. /**
  52141. * The list of effect layers (highlights/glow) added to the scene
  52142. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52143. * @see http://doc.babylonjs.com/how_to/glow_layer
  52144. */
  52145. effectLayers: Array<EffectLayer>;
  52146. /**
  52147. * Removes the given effect layer from this scene.
  52148. * @param toRemove defines the effect layer to remove
  52149. * @returns the index of the removed effect layer
  52150. */
  52151. removeEffectLayer(toRemove: EffectLayer): number;
  52152. /**
  52153. * Adds the given effect layer to this scene
  52154. * @param newEffectLayer defines the effect layer to add
  52155. */
  52156. addEffectLayer(newEffectLayer: EffectLayer): void;
  52157. }
  52158. }
  52159. /**
  52160. * Defines the layer scene component responsible to manage any effect layers
  52161. * in a given scene.
  52162. */
  52163. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52164. /**
  52165. * The component name helpfull to identify the component in the list of scene components.
  52166. */
  52167. readonly name: string;
  52168. /**
  52169. * The scene the component belongs to.
  52170. */
  52171. scene: Scene;
  52172. private _engine;
  52173. private _renderEffects;
  52174. private _needStencil;
  52175. private _previousStencilState;
  52176. /**
  52177. * Creates a new instance of the component for the given scene
  52178. * @param scene Defines the scene to register the component in
  52179. */
  52180. constructor(scene: Scene);
  52181. /**
  52182. * Registers the component in a given scene
  52183. */
  52184. register(): void;
  52185. /**
  52186. * Rebuilds the elements related to this component in case of
  52187. * context lost for instance.
  52188. */
  52189. rebuild(): void;
  52190. /**
  52191. * Serializes the component data to the specified json object
  52192. * @param serializationObject The object to serialize to
  52193. */
  52194. serialize(serializationObject: any): void;
  52195. /**
  52196. * Adds all the elements from the container to the scene
  52197. * @param container the container holding the elements
  52198. */
  52199. addFromContainer(container: AbstractScene): void;
  52200. /**
  52201. * Removes all the elements in the container from the scene
  52202. * @param container contains the elements to remove
  52203. * @param dispose if the removed element should be disposed (default: false)
  52204. */
  52205. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52206. /**
  52207. * Disposes the component and the associated ressources.
  52208. */
  52209. dispose(): void;
  52210. private _isReadyForMesh;
  52211. private _renderMainTexture;
  52212. private _setStencil;
  52213. private _setStencilBack;
  52214. private _draw;
  52215. private _drawCamera;
  52216. private _drawRenderingGroup;
  52217. }
  52218. }
  52219. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52220. /** @hidden */
  52221. export var glowMapMergePixelShader: {
  52222. name: string;
  52223. shader: string;
  52224. };
  52225. }
  52226. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52227. /** @hidden */
  52228. export var glowMapMergeVertexShader: {
  52229. name: string;
  52230. shader: string;
  52231. };
  52232. }
  52233. declare module "babylonjs/Layers/glowLayer" {
  52234. import { Nullable } from "babylonjs/types";
  52235. import { Camera } from "babylonjs/Cameras/camera";
  52236. import { Scene } from "babylonjs/scene";
  52237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52239. import { Mesh } from "babylonjs/Meshes/mesh";
  52240. import { Texture } from "babylonjs/Materials/Textures/texture";
  52241. import { Effect } from "babylonjs/Materials/effect";
  52242. import { Material } from "babylonjs/Materials/material";
  52243. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52244. import { Color4 } from "babylonjs/Maths/math.color";
  52245. import "babylonjs/Shaders/glowMapMerge.fragment";
  52246. import "babylonjs/Shaders/glowMapMerge.vertex";
  52247. import "babylonjs/Layers/effectLayerSceneComponent";
  52248. module "babylonjs/abstractScene" {
  52249. interface AbstractScene {
  52250. /**
  52251. * Return a the first highlight layer of the scene with a given name.
  52252. * @param name The name of the highlight layer to look for.
  52253. * @return The highlight layer if found otherwise null.
  52254. */
  52255. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52256. }
  52257. }
  52258. /**
  52259. * Glow layer options. This helps customizing the behaviour
  52260. * of the glow layer.
  52261. */
  52262. export interface IGlowLayerOptions {
  52263. /**
  52264. * Multiplication factor apply to the canvas size to compute the render target size
  52265. * used to generated the glowing objects (the smaller the faster).
  52266. */
  52267. mainTextureRatio: number;
  52268. /**
  52269. * Enforces a fixed size texture to ensure resize independant blur.
  52270. */
  52271. mainTextureFixedSize?: number;
  52272. /**
  52273. * How big is the kernel of the blur texture.
  52274. */
  52275. blurKernelSize: number;
  52276. /**
  52277. * The camera attached to the layer.
  52278. */
  52279. camera: Nullable<Camera>;
  52280. /**
  52281. * Enable MSAA by chosing the number of samples.
  52282. */
  52283. mainTextureSamples?: number;
  52284. /**
  52285. * The rendering group to draw the layer in.
  52286. */
  52287. renderingGroupId: number;
  52288. }
  52289. /**
  52290. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52291. *
  52292. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52293. *
  52294. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52295. */
  52296. export class GlowLayer extends EffectLayer {
  52297. /**
  52298. * Effect Name of the layer.
  52299. */
  52300. static readonly EffectName: string;
  52301. /**
  52302. * The default blur kernel size used for the glow.
  52303. */
  52304. static DefaultBlurKernelSize: number;
  52305. /**
  52306. * The default texture size ratio used for the glow.
  52307. */
  52308. static DefaultTextureRatio: number;
  52309. /**
  52310. * Sets the kernel size of the blur.
  52311. */
  52312. /**
  52313. * Gets the kernel size of the blur.
  52314. */
  52315. blurKernelSize: number;
  52316. /**
  52317. * Sets the glow intensity.
  52318. */
  52319. /**
  52320. * Gets the glow intensity.
  52321. */
  52322. intensity: number;
  52323. private _options;
  52324. private _intensity;
  52325. private _horizontalBlurPostprocess1;
  52326. private _verticalBlurPostprocess1;
  52327. private _horizontalBlurPostprocess2;
  52328. private _verticalBlurPostprocess2;
  52329. private _blurTexture1;
  52330. private _blurTexture2;
  52331. private _postProcesses1;
  52332. private _postProcesses2;
  52333. private _includedOnlyMeshes;
  52334. private _excludedMeshes;
  52335. private _meshesUsingTheirOwnMaterials;
  52336. /**
  52337. * Callback used to let the user override the color selection on a per mesh basis
  52338. */
  52339. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52340. /**
  52341. * Callback used to let the user override the texture selection on a per mesh basis
  52342. */
  52343. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52344. /**
  52345. * Instantiates a new glow Layer and references it to the scene.
  52346. * @param name The name of the layer
  52347. * @param scene The scene to use the layer in
  52348. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52349. */
  52350. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52351. /**
  52352. * Get the effect name of the layer.
  52353. * @return The effect name
  52354. */
  52355. getEffectName(): string;
  52356. /**
  52357. * Create the merge effect. This is the shader use to blit the information back
  52358. * to the main canvas at the end of the scene rendering.
  52359. */
  52360. protected _createMergeEffect(): Effect;
  52361. /**
  52362. * Creates the render target textures and post processes used in the glow layer.
  52363. */
  52364. protected _createTextureAndPostProcesses(): void;
  52365. /**
  52366. * Checks for the readiness of the element composing the layer.
  52367. * @param subMesh the mesh to check for
  52368. * @param useInstances specify wether or not to use instances to render the mesh
  52369. * @param emissiveTexture the associated emissive texture used to generate the glow
  52370. * @return true if ready otherwise, false
  52371. */
  52372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52373. /**
  52374. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52375. */
  52376. needStencil(): boolean;
  52377. /**
  52378. * Returns true if the mesh can be rendered, otherwise false.
  52379. * @param mesh The mesh to render
  52380. * @param material The material used on the mesh
  52381. * @returns true if it can be rendered otherwise false
  52382. */
  52383. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52384. /**
  52385. * Implementation specific of rendering the generating effect on the main canvas.
  52386. * @param effect The effect used to render through
  52387. */
  52388. protected _internalRender(effect: Effect): void;
  52389. /**
  52390. * Sets the required values for both the emissive texture and and the main color.
  52391. */
  52392. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52393. /**
  52394. * Returns true if the mesh should render, otherwise false.
  52395. * @param mesh The mesh to render
  52396. * @returns true if it should render otherwise false
  52397. */
  52398. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52399. /**
  52400. * Adds specific effects defines.
  52401. * @param defines The defines to add specifics to.
  52402. */
  52403. protected _addCustomEffectDefines(defines: string[]): void;
  52404. /**
  52405. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52406. * @param mesh The mesh to exclude from the glow layer
  52407. */
  52408. addExcludedMesh(mesh: Mesh): void;
  52409. /**
  52410. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52411. * @param mesh The mesh to remove
  52412. */
  52413. removeExcludedMesh(mesh: Mesh): void;
  52414. /**
  52415. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52416. * @param mesh The mesh to include in the glow layer
  52417. */
  52418. addIncludedOnlyMesh(mesh: Mesh): void;
  52419. /**
  52420. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52421. * @param mesh The mesh to remove
  52422. */
  52423. removeIncludedOnlyMesh(mesh: Mesh): void;
  52424. /**
  52425. * Determine if a given mesh will be used in the glow layer
  52426. * @param mesh The mesh to test
  52427. * @returns true if the mesh will be highlighted by the current glow layer
  52428. */
  52429. hasMesh(mesh: AbstractMesh): boolean;
  52430. /**
  52431. * Defines wether the current material of the mesh should be use to render the effect.
  52432. * @param mesh defines the current mesh to render
  52433. */
  52434. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52435. /**
  52436. * Add a mesh to be rendered through its own material and not with emissive only.
  52437. * @param mesh The mesh for which we need to use its material
  52438. */
  52439. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52440. /**
  52441. * Remove a mesh from being rendered through its own material and not with emissive only.
  52442. * @param mesh The mesh for which we need to not use its material
  52443. */
  52444. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52445. /**
  52446. * Free any resources and references associated to a mesh.
  52447. * Internal use
  52448. * @param mesh The mesh to free.
  52449. * @hidden
  52450. */
  52451. _disposeMesh(mesh: Mesh): void;
  52452. /**
  52453. * Gets the class name of the effect layer
  52454. * @returns the string with the class name of the effect layer
  52455. */
  52456. getClassName(): string;
  52457. /**
  52458. * Serializes this glow layer
  52459. * @returns a serialized glow layer object
  52460. */
  52461. serialize(): any;
  52462. /**
  52463. * Creates a Glow Layer from parsed glow layer data
  52464. * @param parsedGlowLayer defines glow layer data
  52465. * @param scene defines the current scene
  52466. * @param rootUrl defines the root URL containing the glow layer information
  52467. * @returns a parsed Glow Layer
  52468. */
  52469. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52470. }
  52471. }
  52472. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52473. /** @hidden */
  52474. export var glowBlurPostProcessPixelShader: {
  52475. name: string;
  52476. shader: string;
  52477. };
  52478. }
  52479. declare module "babylonjs/Layers/highlightLayer" {
  52480. import { Observable } from "babylonjs/Misc/observable";
  52481. import { Nullable } from "babylonjs/types";
  52482. import { Camera } from "babylonjs/Cameras/camera";
  52483. import { Scene } from "babylonjs/scene";
  52484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52486. import { Mesh } from "babylonjs/Meshes/mesh";
  52487. import { Effect } from "babylonjs/Materials/effect";
  52488. import { Material } from "babylonjs/Materials/material";
  52489. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52490. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52491. import "babylonjs/Shaders/glowMapMerge.fragment";
  52492. import "babylonjs/Shaders/glowMapMerge.vertex";
  52493. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52494. module "babylonjs/abstractScene" {
  52495. interface AbstractScene {
  52496. /**
  52497. * Return a the first highlight layer of the scene with a given name.
  52498. * @param name The name of the highlight layer to look for.
  52499. * @return The highlight layer if found otherwise null.
  52500. */
  52501. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52502. }
  52503. }
  52504. /**
  52505. * Highlight layer options. This helps customizing the behaviour
  52506. * of the highlight layer.
  52507. */
  52508. export interface IHighlightLayerOptions {
  52509. /**
  52510. * Multiplication factor apply to the canvas size to compute the render target size
  52511. * used to generated the glowing objects (the smaller the faster).
  52512. */
  52513. mainTextureRatio: number;
  52514. /**
  52515. * Enforces a fixed size texture to ensure resize independant blur.
  52516. */
  52517. mainTextureFixedSize?: number;
  52518. /**
  52519. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52520. * of the picture to blur (the smaller the faster).
  52521. */
  52522. blurTextureSizeRatio: number;
  52523. /**
  52524. * How big in texel of the blur texture is the vertical blur.
  52525. */
  52526. blurVerticalSize: number;
  52527. /**
  52528. * How big in texel of the blur texture is the horizontal blur.
  52529. */
  52530. blurHorizontalSize: number;
  52531. /**
  52532. * Alpha blending mode used to apply the blur. Default is combine.
  52533. */
  52534. alphaBlendingMode: number;
  52535. /**
  52536. * The camera attached to the layer.
  52537. */
  52538. camera: Nullable<Camera>;
  52539. /**
  52540. * Should we display highlight as a solid stroke?
  52541. */
  52542. isStroke?: boolean;
  52543. /**
  52544. * The rendering group to draw the layer in.
  52545. */
  52546. renderingGroupId: number;
  52547. }
  52548. /**
  52549. * The highlight layer Helps adding a glow effect around a mesh.
  52550. *
  52551. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52552. * glowy meshes to your scene.
  52553. *
  52554. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52555. */
  52556. export class HighlightLayer extends EffectLayer {
  52557. name: string;
  52558. /**
  52559. * Effect Name of the highlight layer.
  52560. */
  52561. static readonly EffectName: string;
  52562. /**
  52563. * The neutral color used during the preparation of the glow effect.
  52564. * This is black by default as the blend operation is a blend operation.
  52565. */
  52566. static NeutralColor: Color4;
  52567. /**
  52568. * Stencil value used for glowing meshes.
  52569. */
  52570. static GlowingMeshStencilReference: number;
  52571. /**
  52572. * Stencil value used for the other meshes in the scene.
  52573. */
  52574. static NormalMeshStencilReference: number;
  52575. /**
  52576. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52577. */
  52578. innerGlow: boolean;
  52579. /**
  52580. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52581. */
  52582. outerGlow: boolean;
  52583. /**
  52584. * Specifies the horizontal size of the blur.
  52585. */
  52586. /**
  52587. * Gets the horizontal size of the blur.
  52588. */
  52589. blurHorizontalSize: number;
  52590. /**
  52591. * Specifies the vertical size of the blur.
  52592. */
  52593. /**
  52594. * Gets the vertical size of the blur.
  52595. */
  52596. blurVerticalSize: number;
  52597. /**
  52598. * An event triggered when the highlight layer is being blurred.
  52599. */
  52600. onBeforeBlurObservable: Observable<HighlightLayer>;
  52601. /**
  52602. * An event triggered when the highlight layer has been blurred.
  52603. */
  52604. onAfterBlurObservable: Observable<HighlightLayer>;
  52605. private _instanceGlowingMeshStencilReference;
  52606. private _options;
  52607. private _downSamplePostprocess;
  52608. private _horizontalBlurPostprocess;
  52609. private _verticalBlurPostprocess;
  52610. private _blurTexture;
  52611. private _meshes;
  52612. private _excludedMeshes;
  52613. /**
  52614. * Instantiates a new highlight Layer and references it to the scene..
  52615. * @param name The name of the layer
  52616. * @param scene The scene to use the layer in
  52617. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52618. */
  52619. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52620. /**
  52621. * Get the effect name of the layer.
  52622. * @return The effect name
  52623. */
  52624. getEffectName(): string;
  52625. /**
  52626. * Create the merge effect. This is the shader use to blit the information back
  52627. * to the main canvas at the end of the scene rendering.
  52628. */
  52629. protected _createMergeEffect(): Effect;
  52630. /**
  52631. * Creates the render target textures and post processes used in the highlight layer.
  52632. */
  52633. protected _createTextureAndPostProcesses(): void;
  52634. /**
  52635. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52636. */
  52637. needStencil(): boolean;
  52638. /**
  52639. * Checks for the readiness of the element composing the layer.
  52640. * @param subMesh the mesh to check for
  52641. * @param useInstances specify wether or not to use instances to render the mesh
  52642. * @param emissiveTexture the associated emissive texture used to generate the glow
  52643. * @return true if ready otherwise, false
  52644. */
  52645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52646. /**
  52647. * Implementation specific of rendering the generating effect on the main canvas.
  52648. * @param effect The effect used to render through
  52649. */
  52650. protected _internalRender(effect: Effect): void;
  52651. /**
  52652. * Returns true if the layer contains information to display, otherwise false.
  52653. */
  52654. shouldRender(): boolean;
  52655. /**
  52656. * Returns true if the mesh should render, otherwise false.
  52657. * @param mesh The mesh to render
  52658. * @returns true if it should render otherwise false
  52659. */
  52660. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52661. /**
  52662. * Sets the required values for both the emissive texture and and the main color.
  52663. */
  52664. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52665. /**
  52666. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52667. * @param mesh The mesh to exclude from the highlight layer
  52668. */
  52669. addExcludedMesh(mesh: Mesh): void;
  52670. /**
  52671. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52672. * @param mesh The mesh to highlight
  52673. */
  52674. removeExcludedMesh(mesh: Mesh): void;
  52675. /**
  52676. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52677. * @param mesh mesh to test
  52678. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52679. */
  52680. hasMesh(mesh: AbstractMesh): boolean;
  52681. /**
  52682. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52683. * @param mesh The mesh to highlight
  52684. * @param color The color of the highlight
  52685. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52686. */
  52687. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52688. /**
  52689. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52690. * @param mesh The mesh to highlight
  52691. */
  52692. removeMesh(mesh: Mesh): void;
  52693. /**
  52694. * Force the stencil to the normal expected value for none glowing parts
  52695. */
  52696. private _defaultStencilReference;
  52697. /**
  52698. * Free any resources and references associated to a mesh.
  52699. * Internal use
  52700. * @param mesh The mesh to free.
  52701. * @hidden
  52702. */
  52703. _disposeMesh(mesh: Mesh): void;
  52704. /**
  52705. * Dispose the highlight layer and free resources.
  52706. */
  52707. dispose(): void;
  52708. /**
  52709. * Gets the class name of the effect layer
  52710. * @returns the string with the class name of the effect layer
  52711. */
  52712. getClassName(): string;
  52713. /**
  52714. * Serializes this Highlight layer
  52715. * @returns a serialized Highlight layer object
  52716. */
  52717. serialize(): any;
  52718. /**
  52719. * Creates a Highlight layer from parsed Highlight layer data
  52720. * @param parsedHightlightLayer defines the Highlight layer data
  52721. * @param scene defines the current scene
  52722. * @param rootUrl defines the root URL containing the Highlight layer information
  52723. * @returns a parsed Highlight layer
  52724. */
  52725. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52726. }
  52727. }
  52728. declare module "babylonjs/Layers/layerSceneComponent" {
  52729. import { Scene } from "babylonjs/scene";
  52730. import { ISceneComponent } from "babylonjs/sceneComponent";
  52731. import { Layer } from "babylonjs/Layers/layer";
  52732. import { AbstractScene } from "babylonjs/abstractScene";
  52733. module "babylonjs/abstractScene" {
  52734. interface AbstractScene {
  52735. /**
  52736. * The list of layers (background and foreground) of the scene
  52737. */
  52738. layers: Array<Layer>;
  52739. }
  52740. }
  52741. /**
  52742. * Defines the layer scene component responsible to manage any layers
  52743. * in a given scene.
  52744. */
  52745. export class LayerSceneComponent implements ISceneComponent {
  52746. /**
  52747. * The component name helpfull to identify the component in the list of scene components.
  52748. */
  52749. readonly name: string;
  52750. /**
  52751. * The scene the component belongs to.
  52752. */
  52753. scene: Scene;
  52754. private _engine;
  52755. /**
  52756. * Creates a new instance of the component for the given scene
  52757. * @param scene Defines the scene to register the component in
  52758. */
  52759. constructor(scene: Scene);
  52760. /**
  52761. * Registers the component in a given scene
  52762. */
  52763. register(): void;
  52764. /**
  52765. * Rebuilds the elements related to this component in case of
  52766. * context lost for instance.
  52767. */
  52768. rebuild(): void;
  52769. /**
  52770. * Disposes the component and the associated ressources.
  52771. */
  52772. dispose(): void;
  52773. private _draw;
  52774. private _drawCameraPredicate;
  52775. private _drawCameraBackground;
  52776. private _drawCameraForeground;
  52777. private _drawRenderTargetPredicate;
  52778. private _drawRenderTargetBackground;
  52779. private _drawRenderTargetForeground;
  52780. /**
  52781. * Adds all the elements from the container to the scene
  52782. * @param container the container holding the elements
  52783. */
  52784. addFromContainer(container: AbstractScene): void;
  52785. /**
  52786. * Removes all the elements in the container from the scene
  52787. * @param container contains the elements to remove
  52788. * @param dispose if the removed element should be disposed (default: false)
  52789. */
  52790. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52791. }
  52792. }
  52793. declare module "babylonjs/Shaders/layer.fragment" {
  52794. /** @hidden */
  52795. export var layerPixelShader: {
  52796. name: string;
  52797. shader: string;
  52798. };
  52799. }
  52800. declare module "babylonjs/Shaders/layer.vertex" {
  52801. /** @hidden */
  52802. export var layerVertexShader: {
  52803. name: string;
  52804. shader: string;
  52805. };
  52806. }
  52807. declare module "babylonjs/Layers/layer" {
  52808. import { Observable } from "babylonjs/Misc/observable";
  52809. import { Nullable } from "babylonjs/types";
  52810. import { Scene } from "babylonjs/scene";
  52811. import { Vector2 } from "babylonjs/Maths/math.vector";
  52812. import { Color4 } from "babylonjs/Maths/math.color";
  52813. import { Texture } from "babylonjs/Materials/Textures/texture";
  52814. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52815. import "babylonjs/Shaders/layer.fragment";
  52816. import "babylonjs/Shaders/layer.vertex";
  52817. /**
  52818. * This represents a full screen 2d layer.
  52819. * This can be useful to display a picture in the background of your scene for instance.
  52820. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52821. */
  52822. export class Layer {
  52823. /**
  52824. * Define the name of the layer.
  52825. */
  52826. name: string;
  52827. /**
  52828. * Define the texture the layer should display.
  52829. */
  52830. texture: Nullable<Texture>;
  52831. /**
  52832. * Is the layer in background or foreground.
  52833. */
  52834. isBackground: boolean;
  52835. /**
  52836. * Define the color of the layer (instead of texture).
  52837. */
  52838. color: Color4;
  52839. /**
  52840. * Define the scale of the layer in order to zoom in out of the texture.
  52841. */
  52842. scale: Vector2;
  52843. /**
  52844. * Define an offset for the layer in order to shift the texture.
  52845. */
  52846. offset: Vector2;
  52847. /**
  52848. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52849. */
  52850. alphaBlendingMode: number;
  52851. /**
  52852. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52853. * Alpha test will not mix with the background color in case of transparency.
  52854. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52855. */
  52856. alphaTest: boolean;
  52857. /**
  52858. * Define a mask to restrict the layer to only some of the scene cameras.
  52859. */
  52860. layerMask: number;
  52861. /**
  52862. * Define the list of render target the layer is visible into.
  52863. */
  52864. renderTargetTextures: RenderTargetTexture[];
  52865. /**
  52866. * Define if the layer is only used in renderTarget or if it also
  52867. * renders in the main frame buffer of the canvas.
  52868. */
  52869. renderOnlyInRenderTargetTextures: boolean;
  52870. private _scene;
  52871. private _vertexBuffers;
  52872. private _indexBuffer;
  52873. private _effect;
  52874. private _alphaTestEffect;
  52875. /**
  52876. * An event triggered when the layer is disposed.
  52877. */
  52878. onDisposeObservable: Observable<Layer>;
  52879. private _onDisposeObserver;
  52880. /**
  52881. * Back compatibility with callback before the onDisposeObservable existed.
  52882. * The set callback will be triggered when the layer has been disposed.
  52883. */
  52884. onDispose: () => void;
  52885. /**
  52886. * An event triggered before rendering the scene
  52887. */
  52888. onBeforeRenderObservable: Observable<Layer>;
  52889. private _onBeforeRenderObserver;
  52890. /**
  52891. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52892. * The set callback will be triggered just before rendering the layer.
  52893. */
  52894. onBeforeRender: () => void;
  52895. /**
  52896. * An event triggered after rendering the scene
  52897. */
  52898. onAfterRenderObservable: Observable<Layer>;
  52899. private _onAfterRenderObserver;
  52900. /**
  52901. * Back compatibility with callback before the onAfterRenderObservable existed.
  52902. * The set callback will be triggered just after rendering the layer.
  52903. */
  52904. onAfterRender: () => void;
  52905. /**
  52906. * Instantiates a new layer.
  52907. * This represents a full screen 2d layer.
  52908. * This can be useful to display a picture in the background of your scene for instance.
  52909. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52910. * @param name Define the name of the layer in the scene
  52911. * @param imgUrl Define the url of the texture to display in the layer
  52912. * @param scene Define the scene the layer belongs to
  52913. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52914. * @param color Defines a color for the layer
  52915. */
  52916. constructor(
  52917. /**
  52918. * Define the name of the layer.
  52919. */
  52920. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52921. private _createIndexBuffer;
  52922. /** @hidden */
  52923. _rebuild(): void;
  52924. /**
  52925. * Renders the layer in the scene.
  52926. */
  52927. render(): void;
  52928. /**
  52929. * Disposes and releases the associated ressources.
  52930. */
  52931. dispose(): void;
  52932. }
  52933. }
  52934. declare module "babylonjs/Layers/index" {
  52935. export * from "babylonjs/Layers/effectLayer";
  52936. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52937. export * from "babylonjs/Layers/glowLayer";
  52938. export * from "babylonjs/Layers/highlightLayer";
  52939. export * from "babylonjs/Layers/layer";
  52940. export * from "babylonjs/Layers/layerSceneComponent";
  52941. }
  52942. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52943. /** @hidden */
  52944. export var lensFlarePixelShader: {
  52945. name: string;
  52946. shader: string;
  52947. };
  52948. }
  52949. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52950. /** @hidden */
  52951. export var lensFlareVertexShader: {
  52952. name: string;
  52953. shader: string;
  52954. };
  52955. }
  52956. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52957. import { Scene } from "babylonjs/scene";
  52958. import { Vector3 } from "babylonjs/Maths/math.vector";
  52959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52960. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52961. import "babylonjs/Shaders/lensFlare.fragment";
  52962. import "babylonjs/Shaders/lensFlare.vertex";
  52963. import { Viewport } from "babylonjs/Maths/math.viewport";
  52964. /**
  52965. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52966. * It is usually composed of several `lensFlare`.
  52967. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52968. */
  52969. export class LensFlareSystem {
  52970. /**
  52971. * Define the name of the lens flare system
  52972. */
  52973. name: string;
  52974. /**
  52975. * List of lens flares used in this system.
  52976. */
  52977. lensFlares: LensFlare[];
  52978. /**
  52979. * Define a limit from the border the lens flare can be visible.
  52980. */
  52981. borderLimit: number;
  52982. /**
  52983. * Define a viewport border we do not want to see the lens flare in.
  52984. */
  52985. viewportBorder: number;
  52986. /**
  52987. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52988. */
  52989. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52990. /**
  52991. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52992. */
  52993. layerMask: number;
  52994. /**
  52995. * Define the id of the lens flare system in the scene.
  52996. * (equal to name by default)
  52997. */
  52998. id: string;
  52999. private _scene;
  53000. private _emitter;
  53001. private _vertexBuffers;
  53002. private _indexBuffer;
  53003. private _effect;
  53004. private _positionX;
  53005. private _positionY;
  53006. private _isEnabled;
  53007. /** @hidden */
  53008. static _SceneComponentInitialization: (scene: Scene) => void;
  53009. /**
  53010. * Instantiates a lens flare system.
  53011. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53012. * It is usually composed of several `lensFlare`.
  53013. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53014. * @param name Define the name of the lens flare system in the scene
  53015. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53016. * @param scene Define the scene the lens flare system belongs to
  53017. */
  53018. constructor(
  53019. /**
  53020. * Define the name of the lens flare system
  53021. */
  53022. name: string, emitter: any, scene: Scene);
  53023. /**
  53024. * Define if the lens flare system is enabled.
  53025. */
  53026. isEnabled: boolean;
  53027. /**
  53028. * Get the scene the effects belongs to.
  53029. * @returns the scene holding the lens flare system
  53030. */
  53031. getScene(): Scene;
  53032. /**
  53033. * Get the emitter of the lens flare system.
  53034. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53035. * @returns the emitter of the lens flare system
  53036. */
  53037. getEmitter(): any;
  53038. /**
  53039. * Set the emitter of the lens flare system.
  53040. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53041. * @param newEmitter Define the new emitter of the system
  53042. */
  53043. setEmitter(newEmitter: any): void;
  53044. /**
  53045. * Get the lens flare system emitter position.
  53046. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53047. * @returns the position
  53048. */
  53049. getEmitterPosition(): Vector3;
  53050. /**
  53051. * @hidden
  53052. */
  53053. computeEffectivePosition(globalViewport: Viewport): boolean;
  53054. /** @hidden */
  53055. _isVisible(): boolean;
  53056. /**
  53057. * @hidden
  53058. */
  53059. render(): boolean;
  53060. /**
  53061. * Dispose and release the lens flare with its associated resources.
  53062. */
  53063. dispose(): void;
  53064. /**
  53065. * Parse a lens flare system from a JSON repressentation
  53066. * @param parsedLensFlareSystem Define the JSON to parse
  53067. * @param scene Define the scene the parsed system should be instantiated in
  53068. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53069. * @returns the parsed system
  53070. */
  53071. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53072. /**
  53073. * Serialize the current Lens Flare System into a JSON representation.
  53074. * @returns the serialized JSON
  53075. */
  53076. serialize(): any;
  53077. }
  53078. }
  53079. declare module "babylonjs/LensFlares/lensFlare" {
  53080. import { Nullable } from "babylonjs/types";
  53081. import { Color3 } from "babylonjs/Maths/math.color";
  53082. import { Texture } from "babylonjs/Materials/Textures/texture";
  53083. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53084. /**
  53085. * This represents one of the lens effect in a `lensFlareSystem`.
  53086. * It controls one of the indiviual texture used in the effect.
  53087. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53088. */
  53089. export class LensFlare {
  53090. /**
  53091. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53092. */
  53093. size: number;
  53094. /**
  53095. * 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.
  53096. */
  53097. position: number;
  53098. /**
  53099. * Define the lens color.
  53100. */
  53101. color: Color3;
  53102. /**
  53103. * Define the lens texture.
  53104. */
  53105. texture: Nullable<Texture>;
  53106. /**
  53107. * Define the alpha mode to render this particular lens.
  53108. */
  53109. alphaMode: number;
  53110. private _system;
  53111. /**
  53112. * Creates a new Lens Flare.
  53113. * This represents one of the lens effect in a `lensFlareSystem`.
  53114. * It controls one of the indiviual texture used in the effect.
  53115. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53116. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53117. * @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.
  53118. * @param color Define the lens color
  53119. * @param imgUrl Define the lens texture url
  53120. * @param system Define the `lensFlareSystem` this flare is part of
  53121. * @returns The newly created Lens Flare
  53122. */
  53123. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53124. /**
  53125. * Instantiates a new Lens Flare.
  53126. * This represents one of the lens effect in a `lensFlareSystem`.
  53127. * It controls one of the indiviual texture used in the effect.
  53128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53129. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53130. * @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.
  53131. * @param color Define the lens color
  53132. * @param imgUrl Define the lens texture url
  53133. * @param system Define the `lensFlareSystem` this flare is part of
  53134. */
  53135. constructor(
  53136. /**
  53137. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53138. */
  53139. size: number,
  53140. /**
  53141. * 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.
  53142. */
  53143. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53144. /**
  53145. * Dispose and release the lens flare with its associated resources.
  53146. */
  53147. dispose(): void;
  53148. }
  53149. }
  53150. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53151. import { Nullable } from "babylonjs/types";
  53152. import { Scene } from "babylonjs/scene";
  53153. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53154. import { AbstractScene } from "babylonjs/abstractScene";
  53155. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53156. module "babylonjs/abstractScene" {
  53157. interface AbstractScene {
  53158. /**
  53159. * The list of lens flare system added to the scene
  53160. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53161. */
  53162. lensFlareSystems: Array<LensFlareSystem>;
  53163. /**
  53164. * Removes the given lens flare system from this scene.
  53165. * @param toRemove The lens flare system to remove
  53166. * @returns The index of the removed lens flare system
  53167. */
  53168. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53169. /**
  53170. * Adds the given lens flare system to this scene
  53171. * @param newLensFlareSystem The lens flare system to add
  53172. */
  53173. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53174. /**
  53175. * Gets a lens flare system using its name
  53176. * @param name defines the name to look for
  53177. * @returns the lens flare system or null if not found
  53178. */
  53179. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53180. /**
  53181. * Gets a lens flare system using its id
  53182. * @param id defines the id to look for
  53183. * @returns the lens flare system or null if not found
  53184. */
  53185. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53186. }
  53187. }
  53188. /**
  53189. * Defines the lens flare scene component responsible to manage any lens flares
  53190. * in a given scene.
  53191. */
  53192. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53193. /**
  53194. * The component name helpfull to identify the component in the list of scene components.
  53195. */
  53196. readonly name: string;
  53197. /**
  53198. * The scene the component belongs to.
  53199. */
  53200. scene: Scene;
  53201. /**
  53202. * Creates a new instance of the component for the given scene
  53203. * @param scene Defines the scene to register the component in
  53204. */
  53205. constructor(scene: Scene);
  53206. /**
  53207. * Registers the component in a given scene
  53208. */
  53209. register(): void;
  53210. /**
  53211. * Rebuilds the elements related to this component in case of
  53212. * context lost for instance.
  53213. */
  53214. rebuild(): void;
  53215. /**
  53216. * Adds all the elements from the container to the scene
  53217. * @param container the container holding the elements
  53218. */
  53219. addFromContainer(container: AbstractScene): void;
  53220. /**
  53221. * Removes all the elements in the container from the scene
  53222. * @param container contains the elements to remove
  53223. * @param dispose if the removed element should be disposed (default: false)
  53224. */
  53225. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53226. /**
  53227. * Serializes the component data to the specified json object
  53228. * @param serializationObject The object to serialize to
  53229. */
  53230. serialize(serializationObject: any): void;
  53231. /**
  53232. * Disposes the component and the associated ressources.
  53233. */
  53234. dispose(): void;
  53235. private _draw;
  53236. }
  53237. }
  53238. declare module "babylonjs/LensFlares/index" {
  53239. export * from "babylonjs/LensFlares/lensFlare";
  53240. export * from "babylonjs/LensFlares/lensFlareSystem";
  53241. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53242. }
  53243. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53244. import { Scene } from "babylonjs/scene";
  53245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53246. import { AbstractScene } from "babylonjs/abstractScene";
  53247. /**
  53248. * Defines the shadow generator component responsible to manage any shadow generators
  53249. * in a given scene.
  53250. */
  53251. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53252. /**
  53253. * The component name helpfull to identify the component in the list of scene components.
  53254. */
  53255. readonly name: string;
  53256. /**
  53257. * The scene the component belongs to.
  53258. */
  53259. scene: Scene;
  53260. /**
  53261. * Creates a new instance of the component for the given scene
  53262. * @param scene Defines the scene to register the component in
  53263. */
  53264. constructor(scene: Scene);
  53265. /**
  53266. * Registers the component in a given scene
  53267. */
  53268. register(): void;
  53269. /**
  53270. * Rebuilds the elements related to this component in case of
  53271. * context lost for instance.
  53272. */
  53273. rebuild(): void;
  53274. /**
  53275. * Serializes the component data to the specified json object
  53276. * @param serializationObject The object to serialize to
  53277. */
  53278. serialize(serializationObject: any): void;
  53279. /**
  53280. * Adds all the elements from the container to the scene
  53281. * @param container the container holding the elements
  53282. */
  53283. addFromContainer(container: AbstractScene): void;
  53284. /**
  53285. * Removes all the elements in the container from the scene
  53286. * @param container contains the elements to remove
  53287. * @param dispose if the removed element should be disposed (default: false)
  53288. */
  53289. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53290. /**
  53291. * Rebuilds the elements related to this component in case of
  53292. * context lost for instance.
  53293. */
  53294. dispose(): void;
  53295. private _gatherRenderTargets;
  53296. }
  53297. }
  53298. declare module "babylonjs/Lights/Shadows/index" {
  53299. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53300. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53301. }
  53302. declare module "babylonjs/Lights/pointLight" {
  53303. import { Scene } from "babylonjs/scene";
  53304. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53306. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53307. import { Effect } from "babylonjs/Materials/effect";
  53308. /**
  53309. * A point light is a light defined by an unique point in world space.
  53310. * The light is emitted in every direction from this point.
  53311. * A good example of a point light is a standard light bulb.
  53312. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53313. */
  53314. export class PointLight extends ShadowLight {
  53315. private _shadowAngle;
  53316. /**
  53317. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53318. * This specifies what angle the shadow will use to be created.
  53319. *
  53320. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53321. */
  53322. /**
  53323. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53324. * This specifies what angle the shadow will use to be created.
  53325. *
  53326. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53327. */
  53328. shadowAngle: number;
  53329. /**
  53330. * Gets the direction if it has been set.
  53331. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53332. */
  53333. /**
  53334. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53335. */
  53336. direction: Vector3;
  53337. /**
  53338. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53339. * A PointLight emits the light in every direction.
  53340. * It can cast shadows.
  53341. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53342. * ```javascript
  53343. * var pointLight = new PointLight("pl", camera.position, scene);
  53344. * ```
  53345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53346. * @param name The light friendly name
  53347. * @param position The position of the point light in the scene
  53348. * @param scene The scene the lights belongs to
  53349. */
  53350. constructor(name: string, position: Vector3, scene: Scene);
  53351. /**
  53352. * Returns the string "PointLight"
  53353. * @returns the class name
  53354. */
  53355. getClassName(): string;
  53356. /**
  53357. * Returns the integer 0.
  53358. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53359. */
  53360. getTypeID(): number;
  53361. /**
  53362. * Specifies wether or not the shadowmap should be a cube texture.
  53363. * @returns true if the shadowmap needs to be a cube texture.
  53364. */
  53365. needCube(): boolean;
  53366. /**
  53367. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53368. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53369. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53370. */
  53371. getShadowDirection(faceIndex?: number): Vector3;
  53372. /**
  53373. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53374. * - fov = PI / 2
  53375. * - aspect ratio : 1.0
  53376. * - z-near and far equal to the active camera minZ and maxZ.
  53377. * Returns the PointLight.
  53378. */
  53379. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53380. protected _buildUniformLayout(): void;
  53381. /**
  53382. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53383. * @param effect The effect to update
  53384. * @param lightIndex The index of the light in the effect to update
  53385. * @returns The point light
  53386. */
  53387. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53389. /**
  53390. * Prepares the list of defines specific to the light type.
  53391. * @param defines the list of defines
  53392. * @param lightIndex defines the index of the light for the effect
  53393. */
  53394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53395. }
  53396. }
  53397. declare module "babylonjs/Lights/index" {
  53398. export * from "babylonjs/Lights/light";
  53399. export * from "babylonjs/Lights/shadowLight";
  53400. export * from "babylonjs/Lights/Shadows/index";
  53401. export * from "babylonjs/Lights/directionalLight";
  53402. export * from "babylonjs/Lights/hemisphericLight";
  53403. export * from "babylonjs/Lights/pointLight";
  53404. export * from "babylonjs/Lights/spotLight";
  53405. }
  53406. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53407. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53408. /**
  53409. * Header information of HDR texture files.
  53410. */
  53411. export interface HDRInfo {
  53412. /**
  53413. * The height of the texture in pixels.
  53414. */
  53415. height: number;
  53416. /**
  53417. * The width of the texture in pixels.
  53418. */
  53419. width: number;
  53420. /**
  53421. * The index of the beginning of the data in the binary file.
  53422. */
  53423. dataPosition: number;
  53424. }
  53425. /**
  53426. * This groups tools to convert HDR texture to native colors array.
  53427. */
  53428. export class HDRTools {
  53429. private static Ldexp;
  53430. private static Rgbe2float;
  53431. private static readStringLine;
  53432. /**
  53433. * Reads header information from an RGBE texture stored in a native array.
  53434. * More information on this format are available here:
  53435. * https://en.wikipedia.org/wiki/RGBE_image_format
  53436. *
  53437. * @param uint8array The binary file stored in native array.
  53438. * @return The header information.
  53439. */
  53440. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53441. /**
  53442. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53443. * This RGBE texture needs to store the information as a panorama.
  53444. *
  53445. * More information on this format are available here:
  53446. * https://en.wikipedia.org/wiki/RGBE_image_format
  53447. *
  53448. * @param buffer The binary file stored in an array buffer.
  53449. * @param size The expected size of the extracted cubemap.
  53450. * @return The Cube Map information.
  53451. */
  53452. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53453. /**
  53454. * Returns the pixels data extracted from an RGBE texture.
  53455. * This pixels will be stored left to right up to down in the R G B order in one array.
  53456. *
  53457. * More information on this format are available here:
  53458. * https://en.wikipedia.org/wiki/RGBE_image_format
  53459. *
  53460. * @param uint8array The binary file stored in an array buffer.
  53461. * @param hdrInfo The header information of the file.
  53462. * @return The pixels data in RGB right to left up to down order.
  53463. */
  53464. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53465. private static RGBE_ReadPixels_RLE;
  53466. }
  53467. }
  53468. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53469. import { Nullable } from "babylonjs/types";
  53470. import { Scene } from "babylonjs/scene";
  53471. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53473. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53474. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53475. /**
  53476. * This represents a texture coming from an HDR input.
  53477. *
  53478. * The only supported format is currently panorama picture stored in RGBE format.
  53479. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53480. */
  53481. export class HDRCubeTexture extends BaseTexture {
  53482. private static _facesMapping;
  53483. private _generateHarmonics;
  53484. private _noMipmap;
  53485. private _textureMatrix;
  53486. private _size;
  53487. private _onLoad;
  53488. private _onError;
  53489. /**
  53490. * The texture URL.
  53491. */
  53492. url: string;
  53493. /**
  53494. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53495. */
  53496. coordinatesMode: number;
  53497. protected _isBlocking: boolean;
  53498. /**
  53499. * Sets wether or not the texture is blocking during loading.
  53500. */
  53501. /**
  53502. * Gets wether or not the texture is blocking during loading.
  53503. */
  53504. isBlocking: boolean;
  53505. protected _rotationY: number;
  53506. /**
  53507. * Sets texture matrix rotation angle around Y axis in radians.
  53508. */
  53509. /**
  53510. * Gets texture matrix rotation angle around Y axis radians.
  53511. */
  53512. rotationY: number;
  53513. /**
  53514. * Gets or sets the center of the bounding box associated with the cube texture
  53515. * It must define where the camera used to render the texture was set
  53516. */
  53517. boundingBoxPosition: Vector3;
  53518. private _boundingBoxSize;
  53519. /**
  53520. * Gets or sets the size of the bounding box associated with the cube texture
  53521. * When defined, the cubemap will switch to local mode
  53522. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53523. * @example https://www.babylonjs-playground.com/#RNASML
  53524. */
  53525. boundingBoxSize: Vector3;
  53526. /**
  53527. * Instantiates an HDRTexture from the following parameters.
  53528. *
  53529. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53530. * @param scene The scene the texture will be used in
  53531. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53532. * @param noMipmap Forces to not generate the mipmap if true
  53533. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53534. * @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)
  53535. * @param reserved Reserved flag for internal use.
  53536. */
  53537. 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>);
  53538. /**
  53539. * Get the current class name of the texture useful for serialization or dynamic coding.
  53540. * @returns "HDRCubeTexture"
  53541. */
  53542. getClassName(): string;
  53543. /**
  53544. * Occurs when the file is raw .hdr file.
  53545. */
  53546. private loadTexture;
  53547. clone(): HDRCubeTexture;
  53548. delayLoad(): void;
  53549. /**
  53550. * Get the texture reflection matrix used to rotate/transform the reflection.
  53551. * @returns the reflection matrix
  53552. */
  53553. getReflectionTextureMatrix(): Matrix;
  53554. /**
  53555. * Set the texture reflection matrix used to rotate/transform the reflection.
  53556. * @param value Define the reflection matrix to set
  53557. */
  53558. setReflectionTextureMatrix(value: Matrix): void;
  53559. /**
  53560. * Parses a JSON representation of an HDR Texture in order to create the texture
  53561. * @param parsedTexture Define the JSON representation
  53562. * @param scene Define the scene the texture should be created in
  53563. * @param rootUrl Define the root url in case we need to load relative dependencies
  53564. * @returns the newly created texture after parsing
  53565. */
  53566. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53567. serialize(): any;
  53568. }
  53569. }
  53570. declare module "babylonjs/Physics/physicsEngine" {
  53571. import { Nullable } from "babylonjs/types";
  53572. import { Vector3 } from "babylonjs/Maths/math.vector";
  53573. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53574. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53575. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53576. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53577. /**
  53578. * Class used to control physics engine
  53579. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53580. */
  53581. export class PhysicsEngine implements IPhysicsEngine {
  53582. private _physicsPlugin;
  53583. /**
  53584. * Global value used to control the smallest number supported by the simulation
  53585. */
  53586. static Epsilon: number;
  53587. private _impostors;
  53588. private _joints;
  53589. /**
  53590. * Gets the gravity vector used by the simulation
  53591. */
  53592. gravity: Vector3;
  53593. /**
  53594. * Factory used to create the default physics plugin.
  53595. * @returns The default physics plugin
  53596. */
  53597. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53598. /**
  53599. * Creates a new Physics Engine
  53600. * @param gravity defines the gravity vector used by the simulation
  53601. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53602. */
  53603. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53604. /**
  53605. * Sets the gravity vector used by the simulation
  53606. * @param gravity defines the gravity vector to use
  53607. */
  53608. setGravity(gravity: Vector3): void;
  53609. /**
  53610. * Set the time step of the physics engine.
  53611. * Default is 1/60.
  53612. * To slow it down, enter 1/600 for example.
  53613. * To speed it up, 1/30
  53614. * @param newTimeStep defines the new timestep to apply to this world.
  53615. */
  53616. setTimeStep(newTimeStep?: number): void;
  53617. /**
  53618. * Get the time step of the physics engine.
  53619. * @returns the current time step
  53620. */
  53621. getTimeStep(): number;
  53622. /**
  53623. * Release all resources
  53624. */
  53625. dispose(): void;
  53626. /**
  53627. * Gets the name of the current physics plugin
  53628. * @returns the name of the plugin
  53629. */
  53630. getPhysicsPluginName(): string;
  53631. /**
  53632. * Adding a new impostor for the impostor tracking.
  53633. * This will be done by the impostor itself.
  53634. * @param impostor the impostor to add
  53635. */
  53636. addImpostor(impostor: PhysicsImpostor): void;
  53637. /**
  53638. * Remove an impostor from the engine.
  53639. * This impostor and its mesh will not longer be updated by the physics engine.
  53640. * @param impostor the impostor to remove
  53641. */
  53642. removeImpostor(impostor: PhysicsImpostor): void;
  53643. /**
  53644. * Add a joint to the physics engine
  53645. * @param mainImpostor defines the main impostor to which the joint is added.
  53646. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53647. * @param joint defines the joint that will connect both impostors.
  53648. */
  53649. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53650. /**
  53651. * Removes a joint from the simulation
  53652. * @param mainImpostor defines the impostor used with the joint
  53653. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53654. * @param joint defines the joint to remove
  53655. */
  53656. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53657. /**
  53658. * Called by the scene. No need to call it.
  53659. * @param delta defines the timespam between frames
  53660. */
  53661. _step(delta: number): void;
  53662. /**
  53663. * Gets the current plugin used to run the simulation
  53664. * @returns current plugin
  53665. */
  53666. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53667. /**
  53668. * Gets the list of physic impostors
  53669. * @returns an array of PhysicsImpostor
  53670. */
  53671. getImpostors(): Array<PhysicsImpostor>;
  53672. /**
  53673. * Gets the impostor for a physics enabled object
  53674. * @param object defines the object impersonated by the impostor
  53675. * @returns the PhysicsImpostor or null if not found
  53676. */
  53677. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53678. /**
  53679. * Gets the impostor for a physics body object
  53680. * @param body defines physics body used by the impostor
  53681. * @returns the PhysicsImpostor or null if not found
  53682. */
  53683. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53684. /**
  53685. * Does a raycast in the physics world
  53686. * @param from when should the ray start?
  53687. * @param to when should the ray end?
  53688. * @returns PhysicsRaycastResult
  53689. */
  53690. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53691. }
  53692. }
  53693. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53694. import { Nullable } from "babylonjs/types";
  53695. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53697. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53698. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53699. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53700. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53701. /** @hidden */
  53702. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53703. private _useDeltaForWorldStep;
  53704. world: any;
  53705. name: string;
  53706. private _physicsMaterials;
  53707. private _fixedTimeStep;
  53708. private _cannonRaycastResult;
  53709. private _raycastResult;
  53710. private _physicsBodysToRemoveAfterStep;
  53711. BJSCANNON: any;
  53712. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53713. setGravity(gravity: Vector3): void;
  53714. setTimeStep(timeStep: number): void;
  53715. getTimeStep(): number;
  53716. executeStep(delta: number): void;
  53717. private _removeMarkedPhysicsBodiesFromWorld;
  53718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53719. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53720. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53721. private _processChildMeshes;
  53722. removePhysicsBody(impostor: PhysicsImpostor): void;
  53723. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53725. private _addMaterial;
  53726. private _checkWithEpsilon;
  53727. private _createShape;
  53728. private _createHeightmap;
  53729. private _minus90X;
  53730. private _plus90X;
  53731. private _tmpPosition;
  53732. private _tmpDeltaPosition;
  53733. private _tmpUnityRotation;
  53734. private _updatePhysicsBodyTransformation;
  53735. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53736. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53737. isSupported(): boolean;
  53738. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53739. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53740. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53741. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53742. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53743. getBodyMass(impostor: PhysicsImpostor): number;
  53744. getBodyFriction(impostor: PhysicsImpostor): number;
  53745. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53746. getBodyRestitution(impostor: PhysicsImpostor): number;
  53747. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53748. sleepBody(impostor: PhysicsImpostor): void;
  53749. wakeUpBody(impostor: PhysicsImpostor): void;
  53750. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53751. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53752. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53753. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53754. getRadius(impostor: PhysicsImpostor): number;
  53755. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53756. dispose(): void;
  53757. private _extendNamespace;
  53758. /**
  53759. * Does a raycast in the physics world
  53760. * @param from when should the ray start?
  53761. * @param to when should the ray end?
  53762. * @returns PhysicsRaycastResult
  53763. */
  53764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53765. }
  53766. }
  53767. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53768. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53769. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53770. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53772. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53773. import { Nullable } from "babylonjs/types";
  53774. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53775. /** @hidden */
  53776. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53777. world: any;
  53778. name: string;
  53779. BJSOIMO: any;
  53780. private _raycastResult;
  53781. constructor(iterations?: number, oimoInjection?: any);
  53782. setGravity(gravity: Vector3): void;
  53783. setTimeStep(timeStep: number): void;
  53784. getTimeStep(): number;
  53785. private _tmpImpostorsArray;
  53786. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53787. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53788. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53789. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53790. private _tmpPositionVector;
  53791. removePhysicsBody(impostor: PhysicsImpostor): void;
  53792. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53793. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53794. isSupported(): boolean;
  53795. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53797. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53798. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53799. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53800. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53802. getBodyMass(impostor: PhysicsImpostor): number;
  53803. getBodyFriction(impostor: PhysicsImpostor): number;
  53804. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53805. getBodyRestitution(impostor: PhysicsImpostor): number;
  53806. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53807. sleepBody(impostor: PhysicsImpostor): void;
  53808. wakeUpBody(impostor: PhysicsImpostor): void;
  53809. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53810. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53811. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53812. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53813. getRadius(impostor: PhysicsImpostor): number;
  53814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53815. dispose(): void;
  53816. /**
  53817. * Does a raycast in the physics world
  53818. * @param from when should the ray start?
  53819. * @param to when should the ray end?
  53820. * @returns PhysicsRaycastResult
  53821. */
  53822. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53823. }
  53824. }
  53825. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53826. import { Nullable } from "babylonjs/types";
  53827. import { Scene } from "babylonjs/scene";
  53828. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53829. import { Color4 } from "babylonjs/Maths/math.color";
  53830. import { Mesh } from "babylonjs/Meshes/mesh";
  53831. /**
  53832. * Class containing static functions to help procedurally build meshes
  53833. */
  53834. export class RibbonBuilder {
  53835. /**
  53836. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53837. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53838. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53839. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53840. * * 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
  53841. * * 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
  53842. * * 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
  53843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53846. * * 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
  53847. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53848. * * 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
  53849. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53851. * @param name defines the name of the mesh
  53852. * @param options defines the options used to create the mesh
  53853. * @param scene defines the hosting scene
  53854. * @returns the ribbon mesh
  53855. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53857. */
  53858. static CreateRibbon(name: string, options: {
  53859. pathArray: Vector3[][];
  53860. closeArray?: boolean;
  53861. closePath?: boolean;
  53862. offset?: number;
  53863. updatable?: boolean;
  53864. sideOrientation?: number;
  53865. frontUVs?: Vector4;
  53866. backUVs?: Vector4;
  53867. instance?: Mesh;
  53868. invertUV?: boolean;
  53869. uvs?: Vector2[];
  53870. colors?: Color4[];
  53871. }, scene?: Nullable<Scene>): Mesh;
  53872. }
  53873. }
  53874. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53875. import { Nullable } from "babylonjs/types";
  53876. import { Scene } from "babylonjs/scene";
  53877. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53878. import { Mesh } from "babylonjs/Meshes/mesh";
  53879. /**
  53880. * Class containing static functions to help procedurally build meshes
  53881. */
  53882. export class ShapeBuilder {
  53883. /**
  53884. * 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.
  53885. * * 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.
  53886. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53887. * * 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.
  53888. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53889. * * 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
  53890. * * 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
  53891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53896. * @param name defines the name of the mesh
  53897. * @param options defines the options used to create the mesh
  53898. * @param scene defines the hosting scene
  53899. * @returns the extruded shape mesh
  53900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53902. */
  53903. static ExtrudeShape(name: string, options: {
  53904. shape: Vector3[];
  53905. path: Vector3[];
  53906. scale?: number;
  53907. rotation?: number;
  53908. cap?: number;
  53909. updatable?: boolean;
  53910. sideOrientation?: number;
  53911. frontUVs?: Vector4;
  53912. backUVs?: Vector4;
  53913. instance?: Mesh;
  53914. invertUV?: boolean;
  53915. }, scene?: Nullable<Scene>): Mesh;
  53916. /**
  53917. * Creates an custom extruded shape mesh.
  53918. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53919. * * 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.
  53920. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53921. * * 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
  53922. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53923. * * 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
  53924. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53925. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53926. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53927. * * 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
  53928. * * 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
  53929. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53934. * @param name defines the name of the mesh
  53935. * @param options defines the options used to create the mesh
  53936. * @param scene defines the hosting scene
  53937. * @returns the custom extruded shape mesh
  53938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53939. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53941. */
  53942. static ExtrudeShapeCustom(name: string, options: {
  53943. shape: Vector3[];
  53944. path: Vector3[];
  53945. scaleFunction?: any;
  53946. rotationFunction?: any;
  53947. ribbonCloseArray?: boolean;
  53948. ribbonClosePath?: boolean;
  53949. cap?: number;
  53950. updatable?: boolean;
  53951. sideOrientation?: number;
  53952. frontUVs?: Vector4;
  53953. backUVs?: Vector4;
  53954. instance?: Mesh;
  53955. invertUV?: boolean;
  53956. }, scene?: Nullable<Scene>): Mesh;
  53957. private static _ExtrudeShapeGeneric;
  53958. }
  53959. }
  53960. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53961. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53962. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53963. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53964. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53965. import { Nullable } from "babylonjs/types";
  53966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53967. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53968. /**
  53969. * AmmoJS Physics plugin
  53970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53971. * @see https://github.com/kripken/ammo.js/
  53972. */
  53973. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53974. private _useDeltaForWorldStep;
  53975. /**
  53976. * Reference to the Ammo library
  53977. */
  53978. bjsAMMO: any;
  53979. /**
  53980. * Created ammoJS world which physics bodies are added to
  53981. */
  53982. world: any;
  53983. /**
  53984. * Name of the plugin
  53985. */
  53986. name: string;
  53987. private _timeStep;
  53988. private _fixedTimeStep;
  53989. private _maxSteps;
  53990. private _tmpQuaternion;
  53991. private _tmpAmmoTransform;
  53992. private _tmpAmmoQuaternion;
  53993. private _tmpAmmoConcreteContactResultCallback;
  53994. private _collisionConfiguration;
  53995. private _dispatcher;
  53996. private _overlappingPairCache;
  53997. private _solver;
  53998. private _softBodySolver;
  53999. private _tmpAmmoVectorA;
  54000. private _tmpAmmoVectorB;
  54001. private _tmpAmmoVectorC;
  54002. private _tmpAmmoVectorD;
  54003. private _tmpContactCallbackResult;
  54004. private _tmpAmmoVectorRCA;
  54005. private _tmpAmmoVectorRCB;
  54006. private _raycastResult;
  54007. private static readonly DISABLE_COLLISION_FLAG;
  54008. private static readonly KINEMATIC_FLAG;
  54009. private static readonly DISABLE_DEACTIVATION_FLAG;
  54010. /**
  54011. * Initializes the ammoJS plugin
  54012. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54013. * @param ammoInjection can be used to inject your own ammo reference
  54014. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54015. */
  54016. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54017. /**
  54018. * Sets the gravity of the physics world (m/(s^2))
  54019. * @param gravity Gravity to set
  54020. */
  54021. setGravity(gravity: Vector3): void;
  54022. /**
  54023. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54024. * @param timeStep timestep to use in seconds
  54025. */
  54026. setTimeStep(timeStep: number): void;
  54027. /**
  54028. * 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)
  54029. * @param fixedTimeStep fixedTimeStep to use in seconds
  54030. */
  54031. setFixedTimeStep(fixedTimeStep: number): void;
  54032. /**
  54033. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54034. * @param maxSteps the maximum number of steps by the physics engine per frame
  54035. */
  54036. setMaxSteps(maxSteps: number): void;
  54037. /**
  54038. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54039. * @returns the current timestep in seconds
  54040. */
  54041. getTimeStep(): number;
  54042. private _isImpostorInContact;
  54043. private _isImpostorPairInContact;
  54044. private _stepSimulation;
  54045. /**
  54046. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54047. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54048. * After the step the babylon meshes are set to the position of the physics imposters
  54049. * @param delta amount of time to step forward
  54050. * @param impostors array of imposters to update before/after the step
  54051. */
  54052. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54053. /**
  54054. * Update babylon mesh to match physics world object
  54055. * @param impostor imposter to match
  54056. */
  54057. private _afterSoftStep;
  54058. /**
  54059. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54060. * @param impostor imposter to match
  54061. */
  54062. private _ropeStep;
  54063. /**
  54064. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54065. * @param impostor imposter to match
  54066. */
  54067. private _softbodyOrClothStep;
  54068. private _tmpVector;
  54069. private _tmpMatrix;
  54070. /**
  54071. * Applies an impulse on the imposter
  54072. * @param impostor imposter to apply impulse to
  54073. * @param force amount of force to be applied to the imposter
  54074. * @param contactPoint the location to apply the impulse on the imposter
  54075. */
  54076. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54077. /**
  54078. * Applies a force on the imposter
  54079. * @param impostor imposter to apply force
  54080. * @param force amount of force to be applied to the imposter
  54081. * @param contactPoint the location to apply the force on the imposter
  54082. */
  54083. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54084. /**
  54085. * Creates a physics body using the plugin
  54086. * @param impostor the imposter to create the physics body on
  54087. */
  54088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54089. /**
  54090. * Removes the physics body from the imposter and disposes of the body's memory
  54091. * @param impostor imposter to remove the physics body from
  54092. */
  54093. removePhysicsBody(impostor: PhysicsImpostor): void;
  54094. /**
  54095. * Generates a joint
  54096. * @param impostorJoint the imposter joint to create the joint with
  54097. */
  54098. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54099. /**
  54100. * Removes a joint
  54101. * @param impostorJoint the imposter joint to remove the joint from
  54102. */
  54103. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54104. private _addMeshVerts;
  54105. /**
  54106. * Initialise the soft body vertices to match its object's (mesh) vertices
  54107. * Softbody vertices (nodes) are in world space and to match this
  54108. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54109. * @param impostor to create the softbody for
  54110. */
  54111. private _softVertexData;
  54112. /**
  54113. * Create an impostor's soft body
  54114. * @param impostor to create the softbody for
  54115. */
  54116. private _createSoftbody;
  54117. /**
  54118. * Create cloth for an impostor
  54119. * @param impostor to create the softbody for
  54120. */
  54121. private _createCloth;
  54122. /**
  54123. * Create rope for an impostor
  54124. * @param impostor to create the softbody for
  54125. */
  54126. private _createRope;
  54127. private _addHullVerts;
  54128. private _createShape;
  54129. /**
  54130. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54131. * @param impostor imposter containing the physics body and babylon object
  54132. */
  54133. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54134. /**
  54135. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54136. * @param impostor imposter containing the physics body and babylon object
  54137. * @param newPosition new position
  54138. * @param newRotation new rotation
  54139. */
  54140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54141. /**
  54142. * If this plugin is supported
  54143. * @returns true if its supported
  54144. */
  54145. isSupported(): boolean;
  54146. /**
  54147. * Sets the linear velocity of the physics body
  54148. * @param impostor imposter to set the velocity on
  54149. * @param velocity velocity to set
  54150. */
  54151. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54152. /**
  54153. * Sets the angular velocity of the physics body
  54154. * @param impostor imposter to set the velocity on
  54155. * @param velocity velocity to set
  54156. */
  54157. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54158. /**
  54159. * gets the linear velocity
  54160. * @param impostor imposter to get linear velocity from
  54161. * @returns linear velocity
  54162. */
  54163. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54164. /**
  54165. * gets the angular velocity
  54166. * @param impostor imposter to get angular velocity from
  54167. * @returns angular velocity
  54168. */
  54169. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54170. /**
  54171. * Sets the mass of physics body
  54172. * @param impostor imposter to set the mass on
  54173. * @param mass mass to set
  54174. */
  54175. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54176. /**
  54177. * Gets the mass of the physics body
  54178. * @param impostor imposter to get the mass from
  54179. * @returns mass
  54180. */
  54181. getBodyMass(impostor: PhysicsImpostor): number;
  54182. /**
  54183. * Gets friction of the impostor
  54184. * @param impostor impostor to get friction from
  54185. * @returns friction value
  54186. */
  54187. getBodyFriction(impostor: PhysicsImpostor): number;
  54188. /**
  54189. * Sets friction of the impostor
  54190. * @param impostor impostor to set friction on
  54191. * @param friction friction value
  54192. */
  54193. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54194. /**
  54195. * Gets restitution of the impostor
  54196. * @param impostor impostor to get restitution from
  54197. * @returns restitution value
  54198. */
  54199. getBodyRestitution(impostor: PhysicsImpostor): number;
  54200. /**
  54201. * Sets resitution of the impostor
  54202. * @param impostor impostor to set resitution on
  54203. * @param restitution resitution value
  54204. */
  54205. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54206. /**
  54207. * Gets pressure inside the impostor
  54208. * @param impostor impostor to get pressure from
  54209. * @returns pressure value
  54210. */
  54211. getBodyPressure(impostor: PhysicsImpostor): number;
  54212. /**
  54213. * Sets pressure inside a soft body impostor
  54214. * Cloth and rope must remain 0 pressure
  54215. * @param impostor impostor to set pressure on
  54216. * @param pressure pressure value
  54217. */
  54218. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54219. /**
  54220. * Gets stiffness of the impostor
  54221. * @param impostor impostor to get stiffness from
  54222. * @returns pressure value
  54223. */
  54224. getBodyStiffness(impostor: PhysicsImpostor): number;
  54225. /**
  54226. * Sets stiffness of the impostor
  54227. * @param impostor impostor to set stiffness on
  54228. * @param stiffness stiffness value from 0 to 1
  54229. */
  54230. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54231. /**
  54232. * Gets velocityIterations of the impostor
  54233. * @param impostor impostor to get velocity iterations from
  54234. * @returns velocityIterations value
  54235. */
  54236. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54237. /**
  54238. * Sets velocityIterations of the impostor
  54239. * @param impostor impostor to set velocity iterations on
  54240. * @param velocityIterations velocityIterations value
  54241. */
  54242. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54243. /**
  54244. * Gets positionIterations of the impostor
  54245. * @param impostor impostor to get position iterations from
  54246. * @returns positionIterations value
  54247. */
  54248. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54249. /**
  54250. * Sets positionIterations of the impostor
  54251. * @param impostor impostor to set position on
  54252. * @param positionIterations positionIterations value
  54253. */
  54254. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54255. /**
  54256. * Append an anchor to a cloth object
  54257. * @param impostor is the cloth impostor to add anchor to
  54258. * @param otherImpostor is the rigid impostor to anchor to
  54259. * @param width ratio across width from 0 to 1
  54260. * @param height ratio up height from 0 to 1
  54261. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54262. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54263. */
  54264. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54265. /**
  54266. * Append an hook to a rope object
  54267. * @param impostor is the rope impostor to add hook to
  54268. * @param otherImpostor is the rigid impostor to hook to
  54269. * @param length ratio along the rope from 0 to 1
  54270. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54271. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54272. */
  54273. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54274. /**
  54275. * Sleeps the physics body and stops it from being active
  54276. * @param impostor impostor to sleep
  54277. */
  54278. sleepBody(impostor: PhysicsImpostor): void;
  54279. /**
  54280. * Activates the physics body
  54281. * @param impostor impostor to activate
  54282. */
  54283. wakeUpBody(impostor: PhysicsImpostor): void;
  54284. /**
  54285. * Updates the distance parameters of the joint
  54286. * @param joint joint to update
  54287. * @param maxDistance maximum distance of the joint
  54288. * @param minDistance minimum distance of the joint
  54289. */
  54290. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54291. /**
  54292. * Sets a motor on the joint
  54293. * @param joint joint to set motor on
  54294. * @param speed speed of the motor
  54295. * @param maxForce maximum force of the motor
  54296. * @param motorIndex index of the motor
  54297. */
  54298. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54299. /**
  54300. * Sets the motors limit
  54301. * @param joint joint to set limit on
  54302. * @param upperLimit upper limit
  54303. * @param lowerLimit lower limit
  54304. */
  54305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54306. /**
  54307. * Syncs the position and rotation of a mesh with the impostor
  54308. * @param mesh mesh to sync
  54309. * @param impostor impostor to update the mesh with
  54310. */
  54311. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54312. /**
  54313. * Gets the radius of the impostor
  54314. * @param impostor impostor to get radius from
  54315. * @returns the radius
  54316. */
  54317. getRadius(impostor: PhysicsImpostor): number;
  54318. /**
  54319. * Gets the box size of the impostor
  54320. * @param impostor impostor to get box size from
  54321. * @param result the resulting box size
  54322. */
  54323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54324. /**
  54325. * Disposes of the impostor
  54326. */
  54327. dispose(): void;
  54328. /**
  54329. * Does a raycast in the physics world
  54330. * @param from when should the ray start?
  54331. * @param to when should the ray end?
  54332. * @returns PhysicsRaycastResult
  54333. */
  54334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54335. }
  54336. }
  54337. declare module "babylonjs/Probes/reflectionProbe" {
  54338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54339. import { Vector3 } from "babylonjs/Maths/math.vector";
  54340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54341. import { Nullable } from "babylonjs/types";
  54342. import { Scene } from "babylonjs/scene";
  54343. module "babylonjs/abstractScene" {
  54344. interface AbstractScene {
  54345. /**
  54346. * The list of reflection probes added to the scene
  54347. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54348. */
  54349. reflectionProbes: Array<ReflectionProbe>;
  54350. /**
  54351. * Removes the given reflection probe from this scene.
  54352. * @param toRemove The reflection probe to remove
  54353. * @returns The index of the removed reflection probe
  54354. */
  54355. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54356. /**
  54357. * Adds the given reflection probe to this scene.
  54358. * @param newReflectionProbe The reflection probe to add
  54359. */
  54360. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54361. }
  54362. }
  54363. /**
  54364. * Class used to generate realtime reflection / refraction cube textures
  54365. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54366. */
  54367. export class ReflectionProbe {
  54368. /** defines the name of the probe */
  54369. name: string;
  54370. private _scene;
  54371. private _renderTargetTexture;
  54372. private _projectionMatrix;
  54373. private _viewMatrix;
  54374. private _target;
  54375. private _add;
  54376. private _attachedMesh;
  54377. private _invertYAxis;
  54378. /** Gets or sets probe position (center of the cube map) */
  54379. position: Vector3;
  54380. /**
  54381. * Creates a new reflection probe
  54382. * @param name defines the name of the probe
  54383. * @param size defines the texture resolution (for each face)
  54384. * @param scene defines the hosting scene
  54385. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54386. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54387. */
  54388. constructor(
  54389. /** defines the name of the probe */
  54390. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54391. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54392. samples: number;
  54393. /** Gets or sets the refresh rate to use (on every frame by default) */
  54394. refreshRate: number;
  54395. /**
  54396. * Gets the hosting scene
  54397. * @returns a Scene
  54398. */
  54399. getScene(): Scene;
  54400. /** Gets the internal CubeTexture used to render to */
  54401. readonly cubeTexture: RenderTargetTexture;
  54402. /** Gets the list of meshes to render */
  54403. readonly renderList: Nullable<AbstractMesh[]>;
  54404. /**
  54405. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54406. * @param mesh defines the mesh to attach to
  54407. */
  54408. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54409. /**
  54410. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54411. * @param renderingGroupId The rendering group id corresponding to its index
  54412. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54413. */
  54414. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54415. /**
  54416. * Clean all associated resources
  54417. */
  54418. dispose(): void;
  54419. /**
  54420. * Converts the reflection probe information to a readable string for debug purpose.
  54421. * @param fullDetails Supports for multiple levels of logging within scene loading
  54422. * @returns the human readable reflection probe info
  54423. */
  54424. toString(fullDetails?: boolean): string;
  54425. /**
  54426. * Get the class name of the relfection probe.
  54427. * @returns "ReflectionProbe"
  54428. */
  54429. getClassName(): string;
  54430. /**
  54431. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54432. * @returns The JSON representation of the texture
  54433. */
  54434. serialize(): any;
  54435. /**
  54436. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54437. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54438. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54439. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54440. * @returns The parsed reflection probe if successful
  54441. */
  54442. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54443. }
  54444. }
  54445. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54446. /** @hidden */
  54447. export var _BabylonLoaderRegistered: boolean;
  54448. /**
  54449. * Helps setting up some configuration for the babylon file loader.
  54450. */
  54451. export class BabylonFileLoaderConfiguration {
  54452. /**
  54453. * The loader does not allow injecting custom physix engine into the plugins.
  54454. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54455. * So you could set this variable to your engine import to make it work.
  54456. */
  54457. static LoaderInjectedPhysicsEngine: any;
  54458. }
  54459. }
  54460. declare module "babylonjs/Loading/Plugins/index" {
  54461. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54462. }
  54463. declare module "babylonjs/Loading/index" {
  54464. export * from "babylonjs/Loading/loadingScreen";
  54465. export * from "babylonjs/Loading/Plugins/index";
  54466. export * from "babylonjs/Loading/sceneLoader";
  54467. export * from "babylonjs/Loading/sceneLoaderFlags";
  54468. }
  54469. declare module "babylonjs/Materials/Background/index" {
  54470. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54471. }
  54472. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54473. import { Scene } from "babylonjs/scene";
  54474. import { Color3 } from "babylonjs/Maths/math.color";
  54475. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54477. /**
  54478. * The Physically based simple base material of BJS.
  54479. *
  54480. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54481. * It is used as the base class for both the specGloss and metalRough conventions.
  54482. */
  54483. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54484. /**
  54485. * Number of Simultaneous lights allowed on the material.
  54486. */
  54487. maxSimultaneousLights: number;
  54488. /**
  54489. * If sets to true, disables all the lights affecting the material.
  54490. */
  54491. disableLighting: boolean;
  54492. /**
  54493. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54494. */
  54495. environmentTexture: BaseTexture;
  54496. /**
  54497. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54498. */
  54499. invertNormalMapX: boolean;
  54500. /**
  54501. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54502. */
  54503. invertNormalMapY: boolean;
  54504. /**
  54505. * Normal map used in the model.
  54506. */
  54507. normalTexture: BaseTexture;
  54508. /**
  54509. * Emissivie color used to self-illuminate the model.
  54510. */
  54511. emissiveColor: Color3;
  54512. /**
  54513. * Emissivie texture used to self-illuminate the model.
  54514. */
  54515. emissiveTexture: BaseTexture;
  54516. /**
  54517. * Occlusion Channel Strenght.
  54518. */
  54519. occlusionStrength: number;
  54520. /**
  54521. * Occlusion Texture of the material (adding extra occlusion effects).
  54522. */
  54523. occlusionTexture: BaseTexture;
  54524. /**
  54525. * Defines the alpha limits in alpha test mode.
  54526. */
  54527. alphaCutOff: number;
  54528. /**
  54529. * Gets the current double sided mode.
  54530. */
  54531. /**
  54532. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54533. */
  54534. doubleSided: boolean;
  54535. /**
  54536. * Stores the pre-calculated light information of a mesh in a texture.
  54537. */
  54538. lightmapTexture: BaseTexture;
  54539. /**
  54540. * If true, the light map contains occlusion information instead of lighting info.
  54541. */
  54542. useLightmapAsShadowmap: boolean;
  54543. /**
  54544. * Instantiates a new PBRMaterial instance.
  54545. *
  54546. * @param name The material name
  54547. * @param scene The scene the material will be use in.
  54548. */
  54549. constructor(name: string, scene: Scene);
  54550. getClassName(): string;
  54551. }
  54552. }
  54553. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54554. import { Scene } from "babylonjs/scene";
  54555. import { Color3 } from "babylonjs/Maths/math.color";
  54556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54557. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54558. /**
  54559. * The PBR material of BJS following the metal roughness convention.
  54560. *
  54561. * This fits to the PBR convention in the GLTF definition:
  54562. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54563. */
  54564. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54565. /**
  54566. * The base color has two different interpretations depending on the value of metalness.
  54567. * When the material is a metal, the base color is the specific measured reflectance value
  54568. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54569. * of the material.
  54570. */
  54571. baseColor: Color3;
  54572. /**
  54573. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54574. * well as opacity information in the alpha channel.
  54575. */
  54576. baseTexture: BaseTexture;
  54577. /**
  54578. * Specifies the metallic scalar value of the material.
  54579. * Can also be used to scale the metalness values of the metallic texture.
  54580. */
  54581. metallic: number;
  54582. /**
  54583. * Specifies the roughness scalar value of the material.
  54584. * Can also be used to scale the roughness values of the metallic texture.
  54585. */
  54586. roughness: number;
  54587. /**
  54588. * Texture containing both the metallic value in the B channel and the
  54589. * roughness value in the G channel to keep better precision.
  54590. */
  54591. metallicRoughnessTexture: BaseTexture;
  54592. /**
  54593. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54594. *
  54595. * @param name The material name
  54596. * @param scene The scene the material will be use in.
  54597. */
  54598. constructor(name: string, scene: Scene);
  54599. /**
  54600. * Return the currrent class name of the material.
  54601. */
  54602. getClassName(): string;
  54603. /**
  54604. * Makes a duplicate of the current material.
  54605. * @param name - name to use for the new material.
  54606. */
  54607. clone(name: string): PBRMetallicRoughnessMaterial;
  54608. /**
  54609. * Serialize the material to a parsable JSON object.
  54610. */
  54611. serialize(): any;
  54612. /**
  54613. * Parses a JSON object correponding to the serialize function.
  54614. */
  54615. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54616. }
  54617. }
  54618. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54619. import { Scene } from "babylonjs/scene";
  54620. import { Color3 } from "babylonjs/Maths/math.color";
  54621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54622. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54623. /**
  54624. * The PBR material of BJS following the specular glossiness convention.
  54625. *
  54626. * This fits to the PBR convention in the GLTF definition:
  54627. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54628. */
  54629. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54630. /**
  54631. * Specifies the diffuse color of the material.
  54632. */
  54633. diffuseColor: Color3;
  54634. /**
  54635. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54636. * channel.
  54637. */
  54638. diffuseTexture: BaseTexture;
  54639. /**
  54640. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54641. */
  54642. specularColor: Color3;
  54643. /**
  54644. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54645. */
  54646. glossiness: number;
  54647. /**
  54648. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54649. */
  54650. specularGlossinessTexture: BaseTexture;
  54651. /**
  54652. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54653. *
  54654. * @param name The material name
  54655. * @param scene The scene the material will be use in.
  54656. */
  54657. constructor(name: string, scene: Scene);
  54658. /**
  54659. * Return the currrent class name of the material.
  54660. */
  54661. getClassName(): string;
  54662. /**
  54663. * Makes a duplicate of the current material.
  54664. * @param name - name to use for the new material.
  54665. */
  54666. clone(name: string): PBRSpecularGlossinessMaterial;
  54667. /**
  54668. * Serialize the material to a parsable JSON object.
  54669. */
  54670. serialize(): any;
  54671. /**
  54672. * Parses a JSON object correponding to the serialize function.
  54673. */
  54674. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54675. }
  54676. }
  54677. declare module "babylonjs/Materials/PBR/index" {
  54678. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54679. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54680. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54681. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54682. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54683. }
  54684. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54685. import { Nullable } from "babylonjs/types";
  54686. import { Scene } from "babylonjs/scene";
  54687. import { Matrix } from "babylonjs/Maths/math.vector";
  54688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54689. /**
  54690. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54691. * It can help converting any input color in a desired output one. This can then be used to create effects
  54692. * from sepia, black and white to sixties or futuristic rendering...
  54693. *
  54694. * The only supported format is currently 3dl.
  54695. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54696. */
  54697. export class ColorGradingTexture extends BaseTexture {
  54698. /**
  54699. * The current texture matrix. (will always be identity in color grading texture)
  54700. */
  54701. private _textureMatrix;
  54702. /**
  54703. * The texture URL.
  54704. */
  54705. url: string;
  54706. /**
  54707. * Empty line regex stored for GC.
  54708. */
  54709. private static _noneEmptyLineRegex;
  54710. private _engine;
  54711. /**
  54712. * Instantiates a ColorGradingTexture from the following parameters.
  54713. *
  54714. * @param url The location of the color gradind data (currently only supporting 3dl)
  54715. * @param scene The scene the texture will be used in
  54716. */
  54717. constructor(url: string, scene: Scene);
  54718. /**
  54719. * Returns the texture matrix used in most of the material.
  54720. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54721. */
  54722. getTextureMatrix(): Matrix;
  54723. /**
  54724. * Occurs when the file being loaded is a .3dl LUT file.
  54725. */
  54726. private load3dlTexture;
  54727. /**
  54728. * Starts the loading process of the texture.
  54729. */
  54730. private loadTexture;
  54731. /**
  54732. * Clones the color gradind texture.
  54733. */
  54734. clone(): ColorGradingTexture;
  54735. /**
  54736. * Called during delayed load for textures.
  54737. */
  54738. delayLoad(): void;
  54739. /**
  54740. * Parses a color grading texture serialized by Babylon.
  54741. * @param parsedTexture The texture information being parsedTexture
  54742. * @param scene The scene to load the texture in
  54743. * @param rootUrl The root url of the data assets to load
  54744. * @return A color gradind texture
  54745. */
  54746. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54747. /**
  54748. * Serializes the LUT texture to json format.
  54749. */
  54750. serialize(): any;
  54751. }
  54752. }
  54753. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54755. import { Scene } from "babylonjs/scene";
  54756. import { Nullable } from "babylonjs/types";
  54757. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54758. /**
  54759. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54760. */
  54761. export class EquiRectangularCubeTexture extends BaseTexture {
  54762. /** The six faces of the cube. */
  54763. private static _FacesMapping;
  54764. private _noMipmap;
  54765. private _onLoad;
  54766. private _onError;
  54767. /** The size of the cubemap. */
  54768. private _size;
  54769. /** The buffer of the image. */
  54770. private _buffer;
  54771. /** The width of the input image. */
  54772. private _width;
  54773. /** The height of the input image. */
  54774. private _height;
  54775. /** The URL to the image. */
  54776. url: string;
  54777. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54778. coordinatesMode: number;
  54779. /**
  54780. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54781. * @param url The location of the image
  54782. * @param scene The scene the texture will be used in
  54783. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54784. * @param noMipmap Forces to not generate the mipmap if true
  54785. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54786. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54787. * @param onLoad — defines a callback called when texture is loaded
  54788. * @param onError — defines a callback called if there is an error
  54789. */
  54790. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54791. /**
  54792. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54793. */
  54794. private loadImage;
  54795. /**
  54796. * Convert the image buffer into a cubemap and create a CubeTexture.
  54797. */
  54798. private loadTexture;
  54799. /**
  54800. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54801. * @param buffer The ArrayBuffer that should be converted.
  54802. * @returns The buffer as Float32Array.
  54803. */
  54804. private getFloat32ArrayFromArrayBuffer;
  54805. /**
  54806. * Get the current class name of the texture useful for serialization or dynamic coding.
  54807. * @returns "EquiRectangularCubeTexture"
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54812. * @returns A clone of the current EquiRectangularCubeTexture.
  54813. */
  54814. clone(): EquiRectangularCubeTexture;
  54815. }
  54816. }
  54817. declare module "babylonjs/Misc/tga" {
  54818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54819. /**
  54820. * Based on jsTGALoader - Javascript loader for TGA file
  54821. * By Vincent Thibault
  54822. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54823. */
  54824. export class TGATools {
  54825. private static _TYPE_INDEXED;
  54826. private static _TYPE_RGB;
  54827. private static _TYPE_GREY;
  54828. private static _TYPE_RLE_INDEXED;
  54829. private static _TYPE_RLE_RGB;
  54830. private static _TYPE_RLE_GREY;
  54831. private static _ORIGIN_MASK;
  54832. private static _ORIGIN_SHIFT;
  54833. private static _ORIGIN_BL;
  54834. private static _ORIGIN_BR;
  54835. private static _ORIGIN_UL;
  54836. private static _ORIGIN_UR;
  54837. /**
  54838. * Gets the header of a TGA file
  54839. * @param data defines the TGA data
  54840. * @returns the header
  54841. */
  54842. static GetTGAHeader(data: Uint8Array): any;
  54843. /**
  54844. * Uploads TGA content to a Babylon Texture
  54845. * @hidden
  54846. */
  54847. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54848. /** @hidden */
  54849. 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;
  54850. /** @hidden */
  54851. 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;
  54852. /** @hidden */
  54853. 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;
  54854. /** @hidden */
  54855. 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;
  54856. /** @hidden */
  54857. 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;
  54858. /** @hidden */
  54859. 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;
  54860. }
  54861. }
  54862. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54863. import { Nullable } from "babylonjs/types";
  54864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54865. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54866. /**
  54867. * Implementation of the TGA Texture Loader.
  54868. * @hidden
  54869. */
  54870. export class _TGATextureLoader implements IInternalTextureLoader {
  54871. /**
  54872. * Defines wether the loader supports cascade loading the different faces.
  54873. */
  54874. readonly supportCascades: boolean;
  54875. /**
  54876. * This returns if the loader support the current file information.
  54877. * @param extension defines the file extension of the file being loaded
  54878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54879. * @param fallback defines the fallback internal texture if any
  54880. * @param isBase64 defines whether the texture is encoded as a base64
  54881. * @param isBuffer defines whether the texture data are stored as a buffer
  54882. * @returns true if the loader can load the specified file
  54883. */
  54884. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54885. /**
  54886. * Transform the url before loading if required.
  54887. * @param rootUrl the url of the texture
  54888. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54889. * @returns the transformed texture
  54890. */
  54891. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54892. /**
  54893. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54894. * @param rootUrl the url of the texture
  54895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54896. * @returns the fallback texture
  54897. */
  54898. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54899. /**
  54900. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54901. * @param data contains the texture data
  54902. * @param texture defines the BabylonJS internal texture
  54903. * @param createPolynomials will be true if polynomials have been requested
  54904. * @param onLoad defines the callback to trigger once the texture is ready
  54905. * @param onError defines the callback to trigger in case of error
  54906. */
  54907. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54908. /**
  54909. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54910. * @param data contains the texture data
  54911. * @param texture defines the BabylonJS internal texture
  54912. * @param callback defines the method to call once ready to upload
  54913. */
  54914. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54915. }
  54916. }
  54917. declare module "babylonjs/Misc/basis" {
  54918. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54919. /**
  54920. * Info about the .basis files
  54921. */
  54922. class BasisFileInfo {
  54923. /**
  54924. * If the file has alpha
  54925. */
  54926. hasAlpha: boolean;
  54927. /**
  54928. * Info about each image of the basis file
  54929. */
  54930. images: Array<{
  54931. levels: Array<{
  54932. width: number;
  54933. height: number;
  54934. transcodedPixels: ArrayBufferView;
  54935. }>;
  54936. }>;
  54937. }
  54938. /**
  54939. * Result of transcoding a basis file
  54940. */
  54941. class TranscodeResult {
  54942. /**
  54943. * Info about the .basis file
  54944. */
  54945. fileInfo: BasisFileInfo;
  54946. /**
  54947. * Format to use when loading the file
  54948. */
  54949. format: number;
  54950. }
  54951. /**
  54952. * Configuration options for the Basis transcoder
  54953. */
  54954. export class BasisTranscodeConfiguration {
  54955. /**
  54956. * Supported compression formats used to determine the supported output format of the transcoder
  54957. */
  54958. supportedCompressionFormats?: {
  54959. /**
  54960. * etc1 compression format
  54961. */
  54962. etc1?: boolean;
  54963. /**
  54964. * s3tc compression format
  54965. */
  54966. s3tc?: boolean;
  54967. /**
  54968. * pvrtc compression format
  54969. */
  54970. pvrtc?: boolean;
  54971. /**
  54972. * etc2 compression format
  54973. */
  54974. etc2?: boolean;
  54975. };
  54976. /**
  54977. * If mipmap levels should be loaded for transcoded images (Default: true)
  54978. */
  54979. loadMipmapLevels?: boolean;
  54980. /**
  54981. * Index of a single image to load (Default: all images)
  54982. */
  54983. loadSingleImage?: number;
  54984. }
  54985. /**
  54986. * Used to load .Basis files
  54987. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54988. */
  54989. export class BasisTools {
  54990. private static _IgnoreSupportedFormats;
  54991. /**
  54992. * URL to use when loading the basis transcoder
  54993. */
  54994. static JSModuleURL: string;
  54995. /**
  54996. * URL to use when loading the wasm module for the transcoder
  54997. */
  54998. static WasmModuleURL: string;
  54999. /**
  55000. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55001. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55002. * @returns internal format corresponding to the Basis format
  55003. */
  55004. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55005. private static _WorkerPromise;
  55006. private static _Worker;
  55007. private static _actionId;
  55008. private static _CreateWorkerAsync;
  55009. /**
  55010. * Transcodes a loaded image file to compressed pixel data
  55011. * @param imageData image data to transcode
  55012. * @param config configuration options for the transcoding
  55013. * @returns a promise resulting in the transcoded image
  55014. */
  55015. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55016. /**
  55017. * Loads a texture from the transcode result
  55018. * @param texture texture load to
  55019. * @param transcodeResult the result of transcoding the basis file to load from
  55020. */
  55021. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55022. }
  55023. }
  55024. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55025. import { Nullable } from "babylonjs/types";
  55026. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55027. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55028. /**
  55029. * Loader for .basis file format
  55030. */
  55031. export class _BasisTextureLoader implements IInternalTextureLoader {
  55032. /**
  55033. * Defines whether the loader supports cascade loading the different faces.
  55034. */
  55035. readonly supportCascades: boolean;
  55036. /**
  55037. * This returns if the loader support the current file information.
  55038. * @param extension defines the file extension of the file being loaded
  55039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55040. * @param fallback defines the fallback internal texture if any
  55041. * @param isBase64 defines whether the texture is encoded as a base64
  55042. * @param isBuffer defines whether the texture data are stored as a buffer
  55043. * @returns true if the loader can load the specified file
  55044. */
  55045. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55046. /**
  55047. * Transform the url before loading if required.
  55048. * @param rootUrl the url of the texture
  55049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55050. * @returns the transformed texture
  55051. */
  55052. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55053. /**
  55054. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55055. * @param rootUrl the url of the texture
  55056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55057. * @returns the fallback texture
  55058. */
  55059. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55060. /**
  55061. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55062. * @param data contains the texture data
  55063. * @param texture defines the BabylonJS internal texture
  55064. * @param createPolynomials will be true if polynomials have been requested
  55065. * @param onLoad defines the callback to trigger once the texture is ready
  55066. * @param onError defines the callback to trigger in case of error
  55067. */
  55068. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55069. /**
  55070. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55071. * @param data contains the texture data
  55072. * @param texture defines the BabylonJS internal texture
  55073. * @param callback defines the method to call once ready to upload
  55074. */
  55075. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55076. }
  55077. }
  55078. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55079. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55080. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55081. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55082. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55083. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55084. }
  55085. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55086. import { Scene } from "babylonjs/scene";
  55087. import { Texture } from "babylonjs/Materials/Textures/texture";
  55088. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55089. /**
  55090. * 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.
  55091. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55092. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55093. */
  55094. export class CustomProceduralTexture extends ProceduralTexture {
  55095. private _animate;
  55096. private _time;
  55097. private _config;
  55098. private _texturePath;
  55099. /**
  55100. * Instantiates a new Custom Procedural Texture.
  55101. * 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.
  55102. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55104. * @param name Define the name of the texture
  55105. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55106. * @param size Define the size of the texture to create
  55107. * @param scene Define the scene the texture belongs to
  55108. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55109. * @param generateMipMaps Define if the texture should creates mip maps or not
  55110. */
  55111. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55112. private _loadJson;
  55113. /**
  55114. * Is the texture ready to be used ? (rendered at least once)
  55115. * @returns true if ready, otherwise, false.
  55116. */
  55117. isReady(): boolean;
  55118. /**
  55119. * Render the texture to its associated render target.
  55120. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55121. */
  55122. render(useCameraPostProcess?: boolean): void;
  55123. /**
  55124. * Update the list of dependant textures samplers in the shader.
  55125. */
  55126. updateTextures(): void;
  55127. /**
  55128. * Update the uniform values of the procedural texture in the shader.
  55129. */
  55130. updateShaderUniforms(): void;
  55131. /**
  55132. * Define if the texture animates or not.
  55133. */
  55134. animate: boolean;
  55135. }
  55136. }
  55137. declare module "babylonjs/Shaders/noise.fragment" {
  55138. /** @hidden */
  55139. export var noisePixelShader: {
  55140. name: string;
  55141. shader: string;
  55142. };
  55143. }
  55144. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55145. import { Nullable } from "babylonjs/types";
  55146. import { Scene } from "babylonjs/scene";
  55147. import { Texture } from "babylonjs/Materials/Textures/texture";
  55148. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55149. import "babylonjs/Shaders/noise.fragment";
  55150. /**
  55151. * Class used to generate noise procedural textures
  55152. */
  55153. export class NoiseProceduralTexture extends ProceduralTexture {
  55154. private _time;
  55155. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55156. brightness: number;
  55157. /** Defines the number of octaves to process */
  55158. octaves: number;
  55159. /** Defines the level of persistence (0.8 by default) */
  55160. persistence: number;
  55161. /** Gets or sets animation speed factor (default is 1) */
  55162. animationSpeedFactor: number;
  55163. /**
  55164. * Creates a new NoiseProceduralTexture
  55165. * @param name defines the name fo the texture
  55166. * @param size defines the size of the texture (default is 256)
  55167. * @param scene defines the hosting scene
  55168. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55169. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55170. */
  55171. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55172. private _updateShaderUniforms;
  55173. protected _getDefines(): string;
  55174. /** Generate the current state of the procedural texture */
  55175. render(useCameraPostProcess?: boolean): void;
  55176. /**
  55177. * Serializes this noise procedural texture
  55178. * @returns a serialized noise procedural texture object
  55179. */
  55180. serialize(): any;
  55181. /**
  55182. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55183. * @param parsedTexture defines parsed texture data
  55184. * @param scene defines the current scene
  55185. * @param rootUrl defines the root URL containing noise procedural texture information
  55186. * @returns a parsed NoiseProceduralTexture
  55187. */
  55188. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55189. }
  55190. }
  55191. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55192. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55193. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55194. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55195. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55196. }
  55197. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55198. import { Nullable } from "babylonjs/types";
  55199. import { Scene } from "babylonjs/scene";
  55200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55202. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55203. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55204. /**
  55205. * Raw cube texture where the raw buffers are passed in
  55206. */
  55207. export class RawCubeTexture extends CubeTexture {
  55208. /**
  55209. * Creates a cube texture where the raw buffers are passed in.
  55210. * @param scene defines the scene the texture is attached to
  55211. * @param data defines the array of data to use to create each face
  55212. * @param size defines the size of the textures
  55213. * @param format defines the format of the data
  55214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55215. * @param generateMipMaps defines if the engine should generate the mip levels
  55216. * @param invertY defines if data must be stored with Y axis inverted
  55217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55218. * @param compression defines the compression used (null by default)
  55219. */
  55220. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55221. /**
  55222. * Updates the raw cube texture.
  55223. * @param data defines the data to store
  55224. * @param format defines the data format
  55225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55226. * @param invertY defines if data must be stored with Y axis inverted
  55227. * @param compression defines the compression used (null by default)
  55228. * @param level defines which level of the texture to update
  55229. */
  55230. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55231. /**
  55232. * Updates a raw cube texture with RGBD encoded data.
  55233. * @param data defines the array of data [mipmap][face] to use to create each face
  55234. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55235. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55236. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55237. * @returns a promsie that resolves when the operation is complete
  55238. */
  55239. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55240. /**
  55241. * Clones the raw cube texture.
  55242. * @return a new cube texture
  55243. */
  55244. clone(): CubeTexture;
  55245. /** @hidden */
  55246. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55247. }
  55248. }
  55249. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55250. import { Scene } from "babylonjs/scene";
  55251. import { Texture } from "babylonjs/Materials/Textures/texture";
  55252. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55253. /**
  55254. * Class used to store 3D textures containing user data
  55255. */
  55256. export class RawTexture3D extends Texture {
  55257. /** Gets or sets the texture format to use */
  55258. format: number;
  55259. private _engine;
  55260. /**
  55261. * Create a new RawTexture3D
  55262. * @param data defines the data of the texture
  55263. * @param width defines the width of the texture
  55264. * @param height defines the height of the texture
  55265. * @param depth defines the depth of the texture
  55266. * @param format defines the texture format to use
  55267. * @param scene defines the hosting scene
  55268. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55269. * @param invertY defines if texture must be stored with Y axis inverted
  55270. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55271. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55272. */
  55273. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55274. /** Gets or sets the texture format to use */
  55275. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55276. /**
  55277. * Update the texture with new data
  55278. * @param data defines the data to store in the texture
  55279. */
  55280. update(data: ArrayBufferView): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55284. import { Scene } from "babylonjs/scene";
  55285. import { Plane } from "babylonjs/Maths/math.plane";
  55286. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55287. /**
  55288. * Creates a refraction texture used by refraction channel of the standard material.
  55289. * It is like a mirror but to see through a material.
  55290. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55291. */
  55292. export class RefractionTexture extends RenderTargetTexture {
  55293. /**
  55294. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55295. * 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.
  55296. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55297. */
  55298. refractionPlane: Plane;
  55299. /**
  55300. * Define how deep under the surface we should see.
  55301. */
  55302. depth: number;
  55303. /**
  55304. * Creates a refraction texture used by refraction channel of the standard material.
  55305. * It is like a mirror but to see through a material.
  55306. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55307. * @param name Define the texture name
  55308. * @param size Define the size of the underlying texture
  55309. * @param scene Define the scene the refraction belongs to
  55310. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55311. */
  55312. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55313. /**
  55314. * Clone the refraction texture.
  55315. * @returns the cloned texture
  55316. */
  55317. clone(): RefractionTexture;
  55318. /**
  55319. * Serialize the texture to a JSON representation you could use in Parse later on
  55320. * @returns the serialized JSON representation
  55321. */
  55322. serialize(): any;
  55323. }
  55324. }
  55325. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55326. import { Nullable } from "babylonjs/types";
  55327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55328. import { Matrix } from "babylonjs/Maths/math.vector";
  55329. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55330. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55331. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55332. import { Scene } from "babylonjs/scene";
  55333. /**
  55334. * Defines the options related to the creation of an HtmlElementTexture
  55335. */
  55336. export interface IHtmlElementTextureOptions {
  55337. /**
  55338. * Defines wether mip maps should be created or not.
  55339. */
  55340. generateMipMaps?: boolean;
  55341. /**
  55342. * Defines the sampling mode of the texture.
  55343. */
  55344. samplingMode?: number;
  55345. /**
  55346. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55347. */
  55348. engine: Nullable<ThinEngine>;
  55349. /**
  55350. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55351. */
  55352. scene: Nullable<Scene>;
  55353. }
  55354. /**
  55355. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55356. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55357. * is automatically managed.
  55358. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55359. * in your application.
  55360. *
  55361. * As the update is not automatic, you need to call them manually.
  55362. */
  55363. export class HtmlElementTexture extends BaseTexture {
  55364. /**
  55365. * The texture URL.
  55366. */
  55367. element: HTMLVideoElement | HTMLCanvasElement;
  55368. private static readonly DefaultOptions;
  55369. private _textureMatrix;
  55370. private _engine;
  55371. private _isVideo;
  55372. private _generateMipMaps;
  55373. private _samplingMode;
  55374. /**
  55375. * Instantiates a HtmlElementTexture from the following parameters.
  55376. *
  55377. * @param name Defines the name of the texture
  55378. * @param element Defines the video or canvas the texture is filled with
  55379. * @param options Defines the other none mandatory texture creation options
  55380. */
  55381. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55382. private _createInternalTexture;
  55383. /**
  55384. * Returns the texture matrix used in most of the material.
  55385. */
  55386. getTextureMatrix(): Matrix;
  55387. /**
  55388. * Updates the content of the texture.
  55389. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55390. */
  55391. update(invertY?: Nullable<boolean>): void;
  55392. }
  55393. }
  55394. declare module "babylonjs/Materials/Textures/index" {
  55395. export * from "babylonjs/Materials/Textures/baseTexture";
  55396. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55397. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55398. export * from "babylonjs/Materials/Textures/cubeTexture";
  55399. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55400. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55401. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55402. export * from "babylonjs/Materials/Textures/internalTexture";
  55403. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55404. export * from "babylonjs/Materials/Textures/Loaders/index";
  55405. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55406. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55407. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55408. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55409. export * from "babylonjs/Materials/Textures/rawTexture";
  55410. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55411. export * from "babylonjs/Materials/Textures/refractionTexture";
  55412. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55413. export * from "babylonjs/Materials/Textures/texture";
  55414. export * from "babylonjs/Materials/Textures/videoTexture";
  55415. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55416. }
  55417. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55418. /**
  55419. * Enum used to define the target of a block
  55420. */
  55421. export enum NodeMaterialBlockTargets {
  55422. /** Vertex shader */
  55423. Vertex = 1,
  55424. /** Fragment shader */
  55425. Fragment = 2,
  55426. /** Neutral */
  55427. Neutral = 4,
  55428. /** Vertex and Fragment */
  55429. VertexAndFragment = 3
  55430. }
  55431. }
  55432. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55433. /**
  55434. * Defines the kind of connection point for node based material
  55435. */
  55436. export enum NodeMaterialBlockConnectionPointTypes {
  55437. /** Float */
  55438. Float = 1,
  55439. /** Int */
  55440. Int = 2,
  55441. /** Vector2 */
  55442. Vector2 = 4,
  55443. /** Vector3 */
  55444. Vector3 = 8,
  55445. /** Vector4 */
  55446. Vector4 = 16,
  55447. /** Color3 */
  55448. Color3 = 32,
  55449. /** Color4 */
  55450. Color4 = 64,
  55451. /** Matrix */
  55452. Matrix = 128,
  55453. /** Detect type based on connection */
  55454. AutoDetect = 1024,
  55455. /** Output type that will be defined by input type */
  55456. BasedOnInput = 2048
  55457. }
  55458. }
  55459. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55460. /**
  55461. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55462. */
  55463. export enum NodeMaterialBlockConnectionPointMode {
  55464. /** Value is an uniform */
  55465. Uniform = 0,
  55466. /** Value is a mesh attribute */
  55467. Attribute = 1,
  55468. /** Value is a varying between vertex and fragment shaders */
  55469. Varying = 2,
  55470. /** Mode is undefined */
  55471. Undefined = 3
  55472. }
  55473. }
  55474. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55475. /**
  55476. * Enum used to define system values e.g. values automatically provided by the system
  55477. */
  55478. export enum NodeMaterialSystemValues {
  55479. /** World */
  55480. World = 1,
  55481. /** View */
  55482. View = 2,
  55483. /** Projection */
  55484. Projection = 3,
  55485. /** ViewProjection */
  55486. ViewProjection = 4,
  55487. /** WorldView */
  55488. WorldView = 5,
  55489. /** WorldViewProjection */
  55490. WorldViewProjection = 6,
  55491. /** CameraPosition */
  55492. CameraPosition = 7,
  55493. /** Fog Color */
  55494. FogColor = 8,
  55495. /** Delta time */
  55496. DeltaTime = 9
  55497. }
  55498. }
  55499. declare module "babylonjs/Materials/Node/Enums/index" {
  55500. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55501. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55502. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55503. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55504. }
  55505. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55507. /**
  55508. * Root class for all node material optimizers
  55509. */
  55510. export class NodeMaterialOptimizer {
  55511. /**
  55512. * Function used to optimize a NodeMaterial graph
  55513. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55514. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55515. */
  55516. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55517. }
  55518. }
  55519. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55523. import { Scene } from "babylonjs/scene";
  55524. /**
  55525. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55526. */
  55527. export class TransformBlock extends NodeMaterialBlock {
  55528. /**
  55529. * Defines the value to use to complement W value to transform it to a Vector4
  55530. */
  55531. complementW: number;
  55532. /**
  55533. * Defines the value to use to complement z value to transform it to a Vector4
  55534. */
  55535. complementZ: number;
  55536. /**
  55537. * Creates a new TransformBlock
  55538. * @param name defines the block name
  55539. */
  55540. constructor(name: string);
  55541. /**
  55542. * Gets the current class name
  55543. * @returns the class name
  55544. */
  55545. getClassName(): string;
  55546. /**
  55547. * Gets the vector input
  55548. */
  55549. readonly vector: NodeMaterialConnectionPoint;
  55550. /**
  55551. * Gets the output component
  55552. */
  55553. readonly output: NodeMaterialConnectionPoint;
  55554. /**
  55555. * Gets the matrix transform input
  55556. */
  55557. readonly transform: NodeMaterialConnectionPoint;
  55558. protected _buildBlock(state: NodeMaterialBuildState): this;
  55559. serialize(): any;
  55560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55561. protected _dumpPropertiesCode(): string;
  55562. }
  55563. }
  55564. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55568. /**
  55569. * Block used to output the vertex position
  55570. */
  55571. export class VertexOutputBlock extends NodeMaterialBlock {
  55572. /**
  55573. * Creates a new VertexOutputBlock
  55574. * @param name defines the block name
  55575. */
  55576. constructor(name: string);
  55577. /**
  55578. * Gets the current class name
  55579. * @returns the class name
  55580. */
  55581. getClassName(): string;
  55582. /**
  55583. * Gets the vector input component
  55584. */
  55585. readonly vector: NodeMaterialConnectionPoint;
  55586. protected _buildBlock(state: NodeMaterialBuildState): this;
  55587. }
  55588. }
  55589. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55593. /**
  55594. * Block used to output the final color
  55595. */
  55596. export class FragmentOutputBlock extends NodeMaterialBlock {
  55597. /**
  55598. * Create a new FragmentOutputBlock
  55599. * @param name defines the block name
  55600. */
  55601. constructor(name: string);
  55602. /**
  55603. * Gets the current class name
  55604. * @returns the class name
  55605. */
  55606. getClassName(): string;
  55607. /**
  55608. * Gets the rgba input component
  55609. */
  55610. readonly rgba: NodeMaterialConnectionPoint;
  55611. /**
  55612. * Gets the rgb input component
  55613. */
  55614. readonly rgb: NodeMaterialConnectionPoint;
  55615. /**
  55616. * Gets the a input component
  55617. */
  55618. readonly a: NodeMaterialConnectionPoint;
  55619. protected _buildBlock(state: NodeMaterialBuildState): this;
  55620. }
  55621. }
  55622. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55628. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55629. import { Effect } from "babylonjs/Materials/effect";
  55630. import { Mesh } from "babylonjs/Meshes/mesh";
  55631. import { Nullable } from "babylonjs/types";
  55632. import { Scene } from "babylonjs/scene";
  55633. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55634. /**
  55635. * Block used to read a reflection texture from a sampler
  55636. */
  55637. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55638. private _define3DName;
  55639. private _defineCubicName;
  55640. private _defineExplicitName;
  55641. private _defineProjectionName;
  55642. private _defineLocalCubicName;
  55643. private _defineSphericalName;
  55644. private _definePlanarName;
  55645. private _defineEquirectangularName;
  55646. private _defineMirroredEquirectangularFixedName;
  55647. private _defineEquirectangularFixedName;
  55648. private _defineSkyboxName;
  55649. private _cubeSamplerName;
  55650. private _2DSamplerName;
  55651. private _positionUVWName;
  55652. private _directionWName;
  55653. private _reflectionCoordsName;
  55654. private _reflection2DCoordsName;
  55655. private _reflectionColorName;
  55656. private _reflectionMatrixName;
  55657. /**
  55658. * Gets or sets the texture associated with the node
  55659. */
  55660. texture: Nullable<BaseTexture>;
  55661. /**
  55662. * Create a new TextureBlock
  55663. * @param name defines the block name
  55664. */
  55665. constructor(name: string);
  55666. /**
  55667. * Gets the current class name
  55668. * @returns the class name
  55669. */
  55670. getClassName(): string;
  55671. /**
  55672. * Gets the world position input component
  55673. */
  55674. readonly position: NodeMaterialConnectionPoint;
  55675. /**
  55676. * Gets the world position input component
  55677. */
  55678. readonly worldPosition: NodeMaterialConnectionPoint;
  55679. /**
  55680. * Gets the world normal input component
  55681. */
  55682. readonly worldNormal: NodeMaterialConnectionPoint;
  55683. /**
  55684. * Gets the world input component
  55685. */
  55686. readonly world: NodeMaterialConnectionPoint;
  55687. /**
  55688. * Gets the camera (or eye) position component
  55689. */
  55690. readonly cameraPosition: NodeMaterialConnectionPoint;
  55691. /**
  55692. * Gets the view input component
  55693. */
  55694. readonly view: NodeMaterialConnectionPoint;
  55695. /**
  55696. * Gets the rgb output component
  55697. */
  55698. readonly rgb: NodeMaterialConnectionPoint;
  55699. /**
  55700. * Gets the r output component
  55701. */
  55702. readonly r: NodeMaterialConnectionPoint;
  55703. /**
  55704. * Gets the g output component
  55705. */
  55706. readonly g: NodeMaterialConnectionPoint;
  55707. /**
  55708. * Gets the b output component
  55709. */
  55710. readonly b: NodeMaterialConnectionPoint;
  55711. autoConfigure(material: NodeMaterial): void;
  55712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55713. isReady(): boolean;
  55714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55715. private _injectVertexCode;
  55716. private _writeOutput;
  55717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55718. protected _dumpPropertiesCode(): string;
  55719. serialize(): any;
  55720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55721. }
  55722. }
  55723. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55725. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55726. import { Scene } from "babylonjs/scene";
  55727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55728. import { Matrix } from "babylonjs/Maths/math.vector";
  55729. import { Mesh } from "babylonjs/Meshes/mesh";
  55730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55731. import { Observable } from "babylonjs/Misc/observable";
  55732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55733. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55734. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55735. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55736. import { Nullable } from "babylonjs/types";
  55737. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55738. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55739. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55740. /**
  55741. * Interface used to configure the node material editor
  55742. */
  55743. export interface INodeMaterialEditorOptions {
  55744. /** Define the URl to load node editor script */
  55745. editorURL?: string;
  55746. }
  55747. /** @hidden */
  55748. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55749. /** BONES */
  55750. NUM_BONE_INFLUENCERS: number;
  55751. BonesPerMesh: number;
  55752. BONETEXTURE: boolean;
  55753. /** MORPH TARGETS */
  55754. MORPHTARGETS: boolean;
  55755. MORPHTARGETS_NORMAL: boolean;
  55756. MORPHTARGETS_TANGENT: boolean;
  55757. MORPHTARGETS_UV: boolean;
  55758. NUM_MORPH_INFLUENCERS: number;
  55759. /** IMAGE PROCESSING */
  55760. IMAGEPROCESSING: boolean;
  55761. VIGNETTE: boolean;
  55762. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55763. VIGNETTEBLENDMODEOPAQUE: boolean;
  55764. TONEMAPPING: boolean;
  55765. TONEMAPPING_ACES: boolean;
  55766. CONTRAST: boolean;
  55767. EXPOSURE: boolean;
  55768. COLORCURVES: boolean;
  55769. COLORGRADING: boolean;
  55770. COLORGRADING3D: boolean;
  55771. SAMPLER3DGREENDEPTH: boolean;
  55772. SAMPLER3DBGRMAP: boolean;
  55773. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55774. /** MISC. */
  55775. BUMPDIRECTUV: number;
  55776. constructor();
  55777. setValue(name: string, value: boolean): void;
  55778. }
  55779. /**
  55780. * Class used to configure NodeMaterial
  55781. */
  55782. export interface INodeMaterialOptions {
  55783. /**
  55784. * Defines if blocks should emit comments
  55785. */
  55786. emitComments: boolean;
  55787. }
  55788. /**
  55789. * Class used to create a node based material built by assembling shader blocks
  55790. */
  55791. export class NodeMaterial extends PushMaterial {
  55792. private static _BuildIdGenerator;
  55793. private _options;
  55794. private _vertexCompilationState;
  55795. private _fragmentCompilationState;
  55796. private _sharedData;
  55797. private _buildId;
  55798. private _buildWasSuccessful;
  55799. private _cachedWorldViewMatrix;
  55800. private _cachedWorldViewProjectionMatrix;
  55801. private _optimizers;
  55802. private _animationFrame;
  55803. /** Define the URl to load node editor script */
  55804. static EditorURL: string;
  55805. private BJSNODEMATERIALEDITOR;
  55806. /** Get the inspector from bundle or global */
  55807. private _getGlobalNodeMaterialEditor;
  55808. /**
  55809. * 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)
  55810. */
  55811. ignoreAlpha: boolean;
  55812. /**
  55813. * Defines the maximum number of lights that can be used in the material
  55814. */
  55815. maxSimultaneousLights: number;
  55816. /**
  55817. * Observable raised when the material is built
  55818. */
  55819. onBuildObservable: Observable<NodeMaterial>;
  55820. /**
  55821. * Gets or sets the root nodes of the material vertex shader
  55822. */
  55823. _vertexOutputNodes: NodeMaterialBlock[];
  55824. /**
  55825. * Gets or sets the root nodes of the material fragment (pixel) shader
  55826. */
  55827. _fragmentOutputNodes: NodeMaterialBlock[];
  55828. /** Gets or sets options to control the node material overall behavior */
  55829. options: INodeMaterialOptions;
  55830. /**
  55831. * Default configuration related to image processing available in the standard Material.
  55832. */
  55833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55834. /**
  55835. * Gets the image processing configuration used either in this material.
  55836. */
  55837. /**
  55838. * Sets the Default image processing configuration used either in the this material.
  55839. *
  55840. * If sets to null, the scene one is in use.
  55841. */
  55842. imageProcessingConfiguration: ImageProcessingConfiguration;
  55843. /**
  55844. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55845. */
  55846. attachedBlocks: NodeMaterialBlock[];
  55847. /**
  55848. * Create a new node based material
  55849. * @param name defines the material name
  55850. * @param scene defines the hosting scene
  55851. * @param options defines creation option
  55852. */
  55853. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55854. /**
  55855. * Gets the current class name of the material e.g. "NodeMaterial"
  55856. * @returns the class name
  55857. */
  55858. getClassName(): string;
  55859. /**
  55860. * Keep track of the image processing observer to allow dispose and replace.
  55861. */
  55862. private _imageProcessingObserver;
  55863. /**
  55864. * Attaches a new image processing configuration to the Standard Material.
  55865. * @param configuration
  55866. */
  55867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55868. /**
  55869. * Get a block by its name
  55870. * @param name defines the name of the block to retrieve
  55871. * @returns the required block or null if not found
  55872. */
  55873. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55874. /**
  55875. * Get a block by its name
  55876. * @param predicate defines the predicate used to find the good candidate
  55877. * @returns the required block or null if not found
  55878. */
  55879. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55880. /**
  55881. * Get an input block by its name
  55882. * @param predicate defines the predicate used to find the good candidate
  55883. * @returns the required input block or null if not found
  55884. */
  55885. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55886. /**
  55887. * Gets the list of input blocks attached to this material
  55888. * @returns an array of InputBlocks
  55889. */
  55890. getInputBlocks(): InputBlock[];
  55891. /**
  55892. * Adds a new optimizer to the list of optimizers
  55893. * @param optimizer defines the optimizers to add
  55894. * @returns the current material
  55895. */
  55896. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55897. /**
  55898. * Remove an optimizer from the list of optimizers
  55899. * @param optimizer defines the optimizers to remove
  55900. * @returns the current material
  55901. */
  55902. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55903. /**
  55904. * Add a new block to the list of output nodes
  55905. * @param node defines the node to add
  55906. * @returns the current material
  55907. */
  55908. addOutputNode(node: NodeMaterialBlock): this;
  55909. /**
  55910. * Remove a block from the list of root nodes
  55911. * @param node defines the node to remove
  55912. * @returns the current material
  55913. */
  55914. removeOutputNode(node: NodeMaterialBlock): this;
  55915. private _addVertexOutputNode;
  55916. private _removeVertexOutputNode;
  55917. private _addFragmentOutputNode;
  55918. private _removeFragmentOutputNode;
  55919. /**
  55920. * Specifies if the material will require alpha blending
  55921. * @returns a boolean specifying if alpha blending is needed
  55922. */
  55923. needAlphaBlending(): boolean;
  55924. /**
  55925. * Specifies if this material should be rendered in alpha test mode
  55926. * @returns a boolean specifying if an alpha test is needed.
  55927. */
  55928. needAlphaTesting(): boolean;
  55929. private _initializeBlock;
  55930. private _resetDualBlocks;
  55931. /**
  55932. * Build the material and generates the inner effect
  55933. * @param verbose defines if the build should log activity
  55934. */
  55935. build(verbose?: boolean): void;
  55936. /**
  55937. * Runs an otpimization phase to try to improve the shader code
  55938. */
  55939. optimize(): void;
  55940. private _prepareDefinesForAttributes;
  55941. /**
  55942. * Get if the submesh is ready to be used and all its information available.
  55943. * Child classes can use it to update shaders
  55944. * @param mesh defines the mesh to check
  55945. * @param subMesh defines which submesh to check
  55946. * @param useInstances specifies that instances should be used
  55947. * @returns a boolean indicating that the submesh is ready or not
  55948. */
  55949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55950. /**
  55951. * Get a string representing the shaders built by the current node graph
  55952. */
  55953. readonly compiledShaders: string;
  55954. /**
  55955. * Binds the world matrix to the material
  55956. * @param world defines the world transformation matrix
  55957. */
  55958. bindOnlyWorldMatrix(world: Matrix): void;
  55959. /**
  55960. * Binds the submesh to this material by preparing the effect and shader to draw
  55961. * @param world defines the world transformation matrix
  55962. * @param mesh defines the mesh containing the submesh
  55963. * @param subMesh defines the submesh to bind the material to
  55964. */
  55965. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55966. /**
  55967. * Gets the active textures from the material
  55968. * @returns an array of textures
  55969. */
  55970. getActiveTextures(): BaseTexture[];
  55971. /**
  55972. * Gets the list of texture blocks
  55973. * @returns an array of texture blocks
  55974. */
  55975. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55976. /**
  55977. * Specifies if the material uses a texture
  55978. * @param texture defines the texture to check against the material
  55979. * @returns a boolean specifying if the material uses the texture
  55980. */
  55981. hasTexture(texture: BaseTexture): boolean;
  55982. /**
  55983. * Disposes the material
  55984. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55985. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55986. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55987. */
  55988. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55989. /** Creates the node editor window. */
  55990. private _createNodeEditor;
  55991. /**
  55992. * Launch the node material editor
  55993. * @param config Define the configuration of the editor
  55994. * @return a promise fulfilled when the node editor is visible
  55995. */
  55996. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55997. /**
  55998. * Clear the current material
  55999. */
  56000. clear(): void;
  56001. /**
  56002. * Clear the current material and set it to a default state
  56003. */
  56004. setToDefault(): void;
  56005. /**
  56006. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56007. * @param url defines the url to load from
  56008. * @returns a promise that will fullfil when the material is fully loaded
  56009. */
  56010. loadAsync(url: string): Promise<void>;
  56011. private _gatherBlocks;
  56012. /**
  56013. * Generate a string containing the code declaration required to create an equivalent of this material
  56014. * @returns a string
  56015. */
  56016. generateCode(): string;
  56017. /**
  56018. * Serializes this material in a JSON representation
  56019. * @returns the serialized material object
  56020. */
  56021. serialize(): any;
  56022. private _restoreConnections;
  56023. /**
  56024. * Clear the current graph and load a new one from a serialization object
  56025. * @param source defines the JSON representation of the material
  56026. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56027. */
  56028. loadFromSerialization(source: any, rootUrl?: string): void;
  56029. /**
  56030. * Creates a node material from parsed material data
  56031. * @param source defines the JSON representation of the material
  56032. * @param scene defines the hosting scene
  56033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56034. * @returns a new node material
  56035. */
  56036. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56037. /**
  56038. * Creates a new node material set to default basic configuration
  56039. * @param name defines the name of the material
  56040. * @param scene defines the hosting scene
  56041. * @returns a new NodeMaterial
  56042. */
  56043. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56044. }
  56045. }
  56046. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56049. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56052. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56053. import { Effect } from "babylonjs/Materials/effect";
  56054. import { Mesh } from "babylonjs/Meshes/mesh";
  56055. import { Nullable } from "babylonjs/types";
  56056. import { Texture } from "babylonjs/Materials/Textures/texture";
  56057. import { Scene } from "babylonjs/scene";
  56058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56059. /**
  56060. * Block used to read a texture from a sampler
  56061. */
  56062. export class TextureBlock extends NodeMaterialBlock {
  56063. private _defineName;
  56064. private _linearDefineName;
  56065. private _samplerName;
  56066. private _transformedUVName;
  56067. private _textureTransformName;
  56068. private _textureInfoName;
  56069. private _mainUVName;
  56070. private _mainUVDefineName;
  56071. /**
  56072. * Gets or sets the texture associated with the node
  56073. */
  56074. texture: Nullable<Texture>;
  56075. /**
  56076. * Create a new TextureBlock
  56077. * @param name defines the block name
  56078. */
  56079. constructor(name: string);
  56080. /**
  56081. * Gets the current class name
  56082. * @returns the class name
  56083. */
  56084. getClassName(): string;
  56085. /**
  56086. * Gets the uv input component
  56087. */
  56088. readonly uv: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Gets the rgba output component
  56091. */
  56092. readonly rgba: NodeMaterialConnectionPoint;
  56093. /**
  56094. * Gets the rgb output component
  56095. */
  56096. readonly rgb: NodeMaterialConnectionPoint;
  56097. /**
  56098. * Gets the r output component
  56099. */
  56100. readonly r: NodeMaterialConnectionPoint;
  56101. /**
  56102. * Gets the g output component
  56103. */
  56104. readonly g: NodeMaterialConnectionPoint;
  56105. /**
  56106. * Gets the b output component
  56107. */
  56108. readonly b: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the a output component
  56111. */
  56112. readonly a: NodeMaterialConnectionPoint;
  56113. readonly target: NodeMaterialBlockTargets;
  56114. autoConfigure(material: NodeMaterial): void;
  56115. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56117. isReady(): boolean;
  56118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56119. private readonly _isMixed;
  56120. private _injectVertexCode;
  56121. private _writeOutput;
  56122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56123. protected _dumpPropertiesCode(): string;
  56124. serialize(): any;
  56125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56126. }
  56127. }
  56128. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56131. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56132. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56133. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56134. import { Scene } from "babylonjs/scene";
  56135. /**
  56136. * Class used to store shared data between 2 NodeMaterialBuildState
  56137. */
  56138. export class NodeMaterialBuildStateSharedData {
  56139. /**
  56140. * Gets the list of emitted varyings
  56141. */
  56142. temps: string[];
  56143. /**
  56144. * Gets the list of emitted varyings
  56145. */
  56146. varyings: string[];
  56147. /**
  56148. * Gets the varying declaration string
  56149. */
  56150. varyingDeclaration: string;
  56151. /**
  56152. * Input blocks
  56153. */
  56154. inputBlocks: InputBlock[];
  56155. /**
  56156. * Input blocks
  56157. */
  56158. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56159. /**
  56160. * Bindable blocks (Blocks that need to set data to the effect)
  56161. */
  56162. bindableBlocks: NodeMaterialBlock[];
  56163. /**
  56164. * List of blocks that can provide a compilation fallback
  56165. */
  56166. blocksWithFallbacks: NodeMaterialBlock[];
  56167. /**
  56168. * List of blocks that can provide a define update
  56169. */
  56170. blocksWithDefines: NodeMaterialBlock[];
  56171. /**
  56172. * List of blocks that can provide a repeatable content
  56173. */
  56174. repeatableContentBlocks: NodeMaterialBlock[];
  56175. /**
  56176. * List of blocks that can provide a dynamic list of uniforms
  56177. */
  56178. dynamicUniformBlocks: NodeMaterialBlock[];
  56179. /**
  56180. * List of blocks that can block the isReady function for the material
  56181. */
  56182. blockingBlocks: NodeMaterialBlock[];
  56183. /**
  56184. * Gets the list of animated inputs
  56185. */
  56186. animatedInputs: InputBlock[];
  56187. /**
  56188. * Build Id used to avoid multiple recompilations
  56189. */
  56190. buildId: number;
  56191. /** List of emitted variables */
  56192. variableNames: {
  56193. [key: string]: number;
  56194. };
  56195. /** List of emitted defines */
  56196. defineNames: {
  56197. [key: string]: number;
  56198. };
  56199. /** Should emit comments? */
  56200. emitComments: boolean;
  56201. /** Emit build activity */
  56202. verbose: boolean;
  56203. /** Gets or sets the hosting scene */
  56204. scene: Scene;
  56205. /**
  56206. * Gets the compilation hints emitted at compilation time
  56207. */
  56208. hints: {
  56209. needWorldViewMatrix: boolean;
  56210. needWorldViewProjectionMatrix: boolean;
  56211. needAlphaBlending: boolean;
  56212. needAlphaTesting: boolean;
  56213. };
  56214. /**
  56215. * List of compilation checks
  56216. */
  56217. checks: {
  56218. emitVertex: boolean;
  56219. emitFragment: boolean;
  56220. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56221. };
  56222. /** Creates a new shared data */
  56223. constructor();
  56224. /**
  56225. * Emits console errors and exceptions if there is a failing check
  56226. */
  56227. emitErrors(): void;
  56228. }
  56229. }
  56230. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56231. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56232. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56233. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56234. /**
  56235. * Class used to store node based material build state
  56236. */
  56237. export class NodeMaterialBuildState {
  56238. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56239. supportUniformBuffers: boolean;
  56240. /**
  56241. * Gets the list of emitted attributes
  56242. */
  56243. attributes: string[];
  56244. /**
  56245. * Gets the list of emitted uniforms
  56246. */
  56247. uniforms: string[];
  56248. /**
  56249. * Gets the list of emitted constants
  56250. */
  56251. constants: string[];
  56252. /**
  56253. * Gets the list of emitted samplers
  56254. */
  56255. samplers: string[];
  56256. /**
  56257. * Gets the list of emitted functions
  56258. */
  56259. functions: {
  56260. [key: string]: string;
  56261. };
  56262. /**
  56263. * Gets the list of emitted extensions
  56264. */
  56265. extensions: {
  56266. [key: string]: string;
  56267. };
  56268. /**
  56269. * Gets the target of the compilation state
  56270. */
  56271. target: NodeMaterialBlockTargets;
  56272. /**
  56273. * Gets the list of emitted counters
  56274. */
  56275. counters: {
  56276. [key: string]: number;
  56277. };
  56278. /**
  56279. * Shared data between multiple NodeMaterialBuildState instances
  56280. */
  56281. sharedData: NodeMaterialBuildStateSharedData;
  56282. /** @hidden */
  56283. _vertexState: NodeMaterialBuildState;
  56284. /** @hidden */
  56285. _attributeDeclaration: string;
  56286. /** @hidden */
  56287. _uniformDeclaration: string;
  56288. /** @hidden */
  56289. _constantDeclaration: string;
  56290. /** @hidden */
  56291. _samplerDeclaration: string;
  56292. /** @hidden */
  56293. _varyingTransfer: string;
  56294. private _repeatableContentAnchorIndex;
  56295. /** @hidden */
  56296. _builtCompilationString: string;
  56297. /**
  56298. * Gets the emitted compilation strings
  56299. */
  56300. compilationString: string;
  56301. /**
  56302. * Finalize the compilation strings
  56303. * @param state defines the current compilation state
  56304. */
  56305. finalize(state: NodeMaterialBuildState): void;
  56306. /** @hidden */
  56307. readonly _repeatableContentAnchor: string;
  56308. /** @hidden */
  56309. _getFreeVariableName(prefix: string): string;
  56310. /** @hidden */
  56311. _getFreeDefineName(prefix: string): string;
  56312. /** @hidden */
  56313. _excludeVariableName(name: string): void;
  56314. /** @hidden */
  56315. _emit2DSampler(name: string): void;
  56316. /** @hidden */
  56317. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56318. /** @hidden */
  56319. _emitExtension(name: string, extension: string): void;
  56320. /** @hidden */
  56321. _emitFunction(name: string, code: string, comments: string): void;
  56322. /** @hidden */
  56323. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56324. replaceStrings?: {
  56325. search: RegExp;
  56326. replace: string;
  56327. }[];
  56328. repeatKey?: string;
  56329. }): string;
  56330. /** @hidden */
  56331. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56332. repeatKey?: string;
  56333. removeAttributes?: boolean;
  56334. removeUniforms?: boolean;
  56335. removeVaryings?: boolean;
  56336. removeIfDef?: boolean;
  56337. replaceStrings?: {
  56338. search: RegExp;
  56339. replace: string;
  56340. }[];
  56341. }, storeKey?: string): void;
  56342. /** @hidden */
  56343. _registerTempVariable(name: string): boolean;
  56344. /** @hidden */
  56345. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56346. /** @hidden */
  56347. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56348. /** @hidden */
  56349. _emitFloat(value: number): string;
  56350. }
  56351. }
  56352. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56353. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56355. import { Nullable } from "babylonjs/types";
  56356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56357. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56358. import { Effect } from "babylonjs/Materials/effect";
  56359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56360. import { Mesh } from "babylonjs/Meshes/mesh";
  56361. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56362. import { Scene } from "babylonjs/scene";
  56363. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56364. /**
  56365. * Defines a block that can be used inside a node based material
  56366. */
  56367. export class NodeMaterialBlock {
  56368. private _buildId;
  56369. private _buildTarget;
  56370. private _target;
  56371. private _isFinalMerger;
  56372. private _isInput;
  56373. /** @hidden */
  56374. _codeVariableName: string;
  56375. /** @hidden */
  56376. _inputs: NodeMaterialConnectionPoint[];
  56377. /** @hidden */
  56378. _outputs: NodeMaterialConnectionPoint[];
  56379. /** @hidden */
  56380. _preparationId: number;
  56381. /**
  56382. * Gets or sets the name of the block
  56383. */
  56384. name: string;
  56385. /**
  56386. * Gets or sets the unique id of the node
  56387. */
  56388. uniqueId: number;
  56389. /**
  56390. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56391. */
  56392. readonly isFinalMerger: boolean;
  56393. /**
  56394. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56395. */
  56396. readonly isInput: boolean;
  56397. /**
  56398. * Gets or sets the build Id
  56399. */
  56400. buildId: number;
  56401. /**
  56402. * Gets or sets the target of the block
  56403. */
  56404. target: NodeMaterialBlockTargets;
  56405. /**
  56406. * Gets the list of input points
  56407. */
  56408. readonly inputs: NodeMaterialConnectionPoint[];
  56409. /** Gets the list of output points */
  56410. readonly outputs: NodeMaterialConnectionPoint[];
  56411. /**
  56412. * Find an input by its name
  56413. * @param name defines the name of the input to look for
  56414. * @returns the input or null if not found
  56415. */
  56416. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56417. /**
  56418. * Find an output by its name
  56419. * @param name defines the name of the outputto look for
  56420. * @returns the output or null if not found
  56421. */
  56422. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56423. /**
  56424. * Creates a new NodeMaterialBlock
  56425. * @param name defines the block name
  56426. * @param target defines the target of that block (Vertex by default)
  56427. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56428. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56429. */
  56430. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56431. /**
  56432. * Initialize the block and prepare the context for build
  56433. * @param state defines the state that will be used for the build
  56434. */
  56435. initialize(state: NodeMaterialBuildState): void;
  56436. /**
  56437. * Bind data to effect. Will only be called for blocks with isBindable === true
  56438. * @param effect defines the effect to bind data to
  56439. * @param nodeMaterial defines the hosting NodeMaterial
  56440. * @param mesh defines the mesh that will be rendered
  56441. */
  56442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56443. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56444. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56445. protected _writeFloat(value: number): string;
  56446. /**
  56447. * Gets the current class name e.g. "NodeMaterialBlock"
  56448. * @returns the class name
  56449. */
  56450. getClassName(): string;
  56451. /**
  56452. * Register a new input. Must be called inside a block constructor
  56453. * @param name defines the connection point name
  56454. * @param type defines the connection point type
  56455. * @param isOptional defines a boolean indicating that this input can be omitted
  56456. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56457. * @returns the current block
  56458. */
  56459. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56460. /**
  56461. * Register a new output. Must be called inside a block constructor
  56462. * @param name defines the connection point name
  56463. * @param type defines the connection point type
  56464. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56465. * @returns the current block
  56466. */
  56467. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56468. /**
  56469. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56470. * @param forOutput defines an optional connection point to check compatibility with
  56471. * @returns the first available input or null
  56472. */
  56473. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56474. /**
  56475. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56476. * @param forBlock defines an optional block to check compatibility with
  56477. * @returns the first available input or null
  56478. */
  56479. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56480. /**
  56481. * Gets the sibling of the given output
  56482. * @param current defines the current output
  56483. * @returns the next output in the list or null
  56484. */
  56485. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56486. /**
  56487. * Connect current block with another block
  56488. * @param other defines the block to connect with
  56489. * @param options define the various options to help pick the right connections
  56490. * @returns the current block
  56491. */
  56492. connectTo(other: NodeMaterialBlock, options?: {
  56493. input?: string;
  56494. output?: string;
  56495. outputSwizzle?: string;
  56496. }): this | undefined;
  56497. protected _buildBlock(state: NodeMaterialBuildState): void;
  56498. /**
  56499. * Add uniforms, samplers and uniform buffers at compilation time
  56500. * @param state defines the state to update
  56501. * @param nodeMaterial defines the node material requesting the update
  56502. * @param defines defines the material defines to update
  56503. * @param uniformBuffers defines the list of uniform buffer names
  56504. */
  56505. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56506. /**
  56507. * Add potential fallbacks if shader compilation fails
  56508. * @param mesh defines the mesh to be rendered
  56509. * @param fallbacks defines the current prioritized list of fallbacks
  56510. */
  56511. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56512. /**
  56513. * Initialize defines for shader compilation
  56514. * @param mesh defines the mesh to be rendered
  56515. * @param nodeMaterial defines the node material requesting the update
  56516. * @param defines defines the material defines to update
  56517. * @param useInstances specifies that instances should be used
  56518. */
  56519. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56520. /**
  56521. * Update defines for shader compilation
  56522. * @param mesh defines the mesh to be rendered
  56523. * @param nodeMaterial defines the node material requesting the update
  56524. * @param defines defines the material defines to update
  56525. * @param useInstances specifies that instances should be used
  56526. */
  56527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56528. /**
  56529. * Lets the block try to connect some inputs automatically
  56530. * @param material defines the hosting NodeMaterial
  56531. */
  56532. autoConfigure(material: NodeMaterial): void;
  56533. /**
  56534. * Function called when a block is declared as repeatable content generator
  56535. * @param vertexShaderState defines the current compilation state for the vertex shader
  56536. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56537. * @param mesh defines the mesh to be rendered
  56538. * @param defines defines the material defines to update
  56539. */
  56540. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56541. /**
  56542. * Checks if the block is ready
  56543. * @param mesh defines the mesh to be rendered
  56544. * @param nodeMaterial defines the node material requesting the update
  56545. * @param defines defines the material defines to update
  56546. * @param useInstances specifies that instances should be used
  56547. * @returns true if the block is ready
  56548. */
  56549. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56550. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56551. private _processBuild;
  56552. /**
  56553. * Compile the current node and generate the shader code
  56554. * @param state defines the current compilation state (uniforms, samplers, current string)
  56555. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56556. * @returns true if already built
  56557. */
  56558. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56559. protected _inputRename(name: string): string;
  56560. protected _outputRename(name: string): string;
  56561. protected _dumpPropertiesCode(): string;
  56562. /** @hidden */
  56563. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56564. /** @hidden */
  56565. _dumpCodeForOutputConnections(): string;
  56566. /**
  56567. * Clone the current block to a new identical block
  56568. * @param scene defines the hosting scene
  56569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56570. * @returns a copy of the current block
  56571. */
  56572. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56573. /**
  56574. * Serializes this block in a JSON representation
  56575. * @returns the serialized block object
  56576. */
  56577. serialize(): any;
  56578. /** @hidden */
  56579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56580. /**
  56581. * Release resources
  56582. */
  56583. dispose(): void;
  56584. }
  56585. }
  56586. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56587. /**
  56588. * Enum defining the type of animations supported by InputBlock
  56589. */
  56590. export enum AnimatedInputBlockTypes {
  56591. /** No animation */
  56592. None = 0,
  56593. /** Time based animation. Will only work for floats */
  56594. Time = 1
  56595. }
  56596. }
  56597. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56599. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56600. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56601. import { Nullable } from "babylonjs/types";
  56602. import { Effect } from "babylonjs/Materials/effect";
  56603. import { Matrix } from "babylonjs/Maths/math.vector";
  56604. import { Scene } from "babylonjs/scene";
  56605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56607. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56608. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56609. /**
  56610. * Block used to expose an input value
  56611. */
  56612. export class InputBlock extends NodeMaterialBlock {
  56613. private _mode;
  56614. private _associatedVariableName;
  56615. private _storedValue;
  56616. private _valueCallback;
  56617. private _type;
  56618. private _animationType;
  56619. /** Gets or set a value used to limit the range of float values */
  56620. min: number;
  56621. /** Gets or set a value used to limit the range of float values */
  56622. max: number;
  56623. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56624. matrixMode: number;
  56625. /** @hidden */
  56626. _systemValue: Nullable<NodeMaterialSystemValues>;
  56627. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56628. visibleInInspector: boolean;
  56629. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56630. isConstant: boolean;
  56631. /**
  56632. * Gets or sets the connection point type (default is float)
  56633. */
  56634. readonly type: NodeMaterialBlockConnectionPointTypes;
  56635. /**
  56636. * Creates a new InputBlock
  56637. * @param name defines the block name
  56638. * @param target defines the target of that block (Vertex by default)
  56639. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56640. */
  56641. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56642. /**
  56643. * Gets the output component
  56644. */
  56645. readonly output: NodeMaterialConnectionPoint;
  56646. /**
  56647. * Set the source of this connection point to a vertex attribute
  56648. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56649. * @returns the current connection point
  56650. */
  56651. setAsAttribute(attributeName?: string): InputBlock;
  56652. /**
  56653. * Set the source of this connection point to a system value
  56654. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56655. * @returns the current connection point
  56656. */
  56657. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56658. /**
  56659. * Gets or sets the value of that point.
  56660. * Please note that this value will be ignored if valueCallback is defined
  56661. */
  56662. value: any;
  56663. /**
  56664. * Gets or sets a callback used to get the value of that point.
  56665. * Please note that setting this value will force the connection point to ignore the value property
  56666. */
  56667. valueCallback: () => any;
  56668. /**
  56669. * Gets or sets the associated variable name in the shader
  56670. */
  56671. associatedVariableName: string;
  56672. /** Gets or sets the type of animation applied to the input */
  56673. animationType: AnimatedInputBlockTypes;
  56674. /**
  56675. * Gets a boolean indicating that this connection point not defined yet
  56676. */
  56677. readonly isUndefined: boolean;
  56678. /**
  56679. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56680. * In this case the connection point name must be the name of the uniform to use.
  56681. * Can only be set on inputs
  56682. */
  56683. isUniform: boolean;
  56684. /**
  56685. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56686. * In this case the connection point name must be the name of the attribute to use
  56687. * Can only be set on inputs
  56688. */
  56689. isAttribute: boolean;
  56690. /**
  56691. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56692. * Can only be set on exit points
  56693. */
  56694. isVarying: boolean;
  56695. /**
  56696. * Gets a boolean indicating that the current connection point is a system value
  56697. */
  56698. readonly isSystemValue: boolean;
  56699. /**
  56700. * Gets or sets the current well known value or null if not defined as a system value
  56701. */
  56702. systemValue: Nullable<NodeMaterialSystemValues>;
  56703. /**
  56704. * Gets the current class name
  56705. * @returns the class name
  56706. */
  56707. getClassName(): string;
  56708. /**
  56709. * Animate the input if animationType !== None
  56710. * @param scene defines the rendering scene
  56711. */
  56712. animate(scene: Scene): void;
  56713. private _emitDefine;
  56714. initialize(state: NodeMaterialBuildState): void;
  56715. /**
  56716. * Set the input block to its default value (based on its type)
  56717. */
  56718. setDefaultValue(): void;
  56719. private _emitConstant;
  56720. private _emit;
  56721. /** @hidden */
  56722. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56723. /** @hidden */
  56724. _transmit(effect: Effect, scene: Scene): void;
  56725. protected _buildBlock(state: NodeMaterialBuildState): void;
  56726. protected _dumpPropertiesCode(): string;
  56727. serialize(): any;
  56728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56729. }
  56730. }
  56731. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56732. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56733. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56734. import { Nullable } from "babylonjs/types";
  56735. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56736. import { Observable } from "babylonjs/Misc/observable";
  56737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56738. /**
  56739. * Defines a connection point for a block
  56740. */
  56741. export class NodeMaterialConnectionPoint {
  56742. /** @hidden */
  56743. _ownerBlock: NodeMaterialBlock;
  56744. /** @hidden */
  56745. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56746. private _endpoints;
  56747. private _associatedVariableName;
  56748. /** @hidden */
  56749. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56750. /** @hidden */
  56751. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56752. private _type;
  56753. /** @hidden */
  56754. _enforceAssociatedVariableName: boolean;
  56755. /**
  56756. * Gets or sets the additional types supported by this connection point
  56757. */
  56758. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56759. /**
  56760. * Gets or sets the additional types excluded by this connection point
  56761. */
  56762. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56763. /**
  56764. * Observable triggered when this point is connected
  56765. */
  56766. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56767. /**
  56768. * Gets or sets the associated variable name in the shader
  56769. */
  56770. associatedVariableName: string;
  56771. /**
  56772. * Gets or sets the connection point type (default is float)
  56773. */
  56774. type: NodeMaterialBlockConnectionPointTypes;
  56775. /**
  56776. * Gets or sets the connection point name
  56777. */
  56778. name: string;
  56779. /**
  56780. * Gets or sets a boolean indicating that this connection point can be omitted
  56781. */
  56782. isOptional: boolean;
  56783. /**
  56784. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56785. */
  56786. define: string;
  56787. /** @hidden */
  56788. _prioritizeVertex: boolean;
  56789. private _target;
  56790. /** Gets or sets the target of that connection point */
  56791. target: NodeMaterialBlockTargets;
  56792. /**
  56793. * Gets a boolean indicating that the current point is connected
  56794. */
  56795. readonly isConnected: boolean;
  56796. /**
  56797. * Gets a boolean indicating that the current point is connected to an input block
  56798. */
  56799. readonly isConnectedToInputBlock: boolean;
  56800. /**
  56801. * Gets a the connected input block (if any)
  56802. */
  56803. readonly connectInputBlock: Nullable<InputBlock>;
  56804. /** Get the other side of the connection (if any) */
  56805. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56806. /** Get the block that owns this connection point */
  56807. readonly ownerBlock: NodeMaterialBlock;
  56808. /** Get the block connected on the other side of this connection (if any) */
  56809. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56810. /** Get the block connected on the endpoints of this connection (if any) */
  56811. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56812. /** Gets the list of connected endpoints */
  56813. readonly endpoints: NodeMaterialConnectionPoint[];
  56814. /** Gets a boolean indicating if that output point is connected to at least one input */
  56815. readonly hasEndpoints: boolean;
  56816. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56817. readonly isConnectedInVertexShader: boolean;
  56818. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56819. readonly isConnectedInFragmentShader: boolean;
  56820. /**
  56821. * Creates a new connection point
  56822. * @param name defines the connection point name
  56823. * @param ownerBlock defines the block hosting this connection point
  56824. */
  56825. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56826. /**
  56827. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56828. * @returns the class name
  56829. */
  56830. getClassName(): string;
  56831. /**
  56832. * Gets an boolean indicating if the current point can be connected to another point
  56833. * @param connectionPoint defines the other connection point
  56834. * @returns true if the connection is possible
  56835. */
  56836. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56837. /**
  56838. * Connect this point to another connection point
  56839. * @param connectionPoint defines the other connection point
  56840. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56841. * @returns the current connection point
  56842. */
  56843. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56844. /**
  56845. * Disconnect this point from one of his endpoint
  56846. * @param endpoint defines the other connection point
  56847. * @returns the current connection point
  56848. */
  56849. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56850. /**
  56851. * Serializes this point in a JSON representation
  56852. * @returns the serialized point object
  56853. */
  56854. serialize(): any;
  56855. /**
  56856. * Release resources
  56857. */
  56858. dispose(): void;
  56859. }
  56860. }
  56861. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56865. import { Mesh } from "babylonjs/Meshes/mesh";
  56866. import { Effect } from "babylonjs/Materials/effect";
  56867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56869. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56871. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56872. /**
  56873. * Block used to add support for vertex skinning (bones)
  56874. */
  56875. export class BonesBlock extends NodeMaterialBlock {
  56876. /**
  56877. * Creates a new BonesBlock
  56878. * @param name defines the block name
  56879. */
  56880. constructor(name: string);
  56881. /**
  56882. * Initialize the block and prepare the context for build
  56883. * @param state defines the state that will be used for the build
  56884. */
  56885. initialize(state: NodeMaterialBuildState): void;
  56886. /**
  56887. * Gets the current class name
  56888. * @returns the class name
  56889. */
  56890. getClassName(): string;
  56891. /**
  56892. * Gets the matrix indices input component
  56893. */
  56894. readonly matricesIndices: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the matrix weights input component
  56897. */
  56898. readonly matricesWeights: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the extra matrix indices input component
  56901. */
  56902. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the extra matrix weights input component
  56905. */
  56906. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the world input component
  56909. */
  56910. readonly world: NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the output component
  56913. */
  56914. readonly output: NodeMaterialConnectionPoint;
  56915. autoConfigure(material: NodeMaterial): void;
  56916. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56919. protected _buildBlock(state: NodeMaterialBuildState): this;
  56920. }
  56921. }
  56922. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56927. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56928. /**
  56929. * Block used to add support for instances
  56930. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56931. */
  56932. export class InstancesBlock extends NodeMaterialBlock {
  56933. /**
  56934. * Creates a new InstancesBlock
  56935. * @param name defines the block name
  56936. */
  56937. constructor(name: string);
  56938. /**
  56939. * Gets the current class name
  56940. * @returns the class name
  56941. */
  56942. getClassName(): string;
  56943. /**
  56944. * Gets the first world row input component
  56945. */
  56946. readonly world0: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the second world row input component
  56949. */
  56950. readonly world1: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the third world row input component
  56953. */
  56954. readonly world2: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the forth world row input component
  56957. */
  56958. readonly world3: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the world input component
  56961. */
  56962. readonly world: NodeMaterialConnectionPoint;
  56963. /**
  56964. * Gets the output component
  56965. */
  56966. readonly output: NodeMaterialConnectionPoint;
  56967. autoConfigure(material: NodeMaterial): void;
  56968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56969. protected _buildBlock(state: NodeMaterialBuildState): this;
  56970. }
  56971. }
  56972. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56977. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56978. import { Effect } from "babylonjs/Materials/effect";
  56979. import { Mesh } from "babylonjs/Meshes/mesh";
  56980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56982. /**
  56983. * Block used to add morph targets support to vertex shader
  56984. */
  56985. export class MorphTargetsBlock extends NodeMaterialBlock {
  56986. private _repeatableContentAnchor;
  56987. private _repeatebleContentGenerated;
  56988. /**
  56989. * Create a new MorphTargetsBlock
  56990. * @param name defines the block name
  56991. */
  56992. constructor(name: string);
  56993. /**
  56994. * Gets the current class name
  56995. * @returns the class name
  56996. */
  56997. getClassName(): string;
  56998. /**
  56999. * Gets the position input component
  57000. */
  57001. readonly position: NodeMaterialConnectionPoint;
  57002. /**
  57003. * Gets the normal input component
  57004. */
  57005. readonly normal: NodeMaterialConnectionPoint;
  57006. /**
  57007. * Gets the tangent input component
  57008. */
  57009. readonly tangent: NodeMaterialConnectionPoint;
  57010. /**
  57011. * Gets the tangent input component
  57012. */
  57013. readonly uv: NodeMaterialConnectionPoint;
  57014. /**
  57015. * Gets the position output component
  57016. */
  57017. readonly positionOutput: NodeMaterialConnectionPoint;
  57018. /**
  57019. * Gets the normal output component
  57020. */
  57021. readonly normalOutput: NodeMaterialConnectionPoint;
  57022. /**
  57023. * Gets the tangent output component
  57024. */
  57025. readonly tangentOutput: NodeMaterialConnectionPoint;
  57026. /**
  57027. * Gets the tangent output component
  57028. */
  57029. readonly uvOutput: NodeMaterialConnectionPoint;
  57030. initialize(state: NodeMaterialBuildState): void;
  57031. autoConfigure(material: NodeMaterial): void;
  57032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57033. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57034. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57035. protected _buildBlock(state: NodeMaterialBuildState): this;
  57036. }
  57037. }
  57038. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57042. import { Nullable } from "babylonjs/types";
  57043. import { Scene } from "babylonjs/scene";
  57044. import { Effect } from "babylonjs/Materials/effect";
  57045. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57046. import { Mesh } from "babylonjs/Meshes/mesh";
  57047. import { Light } from "babylonjs/Lights/light";
  57048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57049. /**
  57050. * Block used to get data information from a light
  57051. */
  57052. export class LightInformationBlock extends NodeMaterialBlock {
  57053. private _lightDataUniformName;
  57054. private _lightColorUniformName;
  57055. private _lightTypeDefineName;
  57056. /**
  57057. * Gets or sets the light associated with this block
  57058. */
  57059. light: Nullable<Light>;
  57060. /**
  57061. * Creates a new LightInformationBlock
  57062. * @param name defines the block name
  57063. */
  57064. constructor(name: string);
  57065. /**
  57066. * Gets the current class name
  57067. * @returns the class name
  57068. */
  57069. getClassName(): string;
  57070. /**
  57071. * Gets the world position input component
  57072. */
  57073. readonly worldPosition: NodeMaterialConnectionPoint;
  57074. /**
  57075. * Gets the direction output component
  57076. */
  57077. readonly direction: NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the direction output component
  57080. */
  57081. readonly color: NodeMaterialConnectionPoint;
  57082. /**
  57083. * Gets the direction output component
  57084. */
  57085. readonly intensity: NodeMaterialConnectionPoint;
  57086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57088. protected _buildBlock(state: NodeMaterialBuildState): this;
  57089. serialize(): any;
  57090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57091. }
  57092. }
  57093. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57094. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57095. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57096. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57097. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57098. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57099. }
  57100. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57105. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57106. import { Effect } from "babylonjs/Materials/effect";
  57107. import { Mesh } from "babylonjs/Meshes/mesh";
  57108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57109. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57110. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57111. /**
  57112. * Block used to add image processing support to fragment shader
  57113. */
  57114. export class ImageProcessingBlock extends NodeMaterialBlock {
  57115. /**
  57116. * Create a new ImageProcessingBlock
  57117. * @param name defines the block name
  57118. */
  57119. constructor(name: string);
  57120. /**
  57121. * Gets the current class name
  57122. * @returns the class name
  57123. */
  57124. getClassName(): string;
  57125. /**
  57126. * Gets the color input component
  57127. */
  57128. readonly color: NodeMaterialConnectionPoint;
  57129. /**
  57130. * Gets the output component
  57131. */
  57132. readonly output: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Initialize the block and prepare the context for build
  57135. * @param state defines the state that will be used for the build
  57136. */
  57137. initialize(state: NodeMaterialBuildState): void;
  57138. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57141. protected _buildBlock(state: NodeMaterialBuildState): this;
  57142. }
  57143. }
  57144. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57150. import { Effect } from "babylonjs/Materials/effect";
  57151. import { Mesh } from "babylonjs/Meshes/mesh";
  57152. import { Scene } from "babylonjs/scene";
  57153. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57154. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57155. /**
  57156. * Block used to pertub normals based on a normal map
  57157. */
  57158. export class PerturbNormalBlock extends NodeMaterialBlock {
  57159. private _tangentSpaceParameterName;
  57160. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57161. invertX: boolean;
  57162. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57163. invertY: boolean;
  57164. /**
  57165. * Create a new PerturbNormalBlock
  57166. * @param name defines the block name
  57167. */
  57168. constructor(name: string);
  57169. /**
  57170. * Gets the current class name
  57171. * @returns the class name
  57172. */
  57173. getClassName(): string;
  57174. /**
  57175. * Gets the world position input component
  57176. */
  57177. readonly worldPosition: NodeMaterialConnectionPoint;
  57178. /**
  57179. * Gets the world normal input component
  57180. */
  57181. readonly worldNormal: NodeMaterialConnectionPoint;
  57182. /**
  57183. * Gets the uv input component
  57184. */
  57185. readonly uv: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the normal map color input component
  57188. */
  57189. readonly normalMapColor: NodeMaterialConnectionPoint;
  57190. /**
  57191. * Gets the strength input component
  57192. */
  57193. readonly strength: NodeMaterialConnectionPoint;
  57194. /**
  57195. * Gets the output component
  57196. */
  57197. readonly output: NodeMaterialConnectionPoint;
  57198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57200. autoConfigure(material: NodeMaterial): void;
  57201. protected _buildBlock(state: NodeMaterialBuildState): this;
  57202. protected _dumpPropertiesCode(): string;
  57203. serialize(): any;
  57204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57205. }
  57206. }
  57207. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57211. /**
  57212. * Block used to discard a pixel if a value is smaller than a cutoff
  57213. */
  57214. export class DiscardBlock extends NodeMaterialBlock {
  57215. /**
  57216. * Create a new DiscardBlock
  57217. * @param name defines the block name
  57218. */
  57219. constructor(name: string);
  57220. /**
  57221. * Gets the current class name
  57222. * @returns the class name
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets the color input component
  57227. */
  57228. readonly value: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the cutoff input component
  57231. */
  57232. readonly cutoff: NodeMaterialConnectionPoint;
  57233. protected _buildBlock(state: NodeMaterialBuildState): this;
  57234. }
  57235. }
  57236. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57237. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57238. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57239. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57240. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57241. }
  57242. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57245. import { Mesh } from "babylonjs/Meshes/mesh";
  57246. import { Effect } from "babylonjs/Materials/effect";
  57247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57250. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57251. /**
  57252. * Block used to add support for scene fog
  57253. */
  57254. export class FogBlock extends NodeMaterialBlock {
  57255. private _fogDistanceName;
  57256. private _fogParameters;
  57257. /**
  57258. * Create a new FogBlock
  57259. * @param name defines the block name
  57260. */
  57261. constructor(name: string);
  57262. /**
  57263. * Gets the current class name
  57264. * @returns the class name
  57265. */
  57266. getClassName(): string;
  57267. /**
  57268. * Gets the world position input component
  57269. */
  57270. readonly worldPosition: NodeMaterialConnectionPoint;
  57271. /**
  57272. * Gets the view input component
  57273. */
  57274. readonly view: NodeMaterialConnectionPoint;
  57275. /**
  57276. * Gets the color input component
  57277. */
  57278. readonly input: NodeMaterialConnectionPoint;
  57279. /**
  57280. * Gets the fog color input component
  57281. */
  57282. readonly fogColor: NodeMaterialConnectionPoint;
  57283. /**
  57284. * Gets the output component
  57285. */
  57286. readonly output: NodeMaterialConnectionPoint;
  57287. autoConfigure(material: NodeMaterial): void;
  57288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57290. protected _buildBlock(state: NodeMaterialBuildState): this;
  57291. }
  57292. }
  57293. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57298. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57299. import { Effect } from "babylonjs/Materials/effect";
  57300. import { Mesh } from "babylonjs/Meshes/mesh";
  57301. import { Light } from "babylonjs/Lights/light";
  57302. import { Nullable } from "babylonjs/types";
  57303. import { Scene } from "babylonjs/scene";
  57304. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57305. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57306. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57308. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57309. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57310. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57311. /**
  57312. * Block used to add light in the fragment shader
  57313. */
  57314. export class LightBlock extends NodeMaterialBlock {
  57315. private _lightId;
  57316. /**
  57317. * Gets or sets the light associated with this block
  57318. */
  57319. light: Nullable<Light>;
  57320. /**
  57321. * Create a new LightBlock
  57322. * @param name defines the block name
  57323. */
  57324. constructor(name: string);
  57325. /**
  57326. * Gets the current class name
  57327. * @returns the class name
  57328. */
  57329. getClassName(): string;
  57330. /**
  57331. * Gets the world position input component
  57332. */
  57333. readonly worldPosition: NodeMaterialConnectionPoint;
  57334. /**
  57335. * Gets the world normal input component
  57336. */
  57337. readonly worldNormal: NodeMaterialConnectionPoint;
  57338. /**
  57339. * Gets the camera (or eye) position component
  57340. */
  57341. readonly cameraPosition: NodeMaterialConnectionPoint;
  57342. /**
  57343. * Gets the glossiness component
  57344. */
  57345. readonly glossiness: NodeMaterialConnectionPoint;
  57346. /**
  57347. * Gets the glossinness power component
  57348. */
  57349. readonly glossPower: NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the diffuse color component
  57352. */
  57353. readonly diffuseColor: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the specular color component
  57356. */
  57357. readonly specularColor: NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the diffuse output component
  57360. */
  57361. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the specular output component
  57364. */
  57365. readonly specularOutput: NodeMaterialConnectionPoint;
  57366. autoConfigure(material: NodeMaterial): void;
  57367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57368. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57370. private _injectVertexCode;
  57371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57372. serialize(): any;
  57373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57374. }
  57375. }
  57376. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57377. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57378. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57379. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57380. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57381. }
  57382. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57383. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57384. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57385. }
  57386. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57390. /**
  57391. * Block used to multiply 2 values
  57392. */
  57393. export class MultiplyBlock extends NodeMaterialBlock {
  57394. /**
  57395. * Creates a new MultiplyBlock
  57396. * @param name defines the block name
  57397. */
  57398. constructor(name: string);
  57399. /**
  57400. * Gets the current class name
  57401. * @returns the class name
  57402. */
  57403. getClassName(): string;
  57404. /**
  57405. * Gets the left operand input component
  57406. */
  57407. readonly left: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the right operand input component
  57410. */
  57411. readonly right: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the output component
  57414. */
  57415. readonly output: NodeMaterialConnectionPoint;
  57416. protected _buildBlock(state: NodeMaterialBuildState): this;
  57417. }
  57418. }
  57419. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57423. /**
  57424. * Block used to add 2 vectors
  57425. */
  57426. export class AddBlock extends NodeMaterialBlock {
  57427. /**
  57428. * Creates a new AddBlock
  57429. * @param name defines the block name
  57430. */
  57431. constructor(name: string);
  57432. /**
  57433. * Gets the current class name
  57434. * @returns the class name
  57435. */
  57436. getClassName(): string;
  57437. /**
  57438. * Gets the left operand input component
  57439. */
  57440. readonly left: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the right operand input component
  57443. */
  57444. readonly right: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the output component
  57447. */
  57448. readonly output: NodeMaterialConnectionPoint;
  57449. protected _buildBlock(state: NodeMaterialBuildState): this;
  57450. }
  57451. }
  57452. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57456. /**
  57457. * Block used to scale a vector by a float
  57458. */
  57459. export class ScaleBlock extends NodeMaterialBlock {
  57460. /**
  57461. * Creates a new ScaleBlock
  57462. * @param name defines the block name
  57463. */
  57464. constructor(name: string);
  57465. /**
  57466. * Gets the current class name
  57467. * @returns the class name
  57468. */
  57469. getClassName(): string;
  57470. /**
  57471. * Gets the input component
  57472. */
  57473. readonly input: NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the factor input component
  57476. */
  57477. readonly factor: NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the output component
  57480. */
  57481. readonly output: NodeMaterialConnectionPoint;
  57482. protected _buildBlock(state: NodeMaterialBuildState): this;
  57483. }
  57484. }
  57485. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57489. import { Scene } from "babylonjs/scene";
  57490. /**
  57491. * Block used to clamp a float
  57492. */
  57493. export class ClampBlock extends NodeMaterialBlock {
  57494. /** Gets or sets the minimum range */
  57495. minimum: number;
  57496. /** Gets or sets the maximum range */
  57497. maximum: number;
  57498. /**
  57499. * Creates a new ClampBlock
  57500. * @param name defines the block name
  57501. */
  57502. constructor(name: string);
  57503. /**
  57504. * Gets the current class name
  57505. * @returns the class name
  57506. */
  57507. getClassName(): string;
  57508. /**
  57509. * Gets the value input component
  57510. */
  57511. readonly value: NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the output component
  57514. */
  57515. readonly output: NodeMaterialConnectionPoint;
  57516. protected _buildBlock(state: NodeMaterialBuildState): this;
  57517. protected _dumpPropertiesCode(): string;
  57518. serialize(): any;
  57519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57520. }
  57521. }
  57522. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57526. /**
  57527. * Block used to apply a cross product between 2 vectors
  57528. */
  57529. export class CrossBlock extends NodeMaterialBlock {
  57530. /**
  57531. * Creates a new CrossBlock
  57532. * @param name defines the block name
  57533. */
  57534. constructor(name: string);
  57535. /**
  57536. * Gets the current class name
  57537. * @returns the class name
  57538. */
  57539. getClassName(): string;
  57540. /**
  57541. * Gets the left operand input component
  57542. */
  57543. readonly left: NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the right operand input component
  57546. */
  57547. readonly right: NodeMaterialConnectionPoint;
  57548. /**
  57549. * Gets the output component
  57550. */
  57551. readonly output: NodeMaterialConnectionPoint;
  57552. protected _buildBlock(state: NodeMaterialBuildState): this;
  57553. }
  57554. }
  57555. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57559. /**
  57560. * Block used to apply a dot product between 2 vectors
  57561. */
  57562. export class DotBlock extends NodeMaterialBlock {
  57563. /**
  57564. * Creates a new DotBlock
  57565. * @param name defines the block name
  57566. */
  57567. constructor(name: string);
  57568. /**
  57569. * Gets the current class name
  57570. * @returns the class name
  57571. */
  57572. getClassName(): string;
  57573. /**
  57574. * Gets the left operand input component
  57575. */
  57576. readonly left: NodeMaterialConnectionPoint;
  57577. /**
  57578. * Gets the right operand input component
  57579. */
  57580. readonly right: NodeMaterialConnectionPoint;
  57581. /**
  57582. * Gets the output component
  57583. */
  57584. readonly output: NodeMaterialConnectionPoint;
  57585. protected _buildBlock(state: NodeMaterialBuildState): this;
  57586. }
  57587. }
  57588. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57592. import { Vector2 } from "babylonjs/Maths/math.vector";
  57593. import { Scene } from "babylonjs/scene";
  57594. /**
  57595. * Block used to remap a float from a range to a new one
  57596. */
  57597. export class RemapBlock extends NodeMaterialBlock {
  57598. /**
  57599. * Gets or sets the source range
  57600. */
  57601. sourceRange: Vector2;
  57602. /**
  57603. * Gets or sets the target range
  57604. */
  57605. targetRange: Vector2;
  57606. /**
  57607. * Creates a new RemapBlock
  57608. * @param name defines the block name
  57609. */
  57610. constructor(name: string);
  57611. /**
  57612. * Gets the current class name
  57613. * @returns the class name
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Gets the input component
  57618. */
  57619. readonly input: NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the source min input component
  57622. */
  57623. readonly sourceMin: NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the source max input component
  57626. */
  57627. readonly sourceMax: NodeMaterialConnectionPoint;
  57628. /**
  57629. * Gets the target min input component
  57630. */
  57631. readonly targetMin: NodeMaterialConnectionPoint;
  57632. /**
  57633. * Gets the target max input component
  57634. */
  57635. readonly targetMax: NodeMaterialConnectionPoint;
  57636. /**
  57637. * Gets the output component
  57638. */
  57639. readonly output: NodeMaterialConnectionPoint;
  57640. protected _buildBlock(state: NodeMaterialBuildState): this;
  57641. protected _dumpPropertiesCode(): string;
  57642. serialize(): any;
  57643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57644. }
  57645. }
  57646. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57650. /**
  57651. * Block used to normalize a vector
  57652. */
  57653. export class NormalizeBlock extends NodeMaterialBlock {
  57654. /**
  57655. * Creates a new NormalizeBlock
  57656. * @param name defines the block name
  57657. */
  57658. constructor(name: string);
  57659. /**
  57660. * Gets the current class name
  57661. * @returns the class name
  57662. */
  57663. getClassName(): string;
  57664. /**
  57665. * Gets the input component
  57666. */
  57667. readonly input: NodeMaterialConnectionPoint;
  57668. /**
  57669. * Gets the output component
  57670. */
  57671. readonly output: NodeMaterialConnectionPoint;
  57672. protected _buildBlock(state: NodeMaterialBuildState): this;
  57673. }
  57674. }
  57675. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57679. import { Scene } from "babylonjs/scene";
  57680. /**
  57681. * Operations supported by the Trigonometry block
  57682. */
  57683. export enum TrigonometryBlockOperations {
  57684. /** Cos */
  57685. Cos = 0,
  57686. /** Sin */
  57687. Sin = 1,
  57688. /** Abs */
  57689. Abs = 2,
  57690. /** Exp */
  57691. Exp = 3,
  57692. /** Exp2 */
  57693. Exp2 = 4,
  57694. /** Round */
  57695. Round = 5,
  57696. /** Floor */
  57697. Floor = 6,
  57698. /** Ceiling */
  57699. Ceiling = 7,
  57700. /** Square root */
  57701. Sqrt = 8,
  57702. /** Log */
  57703. Log = 9,
  57704. /** Tangent */
  57705. Tan = 10,
  57706. /** Arc tangent */
  57707. ArcTan = 11,
  57708. /** Arc cosinus */
  57709. ArcCos = 12,
  57710. /** Arc sinus */
  57711. ArcSin = 13,
  57712. /** Fraction */
  57713. Fract = 14,
  57714. /** Sign */
  57715. Sign = 15,
  57716. /** To radians (from degrees) */
  57717. Radians = 16,
  57718. /** To degrees (from radians) */
  57719. Degrees = 17
  57720. }
  57721. /**
  57722. * Block used to apply trigonometry operation to floats
  57723. */
  57724. export class TrigonometryBlock extends NodeMaterialBlock {
  57725. /**
  57726. * Gets or sets the operation applied by the block
  57727. */
  57728. operation: TrigonometryBlockOperations;
  57729. /**
  57730. * Creates a new TrigonometryBlock
  57731. * @param name defines the block name
  57732. */
  57733. constructor(name: string);
  57734. /**
  57735. * Gets the current class name
  57736. * @returns the class name
  57737. */
  57738. getClassName(): string;
  57739. /**
  57740. * Gets the input component
  57741. */
  57742. readonly input: NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the output component
  57745. */
  57746. readonly output: NodeMaterialConnectionPoint;
  57747. protected _buildBlock(state: NodeMaterialBuildState): this;
  57748. serialize(): any;
  57749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57750. }
  57751. }
  57752. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57756. /**
  57757. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57758. */
  57759. export class ColorMergerBlock extends NodeMaterialBlock {
  57760. /**
  57761. * Create a new ColorMergerBlock
  57762. * @param name defines the block name
  57763. */
  57764. constructor(name: string);
  57765. /**
  57766. * Gets the current class name
  57767. * @returns the class name
  57768. */
  57769. getClassName(): string;
  57770. /**
  57771. * Gets the r component (input)
  57772. */
  57773. readonly r: NodeMaterialConnectionPoint;
  57774. /**
  57775. * Gets the g component (input)
  57776. */
  57777. readonly g: NodeMaterialConnectionPoint;
  57778. /**
  57779. * Gets the b component (input)
  57780. */
  57781. readonly b: NodeMaterialConnectionPoint;
  57782. /**
  57783. * Gets the a component (input)
  57784. */
  57785. readonly a: NodeMaterialConnectionPoint;
  57786. /**
  57787. * Gets the rgba component (output)
  57788. */
  57789. readonly rgba: NodeMaterialConnectionPoint;
  57790. /**
  57791. * Gets the rgb component (output)
  57792. */
  57793. readonly rgb: NodeMaterialConnectionPoint;
  57794. protected _buildBlock(state: NodeMaterialBuildState): this;
  57795. }
  57796. }
  57797. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57801. /**
  57802. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57803. */
  57804. export class VectorMergerBlock extends NodeMaterialBlock {
  57805. /**
  57806. * Create a new VectorMergerBlock
  57807. * @param name defines the block name
  57808. */
  57809. constructor(name: string);
  57810. /**
  57811. * Gets the current class name
  57812. * @returns the class name
  57813. */
  57814. getClassName(): string;
  57815. /**
  57816. * Gets the x component (input)
  57817. */
  57818. readonly x: NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the y component (input)
  57821. */
  57822. readonly y: NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the z component (input)
  57825. */
  57826. readonly z: NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the w component (input)
  57829. */
  57830. readonly w: NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the xyzw component (output)
  57833. */
  57834. readonly xyzw: NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the xyz component (output)
  57837. */
  57838. readonly xyz: NodeMaterialConnectionPoint;
  57839. /**
  57840. * Gets the xy component (output)
  57841. */
  57842. readonly xy: NodeMaterialConnectionPoint;
  57843. protected _buildBlock(state: NodeMaterialBuildState): this;
  57844. }
  57845. }
  57846. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57850. /**
  57851. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57852. */
  57853. export class ColorSplitterBlock extends NodeMaterialBlock {
  57854. /**
  57855. * Create a new ColorSplitterBlock
  57856. * @param name defines the block name
  57857. */
  57858. constructor(name: string);
  57859. /**
  57860. * Gets the current class name
  57861. * @returns the class name
  57862. */
  57863. getClassName(): string;
  57864. /**
  57865. * Gets the rgba component (input)
  57866. */
  57867. readonly rgba: NodeMaterialConnectionPoint;
  57868. /**
  57869. * Gets the rgb component (input)
  57870. */
  57871. readonly rgbIn: NodeMaterialConnectionPoint;
  57872. /**
  57873. * Gets the rgb component (output)
  57874. */
  57875. readonly rgbOut: NodeMaterialConnectionPoint;
  57876. /**
  57877. * Gets the r component (output)
  57878. */
  57879. readonly r: NodeMaterialConnectionPoint;
  57880. /**
  57881. * Gets the g component (output)
  57882. */
  57883. readonly g: NodeMaterialConnectionPoint;
  57884. /**
  57885. * Gets the b component (output)
  57886. */
  57887. readonly b: NodeMaterialConnectionPoint;
  57888. /**
  57889. * Gets the a component (output)
  57890. */
  57891. readonly a: NodeMaterialConnectionPoint;
  57892. protected _inputRename(name: string): string;
  57893. protected _outputRename(name: string): string;
  57894. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57895. }
  57896. }
  57897. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57901. /**
  57902. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57903. */
  57904. export class VectorSplitterBlock extends NodeMaterialBlock {
  57905. /**
  57906. * Create a new VectorSplitterBlock
  57907. * @param name defines the block name
  57908. */
  57909. constructor(name: string);
  57910. /**
  57911. * Gets the current class name
  57912. * @returns the class name
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Gets the xyzw component (input)
  57917. */
  57918. readonly xyzw: NodeMaterialConnectionPoint;
  57919. /**
  57920. * Gets the xyz component (input)
  57921. */
  57922. readonly xyzIn: NodeMaterialConnectionPoint;
  57923. /**
  57924. * Gets the xy component (input)
  57925. */
  57926. readonly xyIn: NodeMaterialConnectionPoint;
  57927. /**
  57928. * Gets the xyz component (output)
  57929. */
  57930. readonly xyzOut: NodeMaterialConnectionPoint;
  57931. /**
  57932. * Gets the xy component (output)
  57933. */
  57934. readonly xyOut: NodeMaterialConnectionPoint;
  57935. /**
  57936. * Gets the x component (output)
  57937. */
  57938. readonly x: NodeMaterialConnectionPoint;
  57939. /**
  57940. * Gets the y component (output)
  57941. */
  57942. readonly y: NodeMaterialConnectionPoint;
  57943. /**
  57944. * Gets the z component (output)
  57945. */
  57946. readonly z: NodeMaterialConnectionPoint;
  57947. /**
  57948. * Gets the w component (output)
  57949. */
  57950. readonly w: NodeMaterialConnectionPoint;
  57951. protected _inputRename(name: string): string;
  57952. protected _outputRename(name: string): string;
  57953. protected _buildBlock(state: NodeMaterialBuildState): this;
  57954. }
  57955. }
  57956. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57960. /**
  57961. * Block used to lerp between 2 values
  57962. */
  57963. export class LerpBlock extends NodeMaterialBlock {
  57964. /**
  57965. * Creates a new LerpBlock
  57966. * @param name defines the block name
  57967. */
  57968. constructor(name: string);
  57969. /**
  57970. * Gets the current class name
  57971. * @returns the class name
  57972. */
  57973. getClassName(): string;
  57974. /**
  57975. * Gets the left operand input component
  57976. */
  57977. readonly left: NodeMaterialConnectionPoint;
  57978. /**
  57979. * Gets the right operand input component
  57980. */
  57981. readonly right: NodeMaterialConnectionPoint;
  57982. /**
  57983. * Gets the gradient operand input component
  57984. */
  57985. readonly gradient: NodeMaterialConnectionPoint;
  57986. /**
  57987. * Gets the output component
  57988. */
  57989. readonly output: NodeMaterialConnectionPoint;
  57990. protected _buildBlock(state: NodeMaterialBuildState): this;
  57991. }
  57992. }
  57993. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57997. /**
  57998. * Block used to divide 2 vectors
  57999. */
  58000. export class DivideBlock extends NodeMaterialBlock {
  58001. /**
  58002. * Creates a new DivideBlock
  58003. * @param name defines the block name
  58004. */
  58005. constructor(name: string);
  58006. /**
  58007. * Gets the current class name
  58008. * @returns the class name
  58009. */
  58010. getClassName(): string;
  58011. /**
  58012. * Gets the left operand input component
  58013. */
  58014. readonly left: NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the right operand input component
  58017. */
  58018. readonly right: NodeMaterialConnectionPoint;
  58019. /**
  58020. * Gets the output component
  58021. */
  58022. readonly output: NodeMaterialConnectionPoint;
  58023. protected _buildBlock(state: NodeMaterialBuildState): this;
  58024. }
  58025. }
  58026. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58027. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58030. /**
  58031. * Block used to subtract 2 vectors
  58032. */
  58033. export class SubtractBlock extends NodeMaterialBlock {
  58034. /**
  58035. * Creates a new SubtractBlock
  58036. * @param name defines the block name
  58037. */
  58038. constructor(name: string);
  58039. /**
  58040. * Gets the current class name
  58041. * @returns the class name
  58042. */
  58043. getClassName(): string;
  58044. /**
  58045. * Gets the left operand input component
  58046. */
  58047. readonly left: NodeMaterialConnectionPoint;
  58048. /**
  58049. * Gets the right operand input component
  58050. */
  58051. readonly right: NodeMaterialConnectionPoint;
  58052. /**
  58053. * Gets the output component
  58054. */
  58055. readonly output: NodeMaterialConnectionPoint;
  58056. protected _buildBlock(state: NodeMaterialBuildState): this;
  58057. }
  58058. }
  58059. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58063. /**
  58064. * Block used to step a value
  58065. */
  58066. export class StepBlock extends NodeMaterialBlock {
  58067. /**
  58068. * Creates a new StepBlock
  58069. * @param name defines the block name
  58070. */
  58071. constructor(name: string);
  58072. /**
  58073. * Gets the current class name
  58074. * @returns the class name
  58075. */
  58076. getClassName(): string;
  58077. /**
  58078. * Gets the value operand input component
  58079. */
  58080. readonly value: NodeMaterialConnectionPoint;
  58081. /**
  58082. * Gets the edge operand input component
  58083. */
  58084. readonly edge: NodeMaterialConnectionPoint;
  58085. /**
  58086. * Gets the output component
  58087. */
  58088. readonly output: NodeMaterialConnectionPoint;
  58089. protected _buildBlock(state: NodeMaterialBuildState): this;
  58090. }
  58091. }
  58092. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58096. /**
  58097. * Block used to get the opposite (1 - x) of a value
  58098. */
  58099. export class OneMinusBlock extends NodeMaterialBlock {
  58100. /**
  58101. * Creates a new OneMinusBlock
  58102. * @param name defines the block name
  58103. */
  58104. constructor(name: string);
  58105. /**
  58106. * Gets the current class name
  58107. * @returns the class name
  58108. */
  58109. getClassName(): string;
  58110. /**
  58111. * Gets the input component
  58112. */
  58113. readonly input: NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the output component
  58116. */
  58117. readonly output: NodeMaterialConnectionPoint;
  58118. protected _buildBlock(state: NodeMaterialBuildState): this;
  58119. }
  58120. }
  58121. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58125. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58126. /**
  58127. * Block used to get the view direction
  58128. */
  58129. export class ViewDirectionBlock extends NodeMaterialBlock {
  58130. /**
  58131. * Creates a new ViewDirectionBlock
  58132. * @param name defines the block name
  58133. */
  58134. constructor(name: string);
  58135. /**
  58136. * Gets the current class name
  58137. * @returns the class name
  58138. */
  58139. getClassName(): string;
  58140. /**
  58141. * Gets the world position component
  58142. */
  58143. readonly worldPosition: NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the camera position component
  58146. */
  58147. readonly cameraPosition: NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the output component
  58150. */
  58151. readonly output: NodeMaterialConnectionPoint;
  58152. autoConfigure(material: NodeMaterial): void;
  58153. protected _buildBlock(state: NodeMaterialBuildState): this;
  58154. }
  58155. }
  58156. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58160. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58161. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58162. /**
  58163. * Block used to compute fresnel value
  58164. */
  58165. export class FresnelBlock extends NodeMaterialBlock {
  58166. /**
  58167. * Create a new FresnelBlock
  58168. * @param name defines the block name
  58169. */
  58170. constructor(name: string);
  58171. /**
  58172. * Gets the current class name
  58173. * @returns the class name
  58174. */
  58175. getClassName(): string;
  58176. /**
  58177. * Gets the world normal input component
  58178. */
  58179. readonly worldNormal: NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the view direction input component
  58182. */
  58183. readonly viewDirection: NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the bias input component
  58186. */
  58187. readonly bias: NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the camera (or eye) position component
  58190. */
  58191. readonly power: NodeMaterialConnectionPoint;
  58192. /**
  58193. * Gets the fresnel output component
  58194. */
  58195. readonly fresnel: NodeMaterialConnectionPoint;
  58196. autoConfigure(material: NodeMaterial): void;
  58197. protected _buildBlock(state: NodeMaterialBuildState): this;
  58198. }
  58199. }
  58200. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58204. /**
  58205. * Block used to get the max of 2 values
  58206. */
  58207. export class MaxBlock extends NodeMaterialBlock {
  58208. /**
  58209. * Creates a new MaxBlock
  58210. * @param name defines the block name
  58211. */
  58212. constructor(name: string);
  58213. /**
  58214. * Gets the current class name
  58215. * @returns the class name
  58216. */
  58217. getClassName(): string;
  58218. /**
  58219. * Gets the left operand input component
  58220. */
  58221. readonly left: NodeMaterialConnectionPoint;
  58222. /**
  58223. * Gets the right operand input component
  58224. */
  58225. readonly right: NodeMaterialConnectionPoint;
  58226. /**
  58227. * Gets the output component
  58228. */
  58229. readonly output: NodeMaterialConnectionPoint;
  58230. protected _buildBlock(state: NodeMaterialBuildState): this;
  58231. }
  58232. }
  58233. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58237. /**
  58238. * Block used to get the min of 2 values
  58239. */
  58240. export class MinBlock extends NodeMaterialBlock {
  58241. /**
  58242. * Creates a new MinBlock
  58243. * @param name defines the block name
  58244. */
  58245. constructor(name: string);
  58246. /**
  58247. * Gets the current class name
  58248. * @returns the class name
  58249. */
  58250. getClassName(): string;
  58251. /**
  58252. * Gets the left operand input component
  58253. */
  58254. readonly left: NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the right operand input component
  58257. */
  58258. readonly right: NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the output component
  58261. */
  58262. readonly output: NodeMaterialConnectionPoint;
  58263. protected _buildBlock(state: NodeMaterialBuildState): this;
  58264. }
  58265. }
  58266. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58270. /**
  58271. * Block used to get the distance between 2 values
  58272. */
  58273. export class DistanceBlock extends NodeMaterialBlock {
  58274. /**
  58275. * Creates a new DistanceBlock
  58276. * @param name defines the block name
  58277. */
  58278. constructor(name: string);
  58279. /**
  58280. * Gets the current class name
  58281. * @returns the class name
  58282. */
  58283. getClassName(): string;
  58284. /**
  58285. * Gets the left operand input component
  58286. */
  58287. readonly left: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the right operand input component
  58290. */
  58291. readonly right: NodeMaterialConnectionPoint;
  58292. /**
  58293. * Gets the output component
  58294. */
  58295. readonly output: NodeMaterialConnectionPoint;
  58296. protected _buildBlock(state: NodeMaterialBuildState): this;
  58297. }
  58298. }
  58299. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58301. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58303. /**
  58304. * Block used to get the length of a vector
  58305. */
  58306. export class LengthBlock extends NodeMaterialBlock {
  58307. /**
  58308. * Creates a new LengthBlock
  58309. * @param name defines the block name
  58310. */
  58311. constructor(name: string);
  58312. /**
  58313. * Gets the current class name
  58314. * @returns the class name
  58315. */
  58316. getClassName(): string;
  58317. /**
  58318. * Gets the value input component
  58319. */
  58320. readonly value: NodeMaterialConnectionPoint;
  58321. /**
  58322. * Gets the output component
  58323. */
  58324. readonly output: NodeMaterialConnectionPoint;
  58325. protected _buildBlock(state: NodeMaterialBuildState): this;
  58326. }
  58327. }
  58328. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58332. /**
  58333. * Block used to get negative version of a value (i.e. x * -1)
  58334. */
  58335. export class NegateBlock extends NodeMaterialBlock {
  58336. /**
  58337. * Creates a new NegateBlock
  58338. * @param name defines the block name
  58339. */
  58340. constructor(name: string);
  58341. /**
  58342. * Gets the current class name
  58343. * @returns the class name
  58344. */
  58345. getClassName(): string;
  58346. /**
  58347. * Gets the value input component
  58348. */
  58349. readonly value: NodeMaterialConnectionPoint;
  58350. /**
  58351. * Gets the output component
  58352. */
  58353. readonly output: NodeMaterialConnectionPoint;
  58354. protected _buildBlock(state: NodeMaterialBuildState): this;
  58355. }
  58356. }
  58357. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58361. /**
  58362. * Block used to get the value of the first parameter raised to the power of the second
  58363. */
  58364. export class PowBlock extends NodeMaterialBlock {
  58365. /**
  58366. * Creates a new PowBlock
  58367. * @param name defines the block name
  58368. */
  58369. constructor(name: string);
  58370. /**
  58371. * Gets the current class name
  58372. * @returns the class name
  58373. */
  58374. getClassName(): string;
  58375. /**
  58376. * Gets the value operand input component
  58377. */
  58378. readonly value: NodeMaterialConnectionPoint;
  58379. /**
  58380. * Gets the power operand input component
  58381. */
  58382. readonly power: NodeMaterialConnectionPoint;
  58383. /**
  58384. * Gets the output component
  58385. */
  58386. readonly output: NodeMaterialConnectionPoint;
  58387. protected _buildBlock(state: NodeMaterialBuildState): this;
  58388. }
  58389. }
  58390. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58395. /**
  58396. * Block used to get a random number
  58397. */
  58398. export class RandomNumberBlock extends NodeMaterialBlock {
  58399. /**
  58400. * Creates a new RandomNumberBlock
  58401. * @param name defines the block name
  58402. */
  58403. constructor(name: string);
  58404. /**
  58405. * Gets the current class name
  58406. * @returns the class name
  58407. */
  58408. getClassName(): string;
  58409. /**
  58410. * Gets the seed input component
  58411. */
  58412. readonly seed: NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the output component
  58415. */
  58416. readonly output: NodeMaterialConnectionPoint;
  58417. protected _buildBlock(state: NodeMaterialBuildState): this;
  58418. }
  58419. }
  58420. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58424. /**
  58425. * Block used to compute arc tangent of 2 values
  58426. */
  58427. export class ArcTan2Block extends NodeMaterialBlock {
  58428. /**
  58429. * Creates a new ArcTan2Block
  58430. * @param name defines the block name
  58431. */
  58432. constructor(name: string);
  58433. /**
  58434. * Gets the current class name
  58435. * @returns the class name
  58436. */
  58437. getClassName(): string;
  58438. /**
  58439. * Gets the x operand input component
  58440. */
  58441. readonly x: NodeMaterialConnectionPoint;
  58442. /**
  58443. * Gets the y operand input component
  58444. */
  58445. readonly y: NodeMaterialConnectionPoint;
  58446. /**
  58447. * Gets the output component
  58448. */
  58449. readonly output: NodeMaterialConnectionPoint;
  58450. protected _buildBlock(state: NodeMaterialBuildState): this;
  58451. }
  58452. }
  58453. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58455. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58457. /**
  58458. * Block used to smooth step a value
  58459. */
  58460. export class SmoothStepBlock extends NodeMaterialBlock {
  58461. /**
  58462. * Creates a new SmoothStepBlock
  58463. * @param name defines the block name
  58464. */
  58465. constructor(name: string);
  58466. /**
  58467. * Gets the current class name
  58468. * @returns the class name
  58469. */
  58470. getClassName(): string;
  58471. /**
  58472. * Gets the value operand input component
  58473. */
  58474. readonly value: NodeMaterialConnectionPoint;
  58475. /**
  58476. * Gets the first edge operand input component
  58477. */
  58478. readonly edge0: NodeMaterialConnectionPoint;
  58479. /**
  58480. * Gets the second edge operand input component
  58481. */
  58482. readonly edge1: NodeMaterialConnectionPoint;
  58483. /**
  58484. * Gets the output component
  58485. */
  58486. readonly output: NodeMaterialConnectionPoint;
  58487. protected _buildBlock(state: NodeMaterialBuildState): this;
  58488. }
  58489. }
  58490. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58494. /**
  58495. * Block used to get the reciprocal (1 / x) of a value
  58496. */
  58497. export class ReciprocalBlock extends NodeMaterialBlock {
  58498. /**
  58499. * Creates a new ReciprocalBlock
  58500. * @param name defines the block name
  58501. */
  58502. constructor(name: string);
  58503. /**
  58504. * Gets the current class name
  58505. * @returns the class name
  58506. */
  58507. getClassName(): string;
  58508. /**
  58509. * Gets the input component
  58510. */
  58511. readonly input: NodeMaterialConnectionPoint;
  58512. /**
  58513. * Gets the output component
  58514. */
  58515. readonly output: NodeMaterialConnectionPoint;
  58516. protected _buildBlock(state: NodeMaterialBuildState): this;
  58517. }
  58518. }
  58519. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58523. /**
  58524. * Block used to replace a color by another one
  58525. */
  58526. export class ReplaceColorBlock extends NodeMaterialBlock {
  58527. /**
  58528. * Creates a new ReplaceColorBlock
  58529. * @param name defines the block name
  58530. */
  58531. constructor(name: string);
  58532. /**
  58533. * Gets the current class name
  58534. * @returns the class name
  58535. */
  58536. getClassName(): string;
  58537. /**
  58538. * Gets the value input component
  58539. */
  58540. readonly value: NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the reference input component
  58543. */
  58544. readonly reference: NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the distance input component
  58547. */
  58548. readonly distance: NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the replacement input component
  58551. */
  58552. readonly replacement: NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the output component
  58555. */
  58556. readonly output: NodeMaterialConnectionPoint;
  58557. protected _buildBlock(state: NodeMaterialBuildState): this;
  58558. }
  58559. }
  58560. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58564. /**
  58565. * Block used to posterize a value
  58566. * @see https://en.wikipedia.org/wiki/Posterization
  58567. */
  58568. export class PosterizeBlock extends NodeMaterialBlock {
  58569. /**
  58570. * Creates a new PosterizeBlock
  58571. * @param name defines the block name
  58572. */
  58573. constructor(name: string);
  58574. /**
  58575. * Gets the current class name
  58576. * @returns the class name
  58577. */
  58578. getClassName(): string;
  58579. /**
  58580. * Gets the value input component
  58581. */
  58582. readonly value: NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the steps input component
  58585. */
  58586. readonly steps: NodeMaterialConnectionPoint;
  58587. /**
  58588. * Gets the output component
  58589. */
  58590. readonly output: NodeMaterialConnectionPoint;
  58591. protected _buildBlock(state: NodeMaterialBuildState): this;
  58592. }
  58593. }
  58594. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58598. import { Scene } from "babylonjs/scene";
  58599. /**
  58600. * Operations supported by the Wave block
  58601. */
  58602. export enum WaveBlockKind {
  58603. /** SawTooth */
  58604. SawTooth = 0,
  58605. /** Square */
  58606. Square = 1,
  58607. /** Triangle */
  58608. Triangle = 2
  58609. }
  58610. /**
  58611. * Block used to apply wave operation to floats
  58612. */
  58613. export class WaveBlock extends NodeMaterialBlock {
  58614. /**
  58615. * Gets or sets the kibnd of wave to be applied by the block
  58616. */
  58617. kind: WaveBlockKind;
  58618. /**
  58619. * Creates a new WaveBlock
  58620. * @param name defines the block name
  58621. */
  58622. constructor(name: string);
  58623. /**
  58624. * Gets the current class name
  58625. * @returns the class name
  58626. */
  58627. getClassName(): string;
  58628. /**
  58629. * Gets the input component
  58630. */
  58631. readonly input: NodeMaterialConnectionPoint;
  58632. /**
  58633. * Gets the output component
  58634. */
  58635. readonly output: NodeMaterialConnectionPoint;
  58636. protected _buildBlock(state: NodeMaterialBuildState): this;
  58637. serialize(): any;
  58638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58639. }
  58640. }
  58641. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58645. import { Color3 } from "babylonjs/Maths/math.color";
  58646. import { Scene } from "babylonjs/scene";
  58647. /**
  58648. * Class used to store a color step for the GradientBlock
  58649. */
  58650. export class GradientBlockColorStep {
  58651. /**
  58652. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58653. */
  58654. step: number;
  58655. /**
  58656. * Gets or sets the color associated with this step
  58657. */
  58658. color: Color3;
  58659. /**
  58660. * Creates a new GradientBlockColorStep
  58661. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58662. * @param color defines the color associated with this step
  58663. */
  58664. constructor(
  58665. /**
  58666. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58667. */
  58668. step: number,
  58669. /**
  58670. * Gets or sets the color associated with this step
  58671. */
  58672. color: Color3);
  58673. }
  58674. /**
  58675. * Block used to return a color from a gradient based on an input value between 0 and 1
  58676. */
  58677. export class GradientBlock extends NodeMaterialBlock {
  58678. /**
  58679. * Gets or sets the list of color steps
  58680. */
  58681. colorSteps: GradientBlockColorStep[];
  58682. /**
  58683. * Creates a new GradientBlock
  58684. * @param name defines the block name
  58685. */
  58686. constructor(name: string);
  58687. /**
  58688. * Gets the current class name
  58689. * @returns the class name
  58690. */
  58691. getClassName(): string;
  58692. /**
  58693. * Gets the gradient input component
  58694. */
  58695. readonly gradient: NodeMaterialConnectionPoint;
  58696. /**
  58697. * Gets the output component
  58698. */
  58699. readonly output: NodeMaterialConnectionPoint;
  58700. private _writeColorConstant;
  58701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58702. serialize(): any;
  58703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58704. protected _dumpPropertiesCode(): string;
  58705. }
  58706. }
  58707. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58711. /**
  58712. * Block used to normalize lerp between 2 values
  58713. */
  58714. export class NLerpBlock extends NodeMaterialBlock {
  58715. /**
  58716. * Creates a new NLerpBlock
  58717. * @param name defines the block name
  58718. */
  58719. constructor(name: string);
  58720. /**
  58721. * Gets the current class name
  58722. * @returns the class name
  58723. */
  58724. getClassName(): string;
  58725. /**
  58726. * Gets the left operand input component
  58727. */
  58728. readonly left: NodeMaterialConnectionPoint;
  58729. /**
  58730. * Gets the right operand input component
  58731. */
  58732. readonly right: NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the gradient operand input component
  58735. */
  58736. readonly gradient: NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. readonly output: NodeMaterialConnectionPoint;
  58741. protected _buildBlock(state: NodeMaterialBuildState): this;
  58742. }
  58743. }
  58744. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58748. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58749. /**
  58750. * Block used to test if the fragment shader is front facing
  58751. */
  58752. export class FrontFacingBlock extends NodeMaterialBlock {
  58753. /**
  58754. * Creates a new FrontFacingBlock
  58755. * @param name defines the block name
  58756. */
  58757. constructor(name: string);
  58758. /**
  58759. * Gets the current class name
  58760. * @returns the class name
  58761. */
  58762. getClassName(): string;
  58763. /**
  58764. * Gets the world normal component
  58765. */
  58766. readonly worldNormal: NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the view direction input component
  58769. */
  58770. readonly viewDirection: NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the output component
  58773. */
  58774. readonly output: NodeMaterialConnectionPoint;
  58775. autoConfigure(material: NodeMaterial): void;
  58776. protected _buildBlock(state: NodeMaterialBuildState): this;
  58777. }
  58778. }
  58779. declare module "babylonjs/Materials/Node/Blocks/index" {
  58780. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58781. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58782. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58783. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58784. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58785. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58786. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58787. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58788. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58789. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58790. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58791. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58792. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58793. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58794. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58795. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58796. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58797. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58798. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58799. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58800. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58801. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58802. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58803. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58804. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58805. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58806. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58807. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58808. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58809. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58810. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58811. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58812. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58813. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58814. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58815. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58816. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58817. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58818. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58819. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58820. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  58821. }
  58822. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58823. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58824. }
  58825. declare module "babylonjs/Materials/Node/index" {
  58826. export * from "babylonjs/Materials/Node/Enums/index";
  58827. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58828. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58829. export * from "babylonjs/Materials/Node/nodeMaterial";
  58830. export * from "babylonjs/Materials/Node/Blocks/index";
  58831. export * from "babylonjs/Materials/Node/Optimizers/index";
  58832. }
  58833. declare module "babylonjs/Materials/effectRenderer" {
  58834. import { Nullable } from "babylonjs/types";
  58835. import { Texture } from "babylonjs/Materials/Textures/texture";
  58836. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58837. import { Viewport } from "babylonjs/Maths/math.viewport";
  58838. import { Observable } from "babylonjs/Misc/observable";
  58839. import { Effect } from "babylonjs/Materials/effect";
  58840. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58841. import "babylonjs/Shaders/postprocess.vertex";
  58842. /**
  58843. * Effect Render Options
  58844. */
  58845. export interface IEffectRendererOptions {
  58846. /**
  58847. * Defines the vertices positions.
  58848. */
  58849. positions?: number[];
  58850. /**
  58851. * Defines the indices.
  58852. */
  58853. indices?: number[];
  58854. }
  58855. /**
  58856. * Helper class to render one or more effects
  58857. */
  58858. export class EffectRenderer {
  58859. private engine;
  58860. private static _DefaultOptions;
  58861. private _vertexBuffers;
  58862. private _indexBuffer;
  58863. private _ringBufferIndex;
  58864. private _ringScreenBuffer;
  58865. private _fullscreenViewport;
  58866. private _getNextFrameBuffer;
  58867. /**
  58868. * Creates an effect renderer
  58869. * @param engine the engine to use for rendering
  58870. * @param options defines the options of the effect renderer
  58871. */
  58872. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58873. /**
  58874. * Sets the current viewport in normalized coordinates 0-1
  58875. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58876. */
  58877. setViewport(viewport?: Viewport): void;
  58878. /**
  58879. * Binds the embedded attributes buffer to the effect.
  58880. * @param effect Defines the effect to bind the attributes for
  58881. */
  58882. bindBuffers(effect: Effect): void;
  58883. /**
  58884. * Sets the current effect wrapper to use during draw.
  58885. * The effect needs to be ready before calling this api.
  58886. * This also sets the default full screen position attribute.
  58887. * @param effectWrapper Defines the effect to draw with
  58888. */
  58889. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58890. /**
  58891. * Draws a full screen quad.
  58892. */
  58893. draw(): void;
  58894. /**
  58895. * renders one or more effects to a specified texture
  58896. * @param effectWrappers list of effects to renderer
  58897. * @param outputTexture texture to draw to, if null it will render to the screen
  58898. */
  58899. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58900. /**
  58901. * Disposes of the effect renderer
  58902. */
  58903. dispose(): void;
  58904. }
  58905. /**
  58906. * Options to create an EffectWrapper
  58907. */
  58908. interface EffectWrapperCreationOptions {
  58909. /**
  58910. * Engine to use to create the effect
  58911. */
  58912. engine: ThinEngine;
  58913. /**
  58914. * Fragment shader for the effect
  58915. */
  58916. fragmentShader: string;
  58917. /**
  58918. * Vertex shader for the effect
  58919. */
  58920. vertexShader?: string;
  58921. /**
  58922. * Attributes to use in the shader
  58923. */
  58924. attributeNames?: Array<string>;
  58925. /**
  58926. * Uniforms to use in the shader
  58927. */
  58928. uniformNames?: Array<string>;
  58929. /**
  58930. * Texture sampler names to use in the shader
  58931. */
  58932. samplerNames?: Array<string>;
  58933. /**
  58934. * The friendly name of the effect displayed in Spector.
  58935. */
  58936. name?: string;
  58937. }
  58938. /**
  58939. * Wraps an effect to be used for rendering
  58940. */
  58941. export class EffectWrapper {
  58942. /**
  58943. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58944. */
  58945. onApplyObservable: Observable<{}>;
  58946. /**
  58947. * The underlying effect
  58948. */
  58949. effect: Effect;
  58950. /**
  58951. * Creates an effect to be renderer
  58952. * @param creationOptions options to create the effect
  58953. */
  58954. constructor(creationOptions: EffectWrapperCreationOptions);
  58955. /**
  58956. * Disposes of the effect wrapper
  58957. */
  58958. dispose(): void;
  58959. }
  58960. }
  58961. declare module "babylonjs/Materials/index" {
  58962. export * from "babylonjs/Materials/Background/index";
  58963. export * from "babylonjs/Materials/colorCurves";
  58964. export * from "babylonjs/Materials/iEffectFallbacks";
  58965. export * from "babylonjs/Materials/effectFallbacks";
  58966. export * from "babylonjs/Materials/effect";
  58967. export * from "babylonjs/Materials/fresnelParameters";
  58968. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58969. export * from "babylonjs/Materials/material";
  58970. export * from "babylonjs/Materials/materialDefines";
  58971. export * from "babylonjs/Materials/materialHelper";
  58972. export * from "babylonjs/Materials/multiMaterial";
  58973. export * from "babylonjs/Materials/PBR/index";
  58974. export * from "babylonjs/Materials/pushMaterial";
  58975. export * from "babylonjs/Materials/shaderMaterial";
  58976. export * from "babylonjs/Materials/standardMaterial";
  58977. export * from "babylonjs/Materials/Textures/index";
  58978. export * from "babylonjs/Materials/uniformBuffer";
  58979. export * from "babylonjs/Materials/materialFlags";
  58980. export * from "babylonjs/Materials/Node/index";
  58981. export * from "babylonjs/Materials/effectRenderer";
  58982. }
  58983. declare module "babylonjs/Maths/index" {
  58984. export * from "babylonjs/Maths/math.scalar";
  58985. export * from "babylonjs/Maths/math";
  58986. export * from "babylonjs/Maths/sphericalPolynomial";
  58987. }
  58988. declare module "babylonjs/Misc/workerPool" {
  58989. import { IDisposable } from "babylonjs/scene";
  58990. /**
  58991. * Helper class to push actions to a pool of workers.
  58992. */
  58993. export class WorkerPool implements IDisposable {
  58994. private _workerInfos;
  58995. private _pendingActions;
  58996. /**
  58997. * Constructor
  58998. * @param workers Array of workers to use for actions
  58999. */
  59000. constructor(workers: Array<Worker>);
  59001. /**
  59002. * Terminates all workers and clears any pending actions.
  59003. */
  59004. dispose(): void;
  59005. /**
  59006. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59007. * pended until a worker has completed its action.
  59008. * @param action The action to perform. Call onComplete when the action is complete.
  59009. */
  59010. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59011. private _execute;
  59012. }
  59013. }
  59014. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59015. import { IDisposable } from "babylonjs/scene";
  59016. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59017. /**
  59018. * Configuration for Draco compression
  59019. */
  59020. export interface IDracoCompressionConfiguration {
  59021. /**
  59022. * Configuration for the decoder.
  59023. */
  59024. decoder: {
  59025. /**
  59026. * The url to the WebAssembly module.
  59027. */
  59028. wasmUrl?: string;
  59029. /**
  59030. * The url to the WebAssembly binary.
  59031. */
  59032. wasmBinaryUrl?: string;
  59033. /**
  59034. * The url to the fallback JavaScript module.
  59035. */
  59036. fallbackUrl?: string;
  59037. };
  59038. }
  59039. /**
  59040. * Draco compression (https://google.github.io/draco/)
  59041. *
  59042. * This class wraps the Draco module.
  59043. *
  59044. * **Encoder**
  59045. *
  59046. * The encoder is not currently implemented.
  59047. *
  59048. * **Decoder**
  59049. *
  59050. * 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.
  59051. *
  59052. * To update the configuration, use the following code:
  59053. * ```javascript
  59054. * DracoCompression.Configuration = {
  59055. * decoder: {
  59056. * wasmUrl: "<url to the WebAssembly library>",
  59057. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59058. * fallbackUrl: "<url to the fallback JavaScript library>",
  59059. * }
  59060. * };
  59061. * ```
  59062. *
  59063. * 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.
  59064. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59065. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59066. *
  59067. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59068. * ```javascript
  59069. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59070. * ```
  59071. *
  59072. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59073. */
  59074. export class DracoCompression implements IDisposable {
  59075. private _workerPoolPromise?;
  59076. private _decoderModulePromise?;
  59077. /**
  59078. * The configuration. Defaults to the following urls:
  59079. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59080. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59081. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59082. */
  59083. static Configuration: IDracoCompressionConfiguration;
  59084. /**
  59085. * Returns true if the decoder configuration is available.
  59086. */
  59087. static readonly DecoderAvailable: boolean;
  59088. /**
  59089. * Default number of workers to create when creating the draco compression object.
  59090. */
  59091. static DefaultNumWorkers: number;
  59092. private static GetDefaultNumWorkers;
  59093. private static _Default;
  59094. /**
  59095. * Default instance for the draco compression object.
  59096. */
  59097. static readonly Default: DracoCompression;
  59098. /**
  59099. * Constructor
  59100. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59101. */
  59102. constructor(numWorkers?: number);
  59103. /**
  59104. * Stop all async operations and release resources.
  59105. */
  59106. dispose(): void;
  59107. /**
  59108. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59109. * @returns a promise that resolves when ready
  59110. */
  59111. whenReadyAsync(): Promise<void>;
  59112. /**
  59113. * Decode Draco compressed mesh data to vertex data.
  59114. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59115. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59116. * @returns A promise that resolves with the decoded vertex data
  59117. */
  59118. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59119. [kind: string]: number;
  59120. }): Promise<VertexData>;
  59121. }
  59122. }
  59123. declare module "babylonjs/Meshes/Compression/index" {
  59124. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59125. }
  59126. declare module "babylonjs/Meshes/csg" {
  59127. import { Nullable } from "babylonjs/types";
  59128. import { Scene } from "babylonjs/scene";
  59129. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59130. import { Mesh } from "babylonjs/Meshes/mesh";
  59131. import { Material } from "babylonjs/Materials/material";
  59132. /**
  59133. * Class for building Constructive Solid Geometry
  59134. */
  59135. export class CSG {
  59136. private polygons;
  59137. /**
  59138. * The world matrix
  59139. */
  59140. matrix: Matrix;
  59141. /**
  59142. * Stores the position
  59143. */
  59144. position: Vector3;
  59145. /**
  59146. * Stores the rotation
  59147. */
  59148. rotation: Vector3;
  59149. /**
  59150. * Stores the rotation quaternion
  59151. */
  59152. rotationQuaternion: Nullable<Quaternion>;
  59153. /**
  59154. * Stores the scaling vector
  59155. */
  59156. scaling: Vector3;
  59157. /**
  59158. * Convert the Mesh to CSG
  59159. * @param mesh The Mesh to convert to CSG
  59160. * @returns A new CSG from the Mesh
  59161. */
  59162. static FromMesh(mesh: Mesh): CSG;
  59163. /**
  59164. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59165. * @param polygons Polygons used to construct a CSG solid
  59166. */
  59167. private static FromPolygons;
  59168. /**
  59169. * Clones, or makes a deep copy, of the CSG
  59170. * @returns A new CSG
  59171. */
  59172. clone(): CSG;
  59173. /**
  59174. * Unions this CSG with another CSG
  59175. * @param csg The CSG to union against this CSG
  59176. * @returns The unioned CSG
  59177. */
  59178. union(csg: CSG): CSG;
  59179. /**
  59180. * Unions this CSG with another CSG in place
  59181. * @param csg The CSG to union against this CSG
  59182. */
  59183. unionInPlace(csg: CSG): void;
  59184. /**
  59185. * Subtracts this CSG with another CSG
  59186. * @param csg The CSG to subtract against this CSG
  59187. * @returns A new CSG
  59188. */
  59189. subtract(csg: CSG): CSG;
  59190. /**
  59191. * Subtracts this CSG with another CSG in place
  59192. * @param csg The CSG to subtact against this CSG
  59193. */
  59194. subtractInPlace(csg: CSG): void;
  59195. /**
  59196. * Intersect this CSG with another CSG
  59197. * @param csg The CSG to intersect against this CSG
  59198. * @returns A new CSG
  59199. */
  59200. intersect(csg: CSG): CSG;
  59201. /**
  59202. * Intersects this CSG with another CSG in place
  59203. * @param csg The CSG to intersect against this CSG
  59204. */
  59205. intersectInPlace(csg: CSG): void;
  59206. /**
  59207. * Return a new CSG solid with solid and empty space switched. This solid is
  59208. * not modified.
  59209. * @returns A new CSG solid with solid and empty space switched
  59210. */
  59211. inverse(): CSG;
  59212. /**
  59213. * Inverses the CSG in place
  59214. */
  59215. inverseInPlace(): void;
  59216. /**
  59217. * This is used to keep meshes transformations so they can be restored
  59218. * when we build back a Babylon Mesh
  59219. * NB : All CSG operations are performed in world coordinates
  59220. * @param csg The CSG to copy the transform attributes from
  59221. * @returns This CSG
  59222. */
  59223. copyTransformAttributes(csg: CSG): CSG;
  59224. /**
  59225. * Build Raw mesh from CSG
  59226. * Coordinates here are in world space
  59227. * @param name The name of the mesh geometry
  59228. * @param scene The Scene
  59229. * @param keepSubMeshes Specifies if the submeshes should be kept
  59230. * @returns A new Mesh
  59231. */
  59232. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59233. /**
  59234. * Build Mesh from CSG taking material and transforms into account
  59235. * @param name The name of the Mesh
  59236. * @param material The material of the Mesh
  59237. * @param scene The Scene
  59238. * @param keepSubMeshes Specifies if submeshes should be kept
  59239. * @returns The new Mesh
  59240. */
  59241. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59242. }
  59243. }
  59244. declare module "babylonjs/Meshes/trailMesh" {
  59245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import { Scene } from "babylonjs/scene";
  59248. /**
  59249. * Class used to create a trail following a mesh
  59250. */
  59251. export class TrailMesh extends Mesh {
  59252. private _generator;
  59253. private _autoStart;
  59254. private _running;
  59255. private _diameter;
  59256. private _length;
  59257. private _sectionPolygonPointsCount;
  59258. private _sectionVectors;
  59259. private _sectionNormalVectors;
  59260. private _beforeRenderObserver;
  59261. /**
  59262. * @constructor
  59263. * @param name The value used by scene.getMeshByName() to do a lookup.
  59264. * @param generator The mesh to generate a trail.
  59265. * @param scene The scene to add this mesh to.
  59266. * @param diameter Diameter of trailing mesh. Default is 1.
  59267. * @param length Length of trailing mesh. Default is 60.
  59268. * @param autoStart Automatically start trailing mesh. Default true.
  59269. */
  59270. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59271. /**
  59272. * "TrailMesh"
  59273. * @returns "TrailMesh"
  59274. */
  59275. getClassName(): string;
  59276. private _createMesh;
  59277. /**
  59278. * Start trailing mesh.
  59279. */
  59280. start(): void;
  59281. /**
  59282. * Stop trailing mesh.
  59283. */
  59284. stop(): void;
  59285. /**
  59286. * Update trailing mesh geometry.
  59287. */
  59288. update(): void;
  59289. /**
  59290. * Returns a new TrailMesh object.
  59291. * @param name is a string, the name given to the new mesh
  59292. * @param newGenerator use new generator object for cloned trail mesh
  59293. * @returns a new mesh
  59294. */
  59295. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59296. /**
  59297. * Serializes this trail mesh
  59298. * @param serializationObject object to write serialization to
  59299. */
  59300. serialize(serializationObject: any): void;
  59301. /**
  59302. * Parses a serialized trail mesh
  59303. * @param parsedMesh the serialized mesh
  59304. * @param scene the scene to create the trail mesh in
  59305. * @returns the created trail mesh
  59306. */
  59307. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59308. }
  59309. }
  59310. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59311. import { Nullable } from "babylonjs/types";
  59312. import { Scene } from "babylonjs/scene";
  59313. import { Vector4 } from "babylonjs/Maths/math.vector";
  59314. import { Color4 } from "babylonjs/Maths/math.color";
  59315. import { Mesh } from "babylonjs/Meshes/mesh";
  59316. /**
  59317. * Class containing static functions to help procedurally build meshes
  59318. */
  59319. export class TiledBoxBuilder {
  59320. /**
  59321. * Creates a box mesh
  59322. * 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)
  59323. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59327. * @param name defines the name of the mesh
  59328. * @param options defines the options used to create the mesh
  59329. * @param scene defines the hosting scene
  59330. * @returns the box mesh
  59331. */
  59332. static CreateTiledBox(name: string, options: {
  59333. pattern?: number;
  59334. width?: number;
  59335. height?: number;
  59336. depth?: number;
  59337. tileSize?: number;
  59338. tileWidth?: number;
  59339. tileHeight?: number;
  59340. alignHorizontal?: number;
  59341. alignVertical?: number;
  59342. faceUV?: Vector4[];
  59343. faceColors?: Color4[];
  59344. sideOrientation?: number;
  59345. updatable?: boolean;
  59346. }, scene?: Nullable<Scene>): Mesh;
  59347. }
  59348. }
  59349. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59350. import { Vector4 } from "babylonjs/Maths/math.vector";
  59351. import { Mesh } from "babylonjs/Meshes/mesh";
  59352. /**
  59353. * Class containing static functions to help procedurally build meshes
  59354. */
  59355. export class TorusKnotBuilder {
  59356. /**
  59357. * Creates a torus knot mesh
  59358. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59359. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59360. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59361. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59365. * @param name defines the name of the mesh
  59366. * @param options defines the options used to create the mesh
  59367. * @param scene defines the hosting scene
  59368. * @returns the torus knot mesh
  59369. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59370. */
  59371. static CreateTorusKnot(name: string, options: {
  59372. radius?: number;
  59373. tube?: number;
  59374. radialSegments?: number;
  59375. tubularSegments?: number;
  59376. p?: number;
  59377. q?: number;
  59378. updatable?: boolean;
  59379. sideOrientation?: number;
  59380. frontUVs?: Vector4;
  59381. backUVs?: Vector4;
  59382. }, scene: any): Mesh;
  59383. }
  59384. }
  59385. declare module "babylonjs/Meshes/polygonMesh" {
  59386. import { Scene } from "babylonjs/scene";
  59387. import { Vector2 } from "babylonjs/Maths/math.vector";
  59388. import { Mesh } from "babylonjs/Meshes/mesh";
  59389. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59390. import { Path2 } from "babylonjs/Maths/math.path";
  59391. /**
  59392. * Polygon
  59393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59394. */
  59395. export class Polygon {
  59396. /**
  59397. * Creates a rectangle
  59398. * @param xmin bottom X coord
  59399. * @param ymin bottom Y coord
  59400. * @param xmax top X coord
  59401. * @param ymax top Y coord
  59402. * @returns points that make the resulting rectation
  59403. */
  59404. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59405. /**
  59406. * Creates a circle
  59407. * @param radius radius of circle
  59408. * @param cx scale in x
  59409. * @param cy scale in y
  59410. * @param numberOfSides number of sides that make up the circle
  59411. * @returns points that make the resulting circle
  59412. */
  59413. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59414. /**
  59415. * Creates a polygon from input string
  59416. * @param input Input polygon data
  59417. * @returns the parsed points
  59418. */
  59419. static Parse(input: string): Vector2[];
  59420. /**
  59421. * Starts building a polygon from x and y coordinates
  59422. * @param x x coordinate
  59423. * @param y y coordinate
  59424. * @returns the started path2
  59425. */
  59426. static StartingAt(x: number, y: number): Path2;
  59427. }
  59428. /**
  59429. * Builds a polygon
  59430. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59431. */
  59432. export class PolygonMeshBuilder {
  59433. private _points;
  59434. private _outlinepoints;
  59435. private _holes;
  59436. private _name;
  59437. private _scene;
  59438. private _epoints;
  59439. private _eholes;
  59440. private _addToepoint;
  59441. /**
  59442. * Babylon reference to the earcut plugin.
  59443. */
  59444. bjsEarcut: any;
  59445. /**
  59446. * Creates a PolygonMeshBuilder
  59447. * @param name name of the builder
  59448. * @param contours Path of the polygon
  59449. * @param scene scene to add to when creating the mesh
  59450. * @param earcutInjection can be used to inject your own earcut reference
  59451. */
  59452. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59453. /**
  59454. * Adds a whole within the polygon
  59455. * @param hole Array of points defining the hole
  59456. * @returns this
  59457. */
  59458. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59459. /**
  59460. * Creates the polygon
  59461. * @param updatable If the mesh should be updatable
  59462. * @param depth The depth of the mesh created
  59463. * @returns the created mesh
  59464. */
  59465. build(updatable?: boolean, depth?: number): Mesh;
  59466. /**
  59467. * Creates the polygon
  59468. * @param depth The depth of the mesh created
  59469. * @returns the created VertexData
  59470. */
  59471. buildVertexData(depth?: number): VertexData;
  59472. /**
  59473. * Adds a side to the polygon
  59474. * @param positions points that make the polygon
  59475. * @param normals normals of the polygon
  59476. * @param uvs uvs of the polygon
  59477. * @param indices indices of the polygon
  59478. * @param bounds bounds of the polygon
  59479. * @param points points of the polygon
  59480. * @param depth depth of the polygon
  59481. * @param flip flip of the polygon
  59482. */
  59483. private addSide;
  59484. }
  59485. }
  59486. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59487. import { Scene } from "babylonjs/scene";
  59488. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59489. import { Color4 } from "babylonjs/Maths/math.color";
  59490. import { Mesh } from "babylonjs/Meshes/mesh";
  59491. import { Nullable } from "babylonjs/types";
  59492. /**
  59493. * Class containing static functions to help procedurally build meshes
  59494. */
  59495. export class PolygonBuilder {
  59496. /**
  59497. * Creates a polygon mesh
  59498. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59499. * * 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
  59500. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59503. * * Remember you can only change the shape positions, not their number when updating a polygon
  59504. * @param name defines the name of the mesh
  59505. * @param options defines the options used to create the mesh
  59506. * @param scene defines the hosting scene
  59507. * @param earcutInjection can be used to inject your own earcut reference
  59508. * @returns the polygon mesh
  59509. */
  59510. static CreatePolygon(name: string, options: {
  59511. shape: Vector3[];
  59512. holes?: Vector3[][];
  59513. depth?: number;
  59514. faceUV?: Vector4[];
  59515. faceColors?: Color4[];
  59516. updatable?: boolean;
  59517. sideOrientation?: number;
  59518. frontUVs?: Vector4;
  59519. backUVs?: Vector4;
  59520. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59521. /**
  59522. * Creates an extruded polygon mesh, with depth in the Y direction.
  59523. * * 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)
  59524. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59525. * @param name defines the name of the mesh
  59526. * @param options defines the options used to create the mesh
  59527. * @param scene defines the hosting scene
  59528. * @param earcutInjection can be used to inject your own earcut reference
  59529. * @returns the polygon mesh
  59530. */
  59531. static ExtrudePolygon(name: string, options: {
  59532. shape: Vector3[];
  59533. holes?: Vector3[][];
  59534. depth?: number;
  59535. faceUV?: Vector4[];
  59536. faceColors?: Color4[];
  59537. updatable?: boolean;
  59538. sideOrientation?: number;
  59539. frontUVs?: Vector4;
  59540. backUVs?: Vector4;
  59541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59542. }
  59543. }
  59544. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59545. import { Scene } from "babylonjs/scene";
  59546. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59547. import { Mesh } from "babylonjs/Meshes/mesh";
  59548. import { Nullable } from "babylonjs/types";
  59549. /**
  59550. * Class containing static functions to help procedurally build meshes
  59551. */
  59552. export class LatheBuilder {
  59553. /**
  59554. * Creates lathe mesh.
  59555. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59556. * * 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
  59557. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59558. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59559. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59560. * * 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
  59561. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59562. * * 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
  59563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59567. * @param name defines the name of the mesh
  59568. * @param options defines the options used to create the mesh
  59569. * @param scene defines the hosting scene
  59570. * @returns the lathe mesh
  59571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59572. */
  59573. static CreateLathe(name: string, options: {
  59574. shape: Vector3[];
  59575. radius?: number;
  59576. tessellation?: number;
  59577. clip?: number;
  59578. arc?: number;
  59579. closed?: boolean;
  59580. updatable?: boolean;
  59581. sideOrientation?: number;
  59582. frontUVs?: Vector4;
  59583. backUVs?: Vector4;
  59584. cap?: number;
  59585. invertUV?: boolean;
  59586. }, scene?: Nullable<Scene>): Mesh;
  59587. }
  59588. }
  59589. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59590. import { Nullable } from "babylonjs/types";
  59591. import { Scene } from "babylonjs/scene";
  59592. import { Vector4 } from "babylonjs/Maths/math.vector";
  59593. import { Mesh } from "babylonjs/Meshes/mesh";
  59594. /**
  59595. * Class containing static functions to help procedurally build meshes
  59596. */
  59597. export class TiledPlaneBuilder {
  59598. /**
  59599. * Creates a tiled plane mesh
  59600. * * The parameter `pattern` will, depending on value, do nothing or
  59601. * * * flip (reflect about central vertical) alternate tiles across and up
  59602. * * * flip every tile on alternate rows
  59603. * * * rotate (180 degs) alternate tiles across and up
  59604. * * * rotate every tile on alternate rows
  59605. * * * flip and rotate alternate tiles across and up
  59606. * * * flip and rotate every tile on alternate rows
  59607. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59608. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59611. * * 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)
  59612. * * 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)
  59613. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59614. * @param name defines the name of the mesh
  59615. * @param options defines the options used to create the mesh
  59616. * @param scene defines the hosting scene
  59617. * @returns the box mesh
  59618. */
  59619. static CreateTiledPlane(name: string, options: {
  59620. pattern?: number;
  59621. tileSize?: number;
  59622. tileWidth?: number;
  59623. tileHeight?: number;
  59624. size?: number;
  59625. width?: number;
  59626. height?: number;
  59627. alignHorizontal?: number;
  59628. alignVertical?: number;
  59629. sideOrientation?: number;
  59630. frontUVs?: Vector4;
  59631. backUVs?: Vector4;
  59632. updatable?: boolean;
  59633. }, scene?: Nullable<Scene>): Mesh;
  59634. }
  59635. }
  59636. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59637. import { Nullable } from "babylonjs/types";
  59638. import { Scene } from "babylonjs/scene";
  59639. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59640. import { Mesh } from "babylonjs/Meshes/mesh";
  59641. /**
  59642. * Class containing static functions to help procedurally build meshes
  59643. */
  59644. export class TubeBuilder {
  59645. /**
  59646. * Creates a tube mesh.
  59647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59652. * * 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)
  59653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59654. * * 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
  59655. * * 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
  59656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59660. * @param name defines the name of the mesh
  59661. * @param options defines the options used to create the mesh
  59662. * @param scene defines the hosting scene
  59663. * @returns the tube mesh
  59664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59666. */
  59667. static CreateTube(name: string, options: {
  59668. path: Vector3[];
  59669. radius?: number;
  59670. tessellation?: number;
  59671. radiusFunction?: {
  59672. (i: number, distance: number): number;
  59673. };
  59674. cap?: number;
  59675. arc?: number;
  59676. updatable?: boolean;
  59677. sideOrientation?: number;
  59678. frontUVs?: Vector4;
  59679. backUVs?: Vector4;
  59680. instance?: Mesh;
  59681. invertUV?: boolean;
  59682. }, scene?: Nullable<Scene>): Mesh;
  59683. }
  59684. }
  59685. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59686. import { Scene } from "babylonjs/scene";
  59687. import { Vector4 } from "babylonjs/Maths/math.vector";
  59688. import { Mesh } from "babylonjs/Meshes/mesh";
  59689. import { Nullable } from "babylonjs/types";
  59690. /**
  59691. * Class containing static functions to help procedurally build meshes
  59692. */
  59693. export class IcoSphereBuilder {
  59694. /**
  59695. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59696. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59697. * * 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`)
  59698. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59699. * * 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
  59700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59703. * @param name defines the name of the mesh
  59704. * @param options defines the options used to create the mesh
  59705. * @param scene defines the hosting scene
  59706. * @returns the icosahedron mesh
  59707. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59708. */
  59709. static CreateIcoSphere(name: string, options: {
  59710. radius?: number;
  59711. radiusX?: number;
  59712. radiusY?: number;
  59713. radiusZ?: number;
  59714. flat?: boolean;
  59715. subdivisions?: number;
  59716. sideOrientation?: number;
  59717. frontUVs?: Vector4;
  59718. backUVs?: Vector4;
  59719. updatable?: boolean;
  59720. }, scene?: Nullable<Scene>): Mesh;
  59721. }
  59722. }
  59723. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59724. import { Vector3 } from "babylonjs/Maths/math.vector";
  59725. import { Mesh } from "babylonjs/Meshes/mesh";
  59726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59727. /**
  59728. * Class containing static functions to help procedurally build meshes
  59729. */
  59730. export class DecalBuilder {
  59731. /**
  59732. * Creates a decal mesh.
  59733. * 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
  59734. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59735. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59736. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59737. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59738. * @param name defines the name of the mesh
  59739. * @param sourceMesh defines the mesh where the decal must be applied
  59740. * @param options defines the options used to create the mesh
  59741. * @param scene defines the hosting scene
  59742. * @returns the decal mesh
  59743. * @see https://doc.babylonjs.com/how_to/decals
  59744. */
  59745. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59746. position?: Vector3;
  59747. normal?: Vector3;
  59748. size?: Vector3;
  59749. angle?: number;
  59750. }): Mesh;
  59751. }
  59752. }
  59753. declare module "babylonjs/Meshes/meshBuilder" {
  59754. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59755. import { Nullable } from "babylonjs/types";
  59756. import { Scene } from "babylonjs/scene";
  59757. import { Mesh } from "babylonjs/Meshes/mesh";
  59758. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59759. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59762. import { Plane } from "babylonjs/Maths/math.plane";
  59763. /**
  59764. * Class containing static functions to help procedurally build meshes
  59765. */
  59766. export class MeshBuilder {
  59767. /**
  59768. * Creates a box mesh
  59769. * * The parameter `size` sets the size (float) of each box side (default 1)
  59770. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59771. * * 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)
  59772. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59776. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59777. * @param name defines the name of the mesh
  59778. * @param options defines the options used to create the mesh
  59779. * @param scene defines the hosting scene
  59780. * @returns the box mesh
  59781. */
  59782. static CreateBox(name: string, options: {
  59783. size?: number;
  59784. width?: number;
  59785. height?: number;
  59786. depth?: number;
  59787. faceUV?: Vector4[];
  59788. faceColors?: Color4[];
  59789. sideOrientation?: number;
  59790. frontUVs?: Vector4;
  59791. backUVs?: Vector4;
  59792. updatable?: boolean;
  59793. }, scene?: Nullable<Scene>): Mesh;
  59794. /**
  59795. * Creates a tiled box mesh
  59796. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59798. * @param name defines the name of the mesh
  59799. * @param options defines the options used to create the mesh
  59800. * @param scene defines the hosting scene
  59801. * @returns the tiled box mesh
  59802. */
  59803. static CreateTiledBox(name: string, options: {
  59804. pattern?: number;
  59805. size?: number;
  59806. width?: number;
  59807. height?: number;
  59808. depth: number;
  59809. tileSize?: number;
  59810. tileWidth?: number;
  59811. tileHeight?: number;
  59812. faceUV?: Vector4[];
  59813. faceColors?: Color4[];
  59814. alignHorizontal?: number;
  59815. alignVertical?: number;
  59816. sideOrientation?: number;
  59817. updatable?: boolean;
  59818. }, scene?: Nullable<Scene>): Mesh;
  59819. /**
  59820. * Creates a sphere mesh
  59821. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59822. * * 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`)
  59823. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59824. * * 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
  59825. * * 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)
  59826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59829. * @param name defines the name of the mesh
  59830. * @param options defines the options used to create the mesh
  59831. * @param scene defines the hosting scene
  59832. * @returns the sphere mesh
  59833. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59834. */
  59835. static CreateSphere(name: string, options: {
  59836. segments?: number;
  59837. diameter?: number;
  59838. diameterX?: number;
  59839. diameterY?: number;
  59840. diameterZ?: number;
  59841. arc?: number;
  59842. slice?: number;
  59843. sideOrientation?: number;
  59844. frontUVs?: Vector4;
  59845. backUVs?: Vector4;
  59846. updatable?: boolean;
  59847. }, scene?: Nullable<Scene>): Mesh;
  59848. /**
  59849. * Creates a plane polygonal mesh. By default, this is a disc
  59850. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59851. * * 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
  59852. * * 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
  59853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59856. * @param name defines the name of the mesh
  59857. * @param options defines the options used to create the mesh
  59858. * @param scene defines the hosting scene
  59859. * @returns the plane polygonal mesh
  59860. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59861. */
  59862. static CreateDisc(name: string, options: {
  59863. radius?: number;
  59864. tessellation?: number;
  59865. arc?: number;
  59866. updatable?: boolean;
  59867. sideOrientation?: number;
  59868. frontUVs?: Vector4;
  59869. backUVs?: Vector4;
  59870. }, scene?: Nullable<Scene>): Mesh;
  59871. /**
  59872. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59873. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59874. * * 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`)
  59875. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59876. * * 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
  59877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59880. * @param name defines the name of the mesh
  59881. * @param options defines the options used to create the mesh
  59882. * @param scene defines the hosting scene
  59883. * @returns the icosahedron mesh
  59884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59885. */
  59886. static CreateIcoSphere(name: string, options: {
  59887. radius?: number;
  59888. radiusX?: number;
  59889. radiusY?: number;
  59890. radiusZ?: number;
  59891. flat?: boolean;
  59892. subdivisions?: number;
  59893. sideOrientation?: number;
  59894. frontUVs?: Vector4;
  59895. backUVs?: Vector4;
  59896. updatable?: boolean;
  59897. }, scene?: Nullable<Scene>): Mesh;
  59898. /**
  59899. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59900. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59901. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59902. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59903. * * 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
  59904. * * 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
  59905. * * 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
  59906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59909. * * 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
  59910. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59911. * * 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
  59912. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59914. * @param name defines the name of the mesh
  59915. * @param options defines the options used to create the mesh
  59916. * @param scene defines the hosting scene
  59917. * @returns the ribbon mesh
  59918. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59920. */
  59921. static CreateRibbon(name: string, options: {
  59922. pathArray: Vector3[][];
  59923. closeArray?: boolean;
  59924. closePath?: boolean;
  59925. offset?: number;
  59926. updatable?: boolean;
  59927. sideOrientation?: number;
  59928. frontUVs?: Vector4;
  59929. backUVs?: Vector4;
  59930. instance?: Mesh;
  59931. invertUV?: boolean;
  59932. uvs?: Vector2[];
  59933. colors?: Color4[];
  59934. }, scene?: Nullable<Scene>): Mesh;
  59935. /**
  59936. * Creates a cylinder or a cone mesh
  59937. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59938. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59939. * * 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.
  59940. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59941. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59942. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59943. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59944. * * 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).
  59945. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59946. * * 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).
  59947. * * 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
  59948. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59949. * * 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
  59950. * * 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.
  59951. * * If `enclose` is false, a ring surface is one element.
  59952. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59953. * * 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
  59954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59957. * @param name defines the name of the mesh
  59958. * @param options defines the options used to create the mesh
  59959. * @param scene defines the hosting scene
  59960. * @returns the cylinder mesh
  59961. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59962. */
  59963. static CreateCylinder(name: string, options: {
  59964. height?: number;
  59965. diameterTop?: number;
  59966. diameterBottom?: number;
  59967. diameter?: number;
  59968. tessellation?: number;
  59969. subdivisions?: number;
  59970. arc?: number;
  59971. faceColors?: Color4[];
  59972. faceUV?: Vector4[];
  59973. updatable?: boolean;
  59974. hasRings?: boolean;
  59975. enclose?: boolean;
  59976. cap?: number;
  59977. sideOrientation?: number;
  59978. frontUVs?: Vector4;
  59979. backUVs?: Vector4;
  59980. }, scene?: Nullable<Scene>): Mesh;
  59981. /**
  59982. * Creates a torus mesh
  59983. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59984. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59985. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59989. * @param name defines the name of the mesh
  59990. * @param options defines the options used to create the mesh
  59991. * @param scene defines the hosting scene
  59992. * @returns the torus mesh
  59993. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59994. */
  59995. static CreateTorus(name: string, options: {
  59996. diameter?: number;
  59997. thickness?: number;
  59998. tessellation?: number;
  59999. updatable?: boolean;
  60000. sideOrientation?: number;
  60001. frontUVs?: Vector4;
  60002. backUVs?: Vector4;
  60003. }, scene?: Nullable<Scene>): Mesh;
  60004. /**
  60005. * Creates a torus knot mesh
  60006. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60007. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60008. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60009. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60013. * @param name defines the name of the mesh
  60014. * @param options defines the options used to create the mesh
  60015. * @param scene defines the hosting scene
  60016. * @returns the torus knot mesh
  60017. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60018. */
  60019. static CreateTorusKnot(name: string, options: {
  60020. radius?: number;
  60021. tube?: number;
  60022. radialSegments?: number;
  60023. tubularSegments?: number;
  60024. p?: number;
  60025. q?: number;
  60026. updatable?: boolean;
  60027. sideOrientation?: number;
  60028. frontUVs?: Vector4;
  60029. backUVs?: Vector4;
  60030. }, scene?: Nullable<Scene>): Mesh;
  60031. /**
  60032. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60033. * * 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
  60034. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60035. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60036. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60037. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60038. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60039. * * 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
  60040. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60043. * @param name defines the name of the new line system
  60044. * @param options defines the options used to create the line system
  60045. * @param scene defines the hosting scene
  60046. * @returns a new line system mesh
  60047. */
  60048. static CreateLineSystem(name: string, options: {
  60049. lines: Vector3[][];
  60050. updatable?: boolean;
  60051. instance?: Nullable<LinesMesh>;
  60052. colors?: Nullable<Color4[][]>;
  60053. useVertexAlpha?: boolean;
  60054. }, scene: Nullable<Scene>): LinesMesh;
  60055. /**
  60056. * Creates a line mesh
  60057. * 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
  60058. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60059. * * The parameter `points` is an array successive Vector3
  60060. * * 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
  60061. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60062. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60063. * * When updating an instance, remember that only point positions can change, not the number of points
  60064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60066. * @param name defines the name of the new line system
  60067. * @param options defines the options used to create the line system
  60068. * @param scene defines the hosting scene
  60069. * @returns a new line mesh
  60070. */
  60071. static CreateLines(name: string, options: {
  60072. points: Vector3[];
  60073. updatable?: boolean;
  60074. instance?: Nullable<LinesMesh>;
  60075. colors?: Color4[];
  60076. useVertexAlpha?: boolean;
  60077. }, scene?: Nullable<Scene>): LinesMesh;
  60078. /**
  60079. * Creates a dashed line mesh
  60080. * * 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
  60081. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60082. * * The parameter `points` is an array successive Vector3
  60083. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60084. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60085. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60086. * * 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
  60087. * * When updating an instance, remember that only point positions can change, not the number of points
  60088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60089. * @param name defines the name of the mesh
  60090. * @param options defines the options used to create the mesh
  60091. * @param scene defines the hosting scene
  60092. * @returns the dashed line mesh
  60093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60094. */
  60095. static CreateDashedLines(name: string, options: {
  60096. points: Vector3[];
  60097. dashSize?: number;
  60098. gapSize?: number;
  60099. dashNb?: number;
  60100. updatable?: boolean;
  60101. instance?: LinesMesh;
  60102. }, scene?: Nullable<Scene>): LinesMesh;
  60103. /**
  60104. * 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.
  60105. * * 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.
  60106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60107. * * 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.
  60108. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60109. * * 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
  60110. * * 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
  60111. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60116. * @param name defines the name of the mesh
  60117. * @param options defines the options used to create the mesh
  60118. * @param scene defines the hosting scene
  60119. * @returns the extruded shape mesh
  60120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60122. */
  60123. static ExtrudeShape(name: string, options: {
  60124. shape: Vector3[];
  60125. path: Vector3[];
  60126. scale?: number;
  60127. rotation?: number;
  60128. cap?: number;
  60129. updatable?: boolean;
  60130. sideOrientation?: number;
  60131. frontUVs?: Vector4;
  60132. backUVs?: Vector4;
  60133. instance?: Mesh;
  60134. invertUV?: boolean;
  60135. }, scene?: Nullable<Scene>): Mesh;
  60136. /**
  60137. * Creates an custom extruded shape mesh.
  60138. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60139. * * 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.
  60140. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60141. * * 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
  60142. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60143. * * 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
  60144. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60145. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60146. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60147. * * 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
  60148. * * 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
  60149. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60154. * @param name defines the name of the mesh
  60155. * @param options defines the options used to create the mesh
  60156. * @param scene defines the hosting scene
  60157. * @returns the custom extruded shape mesh
  60158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60161. */
  60162. static ExtrudeShapeCustom(name: string, options: {
  60163. shape: Vector3[];
  60164. path: Vector3[];
  60165. scaleFunction?: any;
  60166. rotationFunction?: any;
  60167. ribbonCloseArray?: boolean;
  60168. ribbonClosePath?: boolean;
  60169. cap?: number;
  60170. updatable?: boolean;
  60171. sideOrientation?: number;
  60172. frontUVs?: Vector4;
  60173. backUVs?: Vector4;
  60174. instance?: Mesh;
  60175. invertUV?: boolean;
  60176. }, scene?: Nullable<Scene>): Mesh;
  60177. /**
  60178. * Creates lathe mesh.
  60179. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60180. * * 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
  60181. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60182. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60183. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60184. * * 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
  60185. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60186. * * 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
  60187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60191. * @param name defines the name of the mesh
  60192. * @param options defines the options used to create the mesh
  60193. * @param scene defines the hosting scene
  60194. * @returns the lathe mesh
  60195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60196. */
  60197. static CreateLathe(name: string, options: {
  60198. shape: Vector3[];
  60199. radius?: number;
  60200. tessellation?: number;
  60201. clip?: number;
  60202. arc?: number;
  60203. closed?: boolean;
  60204. updatable?: boolean;
  60205. sideOrientation?: number;
  60206. frontUVs?: Vector4;
  60207. backUVs?: Vector4;
  60208. cap?: number;
  60209. invertUV?: boolean;
  60210. }, scene?: Nullable<Scene>): Mesh;
  60211. /**
  60212. * Creates a tiled plane mesh
  60213. * * You can set a limited pattern arrangement with the tiles
  60214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60217. * @param name defines the name of the mesh
  60218. * @param options defines the options used to create the mesh
  60219. * @param scene defines the hosting scene
  60220. * @returns the plane mesh
  60221. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60222. */
  60223. static CreateTiledPlane(name: string, options: {
  60224. pattern?: number;
  60225. tileSize?: number;
  60226. tileWidth?: number;
  60227. tileHeight?: number;
  60228. size?: number;
  60229. width?: number;
  60230. height?: number;
  60231. alignHorizontal?: number;
  60232. alignVertical?: number;
  60233. sideOrientation?: number;
  60234. frontUVs?: Vector4;
  60235. backUVs?: Vector4;
  60236. updatable?: boolean;
  60237. }, scene?: Nullable<Scene>): Mesh;
  60238. /**
  60239. * Creates a plane mesh
  60240. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60241. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60242. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60246. * @param name defines the name of the mesh
  60247. * @param options defines the options used to create the mesh
  60248. * @param scene defines the hosting scene
  60249. * @returns the plane mesh
  60250. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60251. */
  60252. static CreatePlane(name: string, options: {
  60253. size?: number;
  60254. width?: number;
  60255. height?: number;
  60256. sideOrientation?: number;
  60257. frontUVs?: Vector4;
  60258. backUVs?: Vector4;
  60259. updatable?: boolean;
  60260. sourcePlane?: Plane;
  60261. }, scene?: Nullable<Scene>): Mesh;
  60262. /**
  60263. * Creates a ground mesh
  60264. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60265. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60267. * @param name defines the name of the mesh
  60268. * @param options defines the options used to create the mesh
  60269. * @param scene defines the hosting scene
  60270. * @returns the ground mesh
  60271. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60272. */
  60273. static CreateGround(name: string, options: {
  60274. width?: number;
  60275. height?: number;
  60276. subdivisions?: number;
  60277. subdivisionsX?: number;
  60278. subdivisionsY?: number;
  60279. updatable?: boolean;
  60280. }, scene?: Nullable<Scene>): Mesh;
  60281. /**
  60282. * Creates a tiled ground mesh
  60283. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60284. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60285. * * 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
  60286. * * 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
  60287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60288. * @param name defines the name of the mesh
  60289. * @param options defines the options used to create the mesh
  60290. * @param scene defines the hosting scene
  60291. * @returns the tiled ground mesh
  60292. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60293. */
  60294. static CreateTiledGround(name: string, options: {
  60295. xmin: number;
  60296. zmin: number;
  60297. xmax: number;
  60298. zmax: number;
  60299. subdivisions?: {
  60300. w: number;
  60301. h: number;
  60302. };
  60303. precision?: {
  60304. w: number;
  60305. h: number;
  60306. };
  60307. updatable?: boolean;
  60308. }, scene?: Nullable<Scene>): Mesh;
  60309. /**
  60310. * Creates a ground mesh from a height map
  60311. * * The parameter `url` sets the URL of the height map image resource.
  60312. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60313. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60314. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60315. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60316. * * 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.
  60317. * * 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).
  60318. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60320. * @param name defines the name of the mesh
  60321. * @param url defines the url to the height map
  60322. * @param options defines the options used to create the mesh
  60323. * @param scene defines the hosting scene
  60324. * @returns the ground mesh
  60325. * @see https://doc.babylonjs.com/babylon101/height_map
  60326. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60327. */
  60328. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60329. width?: number;
  60330. height?: number;
  60331. subdivisions?: number;
  60332. minHeight?: number;
  60333. maxHeight?: number;
  60334. colorFilter?: Color3;
  60335. alphaFilter?: number;
  60336. updatable?: boolean;
  60337. onReady?: (mesh: GroundMesh) => void;
  60338. }, scene?: Nullable<Scene>): GroundMesh;
  60339. /**
  60340. * Creates a polygon mesh
  60341. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60342. * * 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
  60343. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60346. * * Remember you can only change the shape positions, not their number when updating a polygon
  60347. * @param name defines the name of the mesh
  60348. * @param options defines the options used to create the mesh
  60349. * @param scene defines the hosting scene
  60350. * @param earcutInjection can be used to inject your own earcut reference
  60351. * @returns the polygon mesh
  60352. */
  60353. static CreatePolygon(name: string, options: {
  60354. shape: Vector3[];
  60355. holes?: Vector3[][];
  60356. depth?: number;
  60357. faceUV?: Vector4[];
  60358. faceColors?: Color4[];
  60359. updatable?: boolean;
  60360. sideOrientation?: number;
  60361. frontUVs?: Vector4;
  60362. backUVs?: Vector4;
  60363. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60364. /**
  60365. * Creates an extruded polygon mesh, with depth in the Y direction.
  60366. * * 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)
  60367. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60368. * @param name defines the name of the mesh
  60369. * @param options defines the options used to create the mesh
  60370. * @param scene defines the hosting scene
  60371. * @param earcutInjection can be used to inject your own earcut reference
  60372. * @returns the polygon mesh
  60373. */
  60374. static ExtrudePolygon(name: string, options: {
  60375. shape: Vector3[];
  60376. holes?: Vector3[][];
  60377. depth?: number;
  60378. faceUV?: Vector4[];
  60379. faceColors?: Color4[];
  60380. updatable?: boolean;
  60381. sideOrientation?: number;
  60382. frontUVs?: Vector4;
  60383. backUVs?: Vector4;
  60384. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60385. /**
  60386. * Creates a tube mesh.
  60387. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60388. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60389. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60390. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60391. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60392. * * 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)
  60393. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60394. * * 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
  60395. * * 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
  60396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60398. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60400. * @param name defines the name of the mesh
  60401. * @param options defines the options used to create the mesh
  60402. * @param scene defines the hosting scene
  60403. * @returns the tube mesh
  60404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60405. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60406. */
  60407. static CreateTube(name: string, options: {
  60408. path: Vector3[];
  60409. radius?: number;
  60410. tessellation?: number;
  60411. radiusFunction?: {
  60412. (i: number, distance: number): number;
  60413. };
  60414. cap?: number;
  60415. arc?: number;
  60416. updatable?: boolean;
  60417. sideOrientation?: number;
  60418. frontUVs?: Vector4;
  60419. backUVs?: Vector4;
  60420. instance?: Mesh;
  60421. invertUV?: boolean;
  60422. }, scene?: Nullable<Scene>): Mesh;
  60423. /**
  60424. * Creates a polyhedron mesh
  60425. * * 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
  60426. * * The parameter `size` (positive float, default 1) sets the polygon size
  60427. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60428. * * 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`
  60429. * * 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
  60430. * * 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)`)
  60431. * * 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
  60432. * * 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
  60433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60436. * @param name defines the name of the mesh
  60437. * @param options defines the options used to create the mesh
  60438. * @param scene defines the hosting scene
  60439. * @returns the polyhedron mesh
  60440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60441. */
  60442. static CreatePolyhedron(name: string, options: {
  60443. type?: number;
  60444. size?: number;
  60445. sizeX?: number;
  60446. sizeY?: number;
  60447. sizeZ?: number;
  60448. custom?: any;
  60449. faceUV?: Vector4[];
  60450. faceColors?: Color4[];
  60451. flat?: boolean;
  60452. updatable?: boolean;
  60453. sideOrientation?: number;
  60454. frontUVs?: Vector4;
  60455. backUVs?: Vector4;
  60456. }, scene?: Nullable<Scene>): Mesh;
  60457. /**
  60458. * Creates a decal mesh.
  60459. * 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
  60460. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60461. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60462. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60463. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60464. * @param name defines the name of the mesh
  60465. * @param sourceMesh defines the mesh where the decal must be applied
  60466. * @param options defines the options used to create the mesh
  60467. * @param scene defines the hosting scene
  60468. * @returns the decal mesh
  60469. * @see https://doc.babylonjs.com/how_to/decals
  60470. */
  60471. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60472. position?: Vector3;
  60473. normal?: Vector3;
  60474. size?: Vector3;
  60475. angle?: number;
  60476. }): Mesh;
  60477. }
  60478. }
  60479. declare module "babylonjs/Meshes/meshSimplification" {
  60480. import { Mesh } from "babylonjs/Meshes/mesh";
  60481. /**
  60482. * A simplifier interface for future simplification implementations
  60483. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60484. */
  60485. export interface ISimplifier {
  60486. /**
  60487. * Simplification of a given mesh according to the given settings.
  60488. * Since this requires computation, it is assumed that the function runs async.
  60489. * @param settings The settings of the simplification, including quality and distance
  60490. * @param successCallback A callback that will be called after the mesh was simplified.
  60491. * @param errorCallback in case of an error, this callback will be called. optional.
  60492. */
  60493. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60494. }
  60495. /**
  60496. * Expected simplification settings.
  60497. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60499. */
  60500. export interface ISimplificationSettings {
  60501. /**
  60502. * Gets or sets the expected quality
  60503. */
  60504. quality: number;
  60505. /**
  60506. * Gets or sets the distance when this optimized version should be used
  60507. */
  60508. distance: number;
  60509. /**
  60510. * Gets an already optimized mesh
  60511. */
  60512. optimizeMesh?: boolean;
  60513. }
  60514. /**
  60515. * Class used to specify simplification options
  60516. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60517. */
  60518. export class SimplificationSettings implements ISimplificationSettings {
  60519. /** expected quality */
  60520. quality: number;
  60521. /** distance when this optimized version should be used */
  60522. distance: number;
  60523. /** already optimized mesh */
  60524. optimizeMesh?: boolean | undefined;
  60525. /**
  60526. * Creates a SimplificationSettings
  60527. * @param quality expected quality
  60528. * @param distance distance when this optimized version should be used
  60529. * @param optimizeMesh already optimized mesh
  60530. */
  60531. constructor(
  60532. /** expected quality */
  60533. quality: number,
  60534. /** distance when this optimized version should be used */
  60535. distance: number,
  60536. /** already optimized mesh */
  60537. optimizeMesh?: boolean | undefined);
  60538. }
  60539. /**
  60540. * Interface used to define a simplification task
  60541. */
  60542. export interface ISimplificationTask {
  60543. /**
  60544. * Array of settings
  60545. */
  60546. settings: Array<ISimplificationSettings>;
  60547. /**
  60548. * Simplification type
  60549. */
  60550. simplificationType: SimplificationType;
  60551. /**
  60552. * Mesh to simplify
  60553. */
  60554. mesh: Mesh;
  60555. /**
  60556. * Callback called on success
  60557. */
  60558. successCallback?: () => void;
  60559. /**
  60560. * Defines if parallel processing can be used
  60561. */
  60562. parallelProcessing: boolean;
  60563. }
  60564. /**
  60565. * Queue used to order the simplification tasks
  60566. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60567. */
  60568. export class SimplificationQueue {
  60569. private _simplificationArray;
  60570. /**
  60571. * Gets a boolean indicating that the process is still running
  60572. */
  60573. running: boolean;
  60574. /**
  60575. * Creates a new queue
  60576. */
  60577. constructor();
  60578. /**
  60579. * Adds a new simplification task
  60580. * @param task defines a task to add
  60581. */
  60582. addTask(task: ISimplificationTask): void;
  60583. /**
  60584. * Execute next task
  60585. */
  60586. executeNext(): void;
  60587. /**
  60588. * Execute a simplification task
  60589. * @param task defines the task to run
  60590. */
  60591. runSimplification(task: ISimplificationTask): void;
  60592. private getSimplifier;
  60593. }
  60594. /**
  60595. * The implemented types of simplification
  60596. * At the moment only Quadratic Error Decimation is implemented
  60597. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60598. */
  60599. export enum SimplificationType {
  60600. /** Quadratic error decimation */
  60601. QUADRATIC = 0
  60602. }
  60603. }
  60604. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60605. import { Scene } from "babylonjs/scene";
  60606. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60607. import { ISceneComponent } from "babylonjs/sceneComponent";
  60608. module "babylonjs/scene" {
  60609. interface Scene {
  60610. /** @hidden (Backing field) */
  60611. _simplificationQueue: SimplificationQueue;
  60612. /**
  60613. * Gets or sets the simplification queue attached to the scene
  60614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60615. */
  60616. simplificationQueue: SimplificationQueue;
  60617. }
  60618. }
  60619. module "babylonjs/Meshes/mesh" {
  60620. interface Mesh {
  60621. /**
  60622. * Simplify the mesh according to the given array of settings.
  60623. * Function will return immediately and will simplify async
  60624. * @param settings a collection of simplification settings
  60625. * @param parallelProcessing should all levels calculate parallel or one after the other
  60626. * @param simplificationType the type of simplification to run
  60627. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60628. * @returns the current mesh
  60629. */
  60630. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60631. }
  60632. }
  60633. /**
  60634. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60635. * created in a scene
  60636. */
  60637. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60638. /**
  60639. * The component name helpfull to identify the component in the list of scene components.
  60640. */
  60641. readonly name: string;
  60642. /**
  60643. * The scene the component belongs to.
  60644. */
  60645. scene: Scene;
  60646. /**
  60647. * Creates a new instance of the component for the given scene
  60648. * @param scene Defines the scene to register the component in
  60649. */
  60650. constructor(scene: Scene);
  60651. /**
  60652. * Registers the component in a given scene
  60653. */
  60654. register(): void;
  60655. /**
  60656. * Rebuilds the elements related to this component in case of
  60657. * context lost for instance.
  60658. */
  60659. rebuild(): void;
  60660. /**
  60661. * Disposes the component and the associated ressources
  60662. */
  60663. dispose(): void;
  60664. private _beforeCameraUpdate;
  60665. }
  60666. }
  60667. declare module "babylonjs/Meshes/Builders/index" {
  60668. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60669. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60670. export * from "babylonjs/Meshes/Builders/discBuilder";
  60671. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60672. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60673. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60674. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60675. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60676. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60677. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60678. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60679. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60680. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60681. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60682. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60683. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60684. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60685. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60686. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60687. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60688. }
  60689. declare module "babylonjs/Meshes/index" {
  60690. export * from "babylonjs/Meshes/abstractMesh";
  60691. export * from "babylonjs/Meshes/buffer";
  60692. export * from "babylonjs/Meshes/Compression/index";
  60693. export * from "babylonjs/Meshes/csg";
  60694. export * from "babylonjs/Meshes/geometry";
  60695. export * from "babylonjs/Meshes/groundMesh";
  60696. export * from "babylonjs/Meshes/trailMesh";
  60697. export * from "babylonjs/Meshes/instancedMesh";
  60698. export * from "babylonjs/Meshes/linesMesh";
  60699. export * from "babylonjs/Meshes/mesh";
  60700. export * from "babylonjs/Meshes/mesh.vertexData";
  60701. export * from "babylonjs/Meshes/meshBuilder";
  60702. export * from "babylonjs/Meshes/meshSimplification";
  60703. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60704. export * from "babylonjs/Meshes/polygonMesh";
  60705. export * from "babylonjs/Meshes/subMesh";
  60706. export * from "babylonjs/Meshes/meshLODLevel";
  60707. export * from "babylonjs/Meshes/transformNode";
  60708. export * from "babylonjs/Meshes/Builders/index";
  60709. export * from "babylonjs/Meshes/dataBuffer";
  60710. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60711. }
  60712. declare module "babylonjs/Morph/index" {
  60713. export * from "babylonjs/Morph/morphTarget";
  60714. export * from "babylonjs/Morph/morphTargetManager";
  60715. }
  60716. declare module "babylonjs/Navigation/INavigationEngine" {
  60717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60718. import { Vector3 } from "babylonjs/Maths/math";
  60719. import { Mesh } from "babylonjs/Meshes/mesh";
  60720. import { Scene } from "babylonjs/scene";
  60721. /**
  60722. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60723. */
  60724. export interface INavigationEnginePlugin {
  60725. /**
  60726. * plugin name
  60727. */
  60728. name: string;
  60729. /**
  60730. * Creates a navigation mesh
  60731. * @param meshes array of all the geometry used to compute the navigatio mesh
  60732. * @param parameters bunch of parameters used to filter geometry
  60733. */
  60734. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60735. /**
  60736. * Create a navigation mesh debug mesh
  60737. * @param scene is where the mesh will be added
  60738. * @returns debug display mesh
  60739. */
  60740. createDebugNavMesh(scene: Scene): Mesh;
  60741. /**
  60742. * Get a navigation mesh constrained position, closest to the parameter position
  60743. * @param position world position
  60744. * @returns the closest point to position constrained by the navigation mesh
  60745. */
  60746. getClosestPoint(position: Vector3): Vector3;
  60747. /**
  60748. * Get a navigation mesh constrained position, within a particular radius
  60749. * @param position world position
  60750. * @param maxRadius the maximum distance to the constrained world position
  60751. * @returns the closest point to position constrained by the navigation mesh
  60752. */
  60753. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60754. /**
  60755. * Compute the final position from a segment made of destination-position
  60756. * @param position world position
  60757. * @param destination world position
  60758. * @returns the resulting point along the navmesh
  60759. */
  60760. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60761. /**
  60762. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60763. * @param start world position
  60764. * @param end world position
  60765. * @returns array containing world position composing the path
  60766. */
  60767. computePath(start: Vector3, end: Vector3): Vector3[];
  60768. /**
  60769. * If this plugin is supported
  60770. * @returns true if plugin is supported
  60771. */
  60772. isSupported(): boolean;
  60773. /**
  60774. * Create a new Crowd so you can add agents
  60775. * @param maxAgents the maximum agent count in the crowd
  60776. * @param maxAgentRadius the maximum radius an agent can have
  60777. * @param scene to attach the crowd to
  60778. * @returns the crowd you can add agents to
  60779. */
  60780. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60781. /**
  60782. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60783. * The queries will try to find a solution within those bounds
  60784. * default is (1,1,1)
  60785. * @param extent x,y,z value that define the extent around the queries point of reference
  60786. */
  60787. setDefaultQueryExtent(extent: Vector3): void;
  60788. /**
  60789. * Get the Bounding box extent specified by setDefaultQueryExtent
  60790. * @returns the box extent values
  60791. */
  60792. getDefaultQueryExtent(): Vector3;
  60793. /**
  60794. * Release all resources
  60795. */
  60796. dispose(): void;
  60797. }
  60798. /**
  60799. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60800. */
  60801. export interface ICrowd {
  60802. /**
  60803. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60804. * You can attach anything to that node. The node position is updated in the scene update tick.
  60805. * @param pos world position that will be constrained by the navigation mesh
  60806. * @param parameters agent parameters
  60807. * @param transform hooked to the agent that will be update by the scene
  60808. * @returns agent index
  60809. */
  60810. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60811. /**
  60812. * Returns the agent position in world space
  60813. * @param index agent index returned by addAgent
  60814. * @returns world space position
  60815. */
  60816. getAgentPosition(index: number): Vector3;
  60817. /**
  60818. * Gets the agent velocity in world space
  60819. * @param index agent index returned by addAgent
  60820. * @returns world space velocity
  60821. */
  60822. getAgentVelocity(index: number): Vector3;
  60823. /**
  60824. * remove a particular agent previously created
  60825. * @param index agent index returned by addAgent
  60826. */
  60827. removeAgent(index: number): void;
  60828. /**
  60829. * get the list of all agents attached to this crowd
  60830. * @returns list of agent indices
  60831. */
  60832. getAgents(): number[];
  60833. /**
  60834. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60835. * @param deltaTime in seconds
  60836. */
  60837. update(deltaTime: number): void;
  60838. /**
  60839. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60840. * @param index agent index returned by addAgent
  60841. * @param destination targeted world position
  60842. */
  60843. agentGoto(index: number, destination: Vector3): void;
  60844. /**
  60845. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60846. * The queries will try to find a solution within those bounds
  60847. * default is (1,1,1)
  60848. * @param extent x,y,z value that define the extent around the queries point of reference
  60849. */
  60850. setDefaultQueryExtent(extent: Vector3): void;
  60851. /**
  60852. * Get the Bounding box extent specified by setDefaultQueryExtent
  60853. * @returns the box extent values
  60854. */
  60855. getDefaultQueryExtent(): Vector3;
  60856. /**
  60857. * Release all resources
  60858. */
  60859. dispose(): void;
  60860. }
  60861. /**
  60862. * Configures an agent
  60863. */
  60864. export interface IAgentParameters {
  60865. /**
  60866. * Agent radius. [Limit: >= 0]
  60867. */
  60868. radius: number;
  60869. /**
  60870. * Agent height. [Limit: > 0]
  60871. */
  60872. height: number;
  60873. /**
  60874. * Maximum allowed acceleration. [Limit: >= 0]
  60875. */
  60876. maxAcceleration: number;
  60877. /**
  60878. * Maximum allowed speed. [Limit: >= 0]
  60879. */
  60880. maxSpeed: number;
  60881. /**
  60882. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60883. */
  60884. collisionQueryRange: number;
  60885. /**
  60886. * The path visibility optimization range. [Limit: > 0]
  60887. */
  60888. pathOptimizationRange: number;
  60889. /**
  60890. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60891. */
  60892. separationWeight: number;
  60893. }
  60894. /**
  60895. * Configures the navigation mesh creation
  60896. */
  60897. export interface INavMeshParameters {
  60898. /**
  60899. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60900. */
  60901. cs: number;
  60902. /**
  60903. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60904. */
  60905. ch: number;
  60906. /**
  60907. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60908. */
  60909. walkableSlopeAngle: number;
  60910. /**
  60911. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60912. * be considered walkable. [Limit: >= 3] [Units: vx]
  60913. */
  60914. walkableHeight: number;
  60915. /**
  60916. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60917. */
  60918. walkableClimb: number;
  60919. /**
  60920. * The distance to erode/shrink the walkable area of the heightfield away from
  60921. * obstructions. [Limit: >=0] [Units: vx]
  60922. */
  60923. walkableRadius: number;
  60924. /**
  60925. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60926. */
  60927. maxEdgeLen: number;
  60928. /**
  60929. * The maximum distance a simplfied contour's border edges should deviate
  60930. * the original raw contour. [Limit: >=0] [Units: vx]
  60931. */
  60932. maxSimplificationError: number;
  60933. /**
  60934. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60935. */
  60936. minRegionArea: number;
  60937. /**
  60938. * Any regions with a span count smaller than this value will, if possible,
  60939. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60940. */
  60941. mergeRegionArea: number;
  60942. /**
  60943. * The maximum number of vertices allowed for polygons generated during the
  60944. * contour to polygon conversion process. [Limit: >= 3]
  60945. */
  60946. maxVertsPerPoly: number;
  60947. /**
  60948. * Sets the sampling distance to use when generating the detail mesh.
  60949. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60950. */
  60951. detailSampleDist: number;
  60952. /**
  60953. * The maximum distance the detail mesh surface should deviate from heightfield
  60954. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60955. */
  60956. detailSampleMaxError: number;
  60957. }
  60958. }
  60959. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60960. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60961. import { Mesh } from "babylonjs/Meshes/mesh";
  60962. import { Scene } from "babylonjs/scene";
  60963. import { Vector3 } from "babylonjs/Maths/math";
  60964. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60965. /**
  60966. * RecastJS navigation plugin
  60967. */
  60968. export class RecastJSPlugin implements INavigationEnginePlugin {
  60969. /**
  60970. * Reference to the Recast library
  60971. */
  60972. bjsRECAST: any;
  60973. /**
  60974. * plugin name
  60975. */
  60976. name: string;
  60977. /**
  60978. * the first navmesh created. We might extend this to support multiple navmeshes
  60979. */
  60980. navMesh: any;
  60981. /**
  60982. * Initializes the recastJS plugin
  60983. * @param recastInjection can be used to inject your own recast reference
  60984. */
  60985. constructor(recastInjection?: any);
  60986. /**
  60987. * Creates a navigation mesh
  60988. * @param meshes array of all the geometry used to compute the navigatio mesh
  60989. * @param parameters bunch of parameters used to filter geometry
  60990. */
  60991. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60992. /**
  60993. * Create a navigation mesh debug mesh
  60994. * @param scene is where the mesh will be added
  60995. * @returns debug display mesh
  60996. */
  60997. createDebugNavMesh(scene: Scene): Mesh;
  60998. /**
  60999. * Get a navigation mesh constrained position, closest to the parameter position
  61000. * @param position world position
  61001. * @returns the closest point to position constrained by the navigation mesh
  61002. */
  61003. getClosestPoint(position: Vector3): Vector3;
  61004. /**
  61005. * Get a navigation mesh constrained position, within a particular radius
  61006. * @param position world position
  61007. * @param maxRadius the maximum distance to the constrained world position
  61008. * @returns the closest point to position constrained by the navigation mesh
  61009. */
  61010. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61011. /**
  61012. * Compute the final position from a segment made of destination-position
  61013. * @param position world position
  61014. * @param destination world position
  61015. * @returns the resulting point along the navmesh
  61016. */
  61017. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61018. /**
  61019. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61020. * @param start world position
  61021. * @param end world position
  61022. * @returns array containing world position composing the path
  61023. */
  61024. computePath(start: Vector3, end: Vector3): Vector3[];
  61025. /**
  61026. * Create a new Crowd so you can add agents
  61027. * @param maxAgents the maximum agent count in the crowd
  61028. * @param maxAgentRadius the maximum radius an agent can have
  61029. * @param scene to attach the crowd to
  61030. * @returns the crowd you can add agents to
  61031. */
  61032. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61033. /**
  61034. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61035. * The queries will try to find a solution within those bounds
  61036. * default is (1,1,1)
  61037. * @param extent x,y,z value that define the extent around the queries point of reference
  61038. */
  61039. setDefaultQueryExtent(extent: Vector3): void;
  61040. /**
  61041. * Get the Bounding box extent specified by setDefaultQueryExtent
  61042. * @returns the box extent values
  61043. */
  61044. getDefaultQueryExtent(): Vector3;
  61045. /**
  61046. * Disposes
  61047. */
  61048. dispose(): void;
  61049. /**
  61050. * If this plugin is supported
  61051. * @returns true if plugin is supported
  61052. */
  61053. isSupported(): boolean;
  61054. }
  61055. /**
  61056. * Recast detour crowd implementation
  61057. */
  61058. export class RecastJSCrowd implements ICrowd {
  61059. /**
  61060. * Recast/detour plugin
  61061. */
  61062. bjsRECASTPlugin: RecastJSPlugin;
  61063. /**
  61064. * Link to the detour crowd
  61065. */
  61066. recastCrowd: any;
  61067. /**
  61068. * One transform per agent
  61069. */
  61070. transforms: TransformNode[];
  61071. /**
  61072. * All agents created
  61073. */
  61074. agents: number[];
  61075. /**
  61076. * Link to the scene is kept to unregister the crowd from the scene
  61077. */
  61078. private _scene;
  61079. /**
  61080. * Observer for crowd updates
  61081. */
  61082. private _onBeforeAnimationsObserver;
  61083. /**
  61084. * Constructor
  61085. * @param plugin recastJS plugin
  61086. * @param maxAgents the maximum agent count in the crowd
  61087. * @param maxAgentRadius the maximum radius an agent can have
  61088. * @param scene to attach the crowd to
  61089. * @returns the crowd you can add agents to
  61090. */
  61091. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61092. /**
  61093. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61094. * You can attach anything to that node. The node position is updated in the scene update tick.
  61095. * @param pos world position that will be constrained by the navigation mesh
  61096. * @param parameters agent parameters
  61097. * @param transform hooked to the agent that will be update by the scene
  61098. * @returns agent index
  61099. */
  61100. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61101. /**
  61102. * Returns the agent position in world space
  61103. * @param index agent index returned by addAgent
  61104. * @returns world space position
  61105. */
  61106. getAgentPosition(index: number): Vector3;
  61107. /**
  61108. * Returns the agent velocity in world space
  61109. * @param index agent index returned by addAgent
  61110. * @returns world space velocity
  61111. */
  61112. getAgentVelocity(index: number): Vector3;
  61113. /**
  61114. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61115. * @param index agent index returned by addAgent
  61116. * @param destination targeted world position
  61117. */
  61118. agentGoto(index: number, destination: Vector3): void;
  61119. /**
  61120. * remove a particular agent previously created
  61121. * @param index agent index returned by addAgent
  61122. */
  61123. removeAgent(index: number): void;
  61124. /**
  61125. * get the list of all agents attached to this crowd
  61126. * @returns list of agent indices
  61127. */
  61128. getAgents(): number[];
  61129. /**
  61130. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61131. * @param deltaTime in seconds
  61132. */
  61133. update(deltaTime: number): void;
  61134. /**
  61135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61136. * The queries will try to find a solution within those bounds
  61137. * default is (1,1,1)
  61138. * @param extent x,y,z value that define the extent around the queries point of reference
  61139. */
  61140. setDefaultQueryExtent(extent: Vector3): void;
  61141. /**
  61142. * Get the Bounding box extent specified by setDefaultQueryExtent
  61143. * @returns the box extent values
  61144. */
  61145. getDefaultQueryExtent(): Vector3;
  61146. /**
  61147. * Release all resources
  61148. */
  61149. dispose(): void;
  61150. }
  61151. }
  61152. declare module "babylonjs/Navigation/Plugins/index" {
  61153. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61154. }
  61155. declare module "babylonjs/Navigation/index" {
  61156. export * from "babylonjs/Navigation/INavigationEngine";
  61157. export * from "babylonjs/Navigation/Plugins/index";
  61158. }
  61159. declare module "babylonjs/Offline/database" {
  61160. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61161. /**
  61162. * Class used to enable access to IndexedDB
  61163. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61164. */
  61165. export class Database implements IOfflineProvider {
  61166. private _callbackManifestChecked;
  61167. private _currentSceneUrl;
  61168. private _db;
  61169. private _enableSceneOffline;
  61170. private _enableTexturesOffline;
  61171. private _manifestVersionFound;
  61172. private _mustUpdateRessources;
  61173. private _hasReachedQuota;
  61174. private _isSupported;
  61175. private _idbFactory;
  61176. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61177. private static IsUASupportingBlobStorage;
  61178. /**
  61179. * Gets a boolean indicating if Database storate is enabled (off by default)
  61180. */
  61181. static IDBStorageEnabled: boolean;
  61182. /**
  61183. * Gets a boolean indicating if scene must be saved in the database
  61184. */
  61185. readonly enableSceneOffline: boolean;
  61186. /**
  61187. * Gets a boolean indicating if textures must be saved in the database
  61188. */
  61189. readonly enableTexturesOffline: boolean;
  61190. /**
  61191. * Creates a new Database
  61192. * @param urlToScene defines the url to load the scene
  61193. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61194. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61195. */
  61196. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61197. private static _ParseURL;
  61198. private static _ReturnFullUrlLocation;
  61199. private _checkManifestFile;
  61200. /**
  61201. * Open the database and make it available
  61202. * @param successCallback defines the callback to call on success
  61203. * @param errorCallback defines the callback to call on error
  61204. */
  61205. open(successCallback: () => void, errorCallback: () => void): void;
  61206. /**
  61207. * Loads an image from the database
  61208. * @param url defines the url to load from
  61209. * @param image defines the target DOM image
  61210. */
  61211. loadImage(url: string, image: HTMLImageElement): void;
  61212. private _loadImageFromDBAsync;
  61213. private _saveImageIntoDBAsync;
  61214. private _checkVersionFromDB;
  61215. private _loadVersionFromDBAsync;
  61216. private _saveVersionIntoDBAsync;
  61217. /**
  61218. * Loads a file from database
  61219. * @param url defines the URL to load from
  61220. * @param sceneLoaded defines a callback to call on success
  61221. * @param progressCallBack defines a callback to call when progress changed
  61222. * @param errorCallback defines a callback to call on error
  61223. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61224. */
  61225. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61226. private _loadFileAsync;
  61227. private _saveFileAsync;
  61228. /**
  61229. * Validates if xhr data is correct
  61230. * @param xhr defines the request to validate
  61231. * @param dataType defines the expected data type
  61232. * @returns true if data is correct
  61233. */
  61234. private static _ValidateXHRData;
  61235. }
  61236. }
  61237. declare module "babylonjs/Offline/index" {
  61238. export * from "babylonjs/Offline/database";
  61239. export * from "babylonjs/Offline/IOfflineProvider";
  61240. }
  61241. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61242. /** @hidden */
  61243. export var gpuUpdateParticlesPixelShader: {
  61244. name: string;
  61245. shader: string;
  61246. };
  61247. }
  61248. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61249. /** @hidden */
  61250. export var gpuUpdateParticlesVertexShader: {
  61251. name: string;
  61252. shader: string;
  61253. };
  61254. }
  61255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61256. /** @hidden */
  61257. export var clipPlaneFragmentDeclaration2: {
  61258. name: string;
  61259. shader: string;
  61260. };
  61261. }
  61262. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61268. /** @hidden */
  61269. export var gpuRenderParticlesPixelShader: {
  61270. name: string;
  61271. shader: string;
  61272. };
  61273. }
  61274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61275. /** @hidden */
  61276. export var clipPlaneVertexDeclaration2: {
  61277. name: string;
  61278. shader: string;
  61279. };
  61280. }
  61281. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61282. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61283. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61284. /** @hidden */
  61285. export var gpuRenderParticlesVertexShader: {
  61286. name: string;
  61287. shader: string;
  61288. };
  61289. }
  61290. declare module "babylonjs/Particles/gpuParticleSystem" {
  61291. import { Nullable } from "babylonjs/types";
  61292. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61293. import { Observable } from "babylonjs/Misc/observable";
  61294. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61295. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61296. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61297. import { Scene, IDisposable } from "babylonjs/scene";
  61298. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61300. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61301. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61302. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61303. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61304. /**
  61305. * This represents a GPU particle system in Babylon
  61306. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61307. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61308. */
  61309. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61310. /**
  61311. * The layer mask we are rendering the particles through.
  61312. */
  61313. layerMask: number;
  61314. private _capacity;
  61315. private _activeCount;
  61316. private _currentActiveCount;
  61317. private _accumulatedCount;
  61318. private _renderEffect;
  61319. private _updateEffect;
  61320. private _buffer0;
  61321. private _buffer1;
  61322. private _spriteBuffer;
  61323. private _updateVAO;
  61324. private _renderVAO;
  61325. private _targetIndex;
  61326. private _sourceBuffer;
  61327. private _targetBuffer;
  61328. private _engine;
  61329. private _currentRenderId;
  61330. private _started;
  61331. private _stopped;
  61332. private _timeDelta;
  61333. private _randomTexture;
  61334. private _randomTexture2;
  61335. private _attributesStrideSize;
  61336. private _updateEffectOptions;
  61337. private _randomTextureSize;
  61338. private _actualFrame;
  61339. private readonly _rawTextureWidth;
  61340. /**
  61341. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61342. */
  61343. static readonly IsSupported: boolean;
  61344. /**
  61345. * An event triggered when the system is disposed.
  61346. */
  61347. onDisposeObservable: Observable<GPUParticleSystem>;
  61348. /**
  61349. * Gets the maximum number of particles active at the same time.
  61350. * @returns The max number of active particles.
  61351. */
  61352. getCapacity(): number;
  61353. /**
  61354. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61355. * to override the particles.
  61356. */
  61357. forceDepthWrite: boolean;
  61358. /**
  61359. * Gets or set the number of active particles
  61360. */
  61361. activeParticleCount: number;
  61362. private _preWarmDone;
  61363. /**
  61364. * Is this system ready to be used/rendered
  61365. * @return true if the system is ready
  61366. */
  61367. isReady(): boolean;
  61368. /**
  61369. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61370. * @returns True if it has been started, otherwise false.
  61371. */
  61372. isStarted(): boolean;
  61373. /**
  61374. * Starts the particle system and begins to emit
  61375. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61376. */
  61377. start(delay?: number): void;
  61378. /**
  61379. * Stops the particle system.
  61380. */
  61381. stop(): void;
  61382. /**
  61383. * Remove all active particles
  61384. */
  61385. reset(): void;
  61386. /**
  61387. * Returns the string "GPUParticleSystem"
  61388. * @returns a string containing the class name
  61389. */
  61390. getClassName(): string;
  61391. private _colorGradientsTexture;
  61392. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61393. /**
  61394. * Adds a new color gradient
  61395. * @param gradient defines the gradient to use (between 0 and 1)
  61396. * @param color1 defines the color to affect to the specified gradient
  61397. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61398. * @returns the current particle system
  61399. */
  61400. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61401. /**
  61402. * Remove a specific color gradient
  61403. * @param gradient defines the gradient to remove
  61404. * @returns the current particle system
  61405. */
  61406. removeColorGradient(gradient: number): GPUParticleSystem;
  61407. private _angularSpeedGradientsTexture;
  61408. private _sizeGradientsTexture;
  61409. private _velocityGradientsTexture;
  61410. private _limitVelocityGradientsTexture;
  61411. private _dragGradientsTexture;
  61412. private _addFactorGradient;
  61413. /**
  61414. * Adds a new size gradient
  61415. * @param gradient defines the gradient to use (between 0 and 1)
  61416. * @param factor defines the size factor to affect to the specified gradient
  61417. * @returns the current particle system
  61418. */
  61419. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61420. /**
  61421. * Remove a specific size gradient
  61422. * @param gradient defines the gradient to remove
  61423. * @returns the current particle system
  61424. */
  61425. removeSizeGradient(gradient: number): GPUParticleSystem;
  61426. /**
  61427. * Adds a new angular speed gradient
  61428. * @param gradient defines the gradient to use (between 0 and 1)
  61429. * @param factor defines the angular speed to affect to the specified gradient
  61430. * @returns the current particle system
  61431. */
  61432. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61433. /**
  61434. * Remove a specific angular speed gradient
  61435. * @param gradient defines the gradient to remove
  61436. * @returns the current particle system
  61437. */
  61438. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61439. /**
  61440. * Adds a new velocity gradient
  61441. * @param gradient defines the gradient to use (between 0 and 1)
  61442. * @param factor defines the velocity to affect to the specified gradient
  61443. * @returns the current particle system
  61444. */
  61445. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61446. /**
  61447. * Remove a specific velocity gradient
  61448. * @param gradient defines the gradient to remove
  61449. * @returns the current particle system
  61450. */
  61451. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61452. /**
  61453. * Adds a new limit velocity gradient
  61454. * @param gradient defines the gradient to use (between 0 and 1)
  61455. * @param factor defines the limit velocity value to affect to the specified gradient
  61456. * @returns the current particle system
  61457. */
  61458. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61459. /**
  61460. * Remove a specific limit velocity gradient
  61461. * @param gradient defines the gradient to remove
  61462. * @returns the current particle system
  61463. */
  61464. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61465. /**
  61466. * Adds a new drag gradient
  61467. * @param gradient defines the gradient to use (between 0 and 1)
  61468. * @param factor defines the drag value to affect to the specified gradient
  61469. * @returns the current particle system
  61470. */
  61471. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61472. /**
  61473. * Remove a specific drag gradient
  61474. * @param gradient defines the gradient to remove
  61475. * @returns the current particle system
  61476. */
  61477. removeDragGradient(gradient: number): GPUParticleSystem;
  61478. /**
  61479. * Not supported by GPUParticleSystem
  61480. * @param gradient defines the gradient to use (between 0 and 1)
  61481. * @param factor defines the emit rate value to affect to the specified gradient
  61482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61483. * @returns the current particle system
  61484. */
  61485. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61486. /**
  61487. * Not supported by GPUParticleSystem
  61488. * @param gradient defines the gradient to remove
  61489. * @returns the current particle system
  61490. */
  61491. removeEmitRateGradient(gradient: number): IParticleSystem;
  61492. /**
  61493. * Not supported by GPUParticleSystem
  61494. * @param gradient defines the gradient to use (between 0 and 1)
  61495. * @param factor defines the start size value to affect to the specified gradient
  61496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61497. * @returns the current particle system
  61498. */
  61499. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61500. /**
  61501. * Not supported by GPUParticleSystem
  61502. * @param gradient defines the gradient to remove
  61503. * @returns the current particle system
  61504. */
  61505. removeStartSizeGradient(gradient: number): IParticleSystem;
  61506. /**
  61507. * Not supported by GPUParticleSystem
  61508. * @param gradient defines the gradient to use (between 0 and 1)
  61509. * @param min defines the color remap minimal range
  61510. * @param max defines the color remap maximal range
  61511. * @returns the current particle system
  61512. */
  61513. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61514. /**
  61515. * Not supported by GPUParticleSystem
  61516. * @param gradient defines the gradient to remove
  61517. * @returns the current particle system
  61518. */
  61519. removeColorRemapGradient(): IParticleSystem;
  61520. /**
  61521. * Not supported by GPUParticleSystem
  61522. * @param gradient defines the gradient to use (between 0 and 1)
  61523. * @param min defines the alpha remap minimal range
  61524. * @param max defines the alpha remap maximal range
  61525. * @returns the current particle system
  61526. */
  61527. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61528. /**
  61529. * Not supported by GPUParticleSystem
  61530. * @param gradient defines the gradient to remove
  61531. * @returns the current particle system
  61532. */
  61533. removeAlphaRemapGradient(): IParticleSystem;
  61534. /**
  61535. * Not supported by GPUParticleSystem
  61536. * @param gradient defines the gradient to use (between 0 and 1)
  61537. * @param color defines the color to affect to the specified gradient
  61538. * @returns the current particle system
  61539. */
  61540. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61541. /**
  61542. * Not supported by GPUParticleSystem
  61543. * @param gradient defines the gradient to remove
  61544. * @returns the current particle system
  61545. */
  61546. removeRampGradient(): IParticleSystem;
  61547. /**
  61548. * Not supported by GPUParticleSystem
  61549. * @returns the list of ramp gradients
  61550. */
  61551. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61552. /**
  61553. * Not supported by GPUParticleSystem
  61554. * Gets or sets a boolean indicating that ramp gradients must be used
  61555. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61556. */
  61557. useRampGradients: boolean;
  61558. /**
  61559. * Not supported by GPUParticleSystem
  61560. * @param gradient defines the gradient to use (between 0 and 1)
  61561. * @param factor defines the life time factor to affect to the specified gradient
  61562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61563. * @returns the current particle system
  61564. */
  61565. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61566. /**
  61567. * Not supported by GPUParticleSystem
  61568. * @param gradient defines the gradient to remove
  61569. * @returns the current particle system
  61570. */
  61571. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61572. /**
  61573. * Instantiates a GPU particle system.
  61574. * 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.
  61575. * @param name The name of the particle system
  61576. * @param options The options used to create the system
  61577. * @param scene The scene the particle system belongs to
  61578. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61579. */
  61580. constructor(name: string, options: Partial<{
  61581. capacity: number;
  61582. randomTextureSize: number;
  61583. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61584. protected _reset(): void;
  61585. private _createUpdateVAO;
  61586. private _createRenderVAO;
  61587. private _initialize;
  61588. /** @hidden */
  61589. _recreateUpdateEffect(): void;
  61590. /** @hidden */
  61591. _recreateRenderEffect(): void;
  61592. /**
  61593. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61594. * @param preWarm defines if we are in the pre-warmimg phase
  61595. */
  61596. animate(preWarm?: boolean): void;
  61597. private _createFactorGradientTexture;
  61598. private _createSizeGradientTexture;
  61599. private _createAngularSpeedGradientTexture;
  61600. private _createVelocityGradientTexture;
  61601. private _createLimitVelocityGradientTexture;
  61602. private _createDragGradientTexture;
  61603. private _createColorGradientTexture;
  61604. /**
  61605. * Renders the particle system in its current state
  61606. * @param preWarm defines if the system should only update the particles but not render them
  61607. * @returns the current number of particles
  61608. */
  61609. render(preWarm?: boolean): number;
  61610. /**
  61611. * Rebuilds the particle system
  61612. */
  61613. rebuild(): void;
  61614. private _releaseBuffers;
  61615. private _releaseVAOs;
  61616. /**
  61617. * Disposes the particle system and free the associated resources
  61618. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61619. */
  61620. dispose(disposeTexture?: boolean): void;
  61621. /**
  61622. * Clones the particle system.
  61623. * @param name The name of the cloned object
  61624. * @param newEmitter The new emitter to use
  61625. * @returns the cloned particle system
  61626. */
  61627. clone(name: string, newEmitter: any): GPUParticleSystem;
  61628. /**
  61629. * Serializes the particle system to a JSON object.
  61630. * @returns the JSON object
  61631. */
  61632. serialize(): any;
  61633. /**
  61634. * Parses a JSON object to create a GPU particle system.
  61635. * @param parsedParticleSystem The JSON object to parse
  61636. * @param scene The scene to create the particle system in
  61637. * @param rootUrl The root url to use to load external dependencies like texture
  61638. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61639. * @returns the parsed GPU particle system
  61640. */
  61641. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61642. }
  61643. }
  61644. declare module "babylonjs/Particles/particleSystemSet" {
  61645. import { Nullable } from "babylonjs/types";
  61646. import { Color3 } from "babylonjs/Maths/math.color";
  61647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61649. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61650. import { Scene, IDisposable } from "babylonjs/scene";
  61651. /**
  61652. * Represents a set of particle systems working together to create a specific effect
  61653. */
  61654. export class ParticleSystemSet implements IDisposable {
  61655. /**
  61656. * Gets or sets base Assets URL
  61657. */
  61658. static BaseAssetsUrl: string;
  61659. private _emitterCreationOptions;
  61660. private _emitterNode;
  61661. /**
  61662. * Gets the particle system list
  61663. */
  61664. systems: IParticleSystem[];
  61665. /**
  61666. * Gets the emitter node used with this set
  61667. */
  61668. readonly emitterNode: Nullable<TransformNode>;
  61669. /**
  61670. * Creates a new emitter mesh as a sphere
  61671. * @param options defines the options used to create the sphere
  61672. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61673. * @param scene defines the hosting scene
  61674. */
  61675. setEmitterAsSphere(options: {
  61676. diameter: number;
  61677. segments: number;
  61678. color: Color3;
  61679. }, renderingGroupId: number, scene: Scene): void;
  61680. /**
  61681. * Starts all particle systems of the set
  61682. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61683. */
  61684. start(emitter?: AbstractMesh): void;
  61685. /**
  61686. * Release all associated resources
  61687. */
  61688. dispose(): void;
  61689. /**
  61690. * Serialize the set into a JSON compatible object
  61691. * @returns a JSON compatible representation of the set
  61692. */
  61693. serialize(): any;
  61694. /**
  61695. * Parse a new ParticleSystemSet from a serialized source
  61696. * @param data defines a JSON compatible representation of the set
  61697. * @param scene defines the hosting scene
  61698. * @param gpu defines if we want GPU particles or CPU particles
  61699. * @returns a new ParticleSystemSet
  61700. */
  61701. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61702. }
  61703. }
  61704. declare module "babylonjs/Particles/particleHelper" {
  61705. import { Nullable } from "babylonjs/types";
  61706. import { Scene } from "babylonjs/scene";
  61707. import { Vector3 } from "babylonjs/Maths/math.vector";
  61708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61709. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61710. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61711. /**
  61712. * This class is made for on one-liner static method to help creating particle system set.
  61713. */
  61714. export class ParticleHelper {
  61715. /**
  61716. * Gets or sets base Assets URL
  61717. */
  61718. static BaseAssetsUrl: string;
  61719. /**
  61720. * Create a default particle system that you can tweak
  61721. * @param emitter defines the emitter to use
  61722. * @param capacity defines the system capacity (default is 500 particles)
  61723. * @param scene defines the hosting scene
  61724. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61725. * @returns the new Particle system
  61726. */
  61727. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61728. /**
  61729. * This is the main static method (one-liner) of this helper to create different particle systems
  61730. * @param type This string represents the type to the particle system to create
  61731. * @param scene The scene where the particle system should live
  61732. * @param gpu If the system will use gpu
  61733. * @returns the ParticleSystemSet created
  61734. */
  61735. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61736. /**
  61737. * Static function used to export a particle system to a ParticleSystemSet variable.
  61738. * Please note that the emitter shape is not exported
  61739. * @param systems defines the particle systems to export
  61740. * @returns the created particle system set
  61741. */
  61742. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61743. }
  61744. }
  61745. declare module "babylonjs/Particles/particleSystemComponent" {
  61746. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61747. import { Effect } from "babylonjs/Materials/effect";
  61748. import "babylonjs/Shaders/particles.vertex";
  61749. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61750. module "babylonjs/Engines/engine" {
  61751. interface Engine {
  61752. /**
  61753. * Create an effect to use with particle systems.
  61754. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61755. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61756. * @param uniformsNames defines a list of attribute names
  61757. * @param samplers defines an array of string used to represent textures
  61758. * @param defines defines the string containing the defines to use to compile the shaders
  61759. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61760. * @param onCompiled defines a function to call when the effect creation is successful
  61761. * @param onError defines a function to call when the effect creation has failed
  61762. * @returns the new Effect
  61763. */
  61764. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61765. }
  61766. }
  61767. module "babylonjs/Meshes/mesh" {
  61768. interface Mesh {
  61769. /**
  61770. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61771. * @returns an array of IParticleSystem
  61772. */
  61773. getEmittedParticleSystems(): IParticleSystem[];
  61774. /**
  61775. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61776. * @returns an array of IParticleSystem
  61777. */
  61778. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61779. }
  61780. }
  61781. /**
  61782. * @hidden
  61783. */
  61784. export var _IDoNeedToBeInTheBuild: number;
  61785. }
  61786. declare module "babylonjs/Particles/pointsCloudSystem" {
  61787. import { Color4 } from "babylonjs/Maths/math";
  61788. import { Mesh } from "babylonjs/Meshes/mesh";
  61789. import { Scene, IDisposable } from "babylonjs/scene";
  61790. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61791. /** Defines the 4 color options */
  61792. export enum PointColor {
  61793. /** color value */
  61794. Color = 2,
  61795. /** uv value */
  61796. UV = 1,
  61797. /** random value */
  61798. Random = 0,
  61799. /** stated value */
  61800. Stated = 3
  61801. }
  61802. /**
  61803. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61804. * 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.
  61805. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61806. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61807. *
  61808. * Full documentation here : TO BE ENTERED
  61809. */
  61810. export class PointsCloudSystem implements IDisposable {
  61811. /**
  61812. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61813. * Example : var p = SPS.particles[i];
  61814. */
  61815. particles: CloudPoint[];
  61816. /**
  61817. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61818. */
  61819. nbParticles: number;
  61820. /**
  61821. * This a counter for your own usage. It's not set by any SPS functions.
  61822. */
  61823. counter: number;
  61824. /**
  61825. * The PCS name. This name is also given to the underlying mesh.
  61826. */
  61827. name: string;
  61828. /**
  61829. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61830. */
  61831. mesh: Mesh;
  61832. /**
  61833. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61834. * Please read :
  61835. */
  61836. vars: any;
  61837. /**
  61838. * @hidden
  61839. */
  61840. _size: number;
  61841. private _scene;
  61842. private _promises;
  61843. private _positions;
  61844. private _indices;
  61845. private _normals;
  61846. private _colors;
  61847. private _uvs;
  61848. private _indices32;
  61849. private _positions32;
  61850. private _colors32;
  61851. private _uvs32;
  61852. private _updatable;
  61853. private _isVisibilityBoxLocked;
  61854. private _alwaysVisible;
  61855. private _groups;
  61856. private _groupCounter;
  61857. private _computeParticleColor;
  61858. private _computeParticleTexture;
  61859. private _computeParticleRotation;
  61860. private _computeBoundingBox;
  61861. private _isReady;
  61862. /**
  61863. * Creates a PCS (Points Cloud System) object
  61864. * @param name (String) is the PCS name, this will be the underlying mesh name
  61865. * @param pointSize (number) is the size for each point
  61866. * @param scene (Scene) is the scene in which the PCS is added
  61867. * @param options defines the options of the PCS e.g.
  61868. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61869. */
  61870. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61871. updatable?: boolean;
  61872. });
  61873. /**
  61874. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61875. * If no points were added to the PCS, the returned mesh is just a single point.
  61876. * @returns a promise for the created mesh
  61877. */
  61878. buildMeshAsync(): Promise<Mesh>;
  61879. /**
  61880. * @hidden
  61881. */
  61882. private _buildMesh;
  61883. private _addParticle;
  61884. private _randomUnitVector;
  61885. private _getColorIndicesForCoord;
  61886. private _setPointsColorOrUV;
  61887. private _colorFromTexture;
  61888. private _calculateDensity;
  61889. /**
  61890. * Adds points to the PCS in random positions within a unit sphere
  61891. * @param nb (positive integer) the number of particles to be created from this model
  61892. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61893. * @returns the number of groups in the system
  61894. */
  61895. addPoints(nb: number, pointFunction?: any): number;
  61896. /**
  61897. * Adds points to the PCS from the surface of the model shape
  61898. * @param mesh is any Mesh object that will be used as a surface model for the points
  61899. * @param nb (positive integer) the number of particles to be created from this model
  61900. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61901. * @param color (color3) to be used when colorWith is stated
  61902. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61903. * @returns the number of groups in the system
  61904. */
  61905. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61906. /**
  61907. * Adds points to the PCS inside the model shape
  61908. * @param mesh is any Mesh object that will be used as a surface model for the points
  61909. * @param nb (positive integer) the number of particles to be created from this model
  61910. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61911. * @param color (color4) to be used when colorWith is stated
  61912. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61913. * @returns the number of groups in the system
  61914. */
  61915. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61916. /**
  61917. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61918. * This method calls `updateParticle()` for each particle of the SPS.
  61919. * For an animated SPS, it is usually called within the render loop.
  61920. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61921. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61922. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61923. * @returns the PCS.
  61924. */
  61925. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61926. /**
  61927. * Disposes the PCS.
  61928. */
  61929. dispose(): void;
  61930. /**
  61931. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61932. * doc :
  61933. * @returns the PCS.
  61934. */
  61935. refreshVisibleSize(): PointsCloudSystem;
  61936. /**
  61937. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61938. * @param size the size (float) of the visibility box
  61939. * note : this doesn't lock the PCS mesh bounding box.
  61940. * doc :
  61941. */
  61942. setVisibilityBox(size: number): void;
  61943. /**
  61944. * Gets whether the PCS is always visible or not
  61945. * doc :
  61946. */
  61947. /**
  61948. * Sets the PCS as always visible or not
  61949. * doc :
  61950. */
  61951. isAlwaysVisible: boolean;
  61952. /**
  61953. * Tells to `setParticles()` to compute the particle rotations or not
  61954. * Default value : false. The PCS is faster when it's set to false
  61955. * Note : particle rotations are only applied to parent particles
  61956. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61957. */
  61958. computeParticleRotation: boolean;
  61959. /**
  61960. * Tells to `setParticles()` to compute the particle colors or not.
  61961. * Default value : true. The PCS is faster when it's set to false.
  61962. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61963. */
  61964. /**
  61965. * Gets if `setParticles()` computes the particle colors or not.
  61966. * Default value : false. The PCS is faster when it's set to false.
  61967. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61968. */
  61969. computeParticleColor: boolean;
  61970. /**
  61971. * Gets if `setParticles()` computes the particle textures or not.
  61972. * Default value : false. The PCS is faster when it's set to false.
  61973. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61974. */
  61975. computeParticleTexture: boolean;
  61976. /**
  61977. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61978. */
  61979. /**
  61980. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61981. */
  61982. computeBoundingBox: boolean;
  61983. /**
  61984. * This function does nothing. It may be overwritten to set all the particle first values.
  61985. * The PCS doesn't call this function, you may have to call it by your own.
  61986. * doc :
  61987. */
  61988. initParticles(): void;
  61989. /**
  61990. * This function does nothing. It may be overwritten to recycle a particle
  61991. * The PCS doesn't call this function, you can to call it
  61992. * doc :
  61993. * @param particle The particle to recycle
  61994. * @returns the recycled particle
  61995. */
  61996. recycleParticle(particle: CloudPoint): CloudPoint;
  61997. /**
  61998. * Updates a particle : this function should be overwritten by the user.
  61999. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62000. * doc :
  62001. * @example : just set a particle position or velocity and recycle conditions
  62002. * @param particle The particle to update
  62003. * @returns the updated particle
  62004. */
  62005. updateParticle(particle: CloudPoint): CloudPoint;
  62006. /**
  62007. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62008. * This does nothing and may be overwritten by the user.
  62009. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62010. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62011. * @param update the boolean update value actually passed to setParticles()
  62012. */
  62013. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62014. /**
  62015. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62016. * This will be passed three parameters.
  62017. * This does nothing and may be overwritten by the user.
  62018. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62019. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62020. * @param update the boolean update value actually passed to setParticles()
  62021. */
  62022. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62023. }
  62024. }
  62025. declare module "babylonjs/Particles/cloudPoint" {
  62026. import { Nullable } from "babylonjs/types";
  62027. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62028. import { Mesh } from "babylonjs/Meshes/mesh";
  62029. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62030. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62031. /**
  62032. * Represents one particle of a points cloud system.
  62033. */
  62034. export class CloudPoint {
  62035. /**
  62036. * particle global index
  62037. */
  62038. idx: number;
  62039. /**
  62040. * The color of the particle
  62041. */
  62042. color: Nullable<Color4>;
  62043. /**
  62044. * The world space position of the particle.
  62045. */
  62046. position: Vector3;
  62047. /**
  62048. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62049. */
  62050. rotation: Vector3;
  62051. /**
  62052. * The world space rotation quaternion of the particle.
  62053. */
  62054. rotationQuaternion: Nullable<Quaternion>;
  62055. /**
  62056. * The uv of the particle.
  62057. */
  62058. uv: Nullable<Vector2>;
  62059. /**
  62060. * The current speed of the particle.
  62061. */
  62062. velocity: Vector3;
  62063. /**
  62064. * The pivot point in the particle local space.
  62065. */
  62066. pivot: Vector3;
  62067. /**
  62068. * Must the particle be translated from its pivot point in its local space ?
  62069. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62070. * Default : false
  62071. */
  62072. translateFromPivot: boolean;
  62073. /**
  62074. * Index of this particle in the global "positions" array (Internal use)
  62075. * @hidden
  62076. */
  62077. _pos: number;
  62078. /**
  62079. * @hidden Index of this particle in the global "indices" array (Internal use)
  62080. */
  62081. _ind: number;
  62082. /**
  62083. * Group this particle belongs to
  62084. */
  62085. _group: PointsGroup;
  62086. /**
  62087. * Group id of this particle
  62088. */
  62089. groupId: number;
  62090. /**
  62091. * Index of the particle in its group id (Internal use)
  62092. */
  62093. idxInGroup: number;
  62094. /**
  62095. * @hidden Particle BoundingInfo object (Internal use)
  62096. */
  62097. _boundingInfo: BoundingInfo;
  62098. /**
  62099. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62100. */
  62101. _pcs: PointsCloudSystem;
  62102. /**
  62103. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62104. */
  62105. _stillInvisible: boolean;
  62106. /**
  62107. * @hidden Last computed particle rotation matrix
  62108. */
  62109. _rotationMatrix: number[];
  62110. /**
  62111. * Parent particle Id, if any.
  62112. * Default null.
  62113. */
  62114. parentId: Nullable<number>;
  62115. /**
  62116. * @hidden Internal global position in the PCS.
  62117. */
  62118. _globalPosition: Vector3;
  62119. /**
  62120. * Creates a Point Cloud object.
  62121. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62122. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62123. * @param group (PointsGroup) is the group the particle belongs to
  62124. * @param groupId (integer) is the group identifier in the PCS.
  62125. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62126. * @param pcs defines the PCS it is associated to
  62127. */
  62128. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62129. /**
  62130. * get point size
  62131. */
  62132. /**
  62133. * Set point size
  62134. */
  62135. size: Vector3;
  62136. /**
  62137. * Legacy support, changed quaternion to rotationQuaternion
  62138. */
  62139. /**
  62140. * Legacy support, changed quaternion to rotationQuaternion
  62141. */
  62142. quaternion: Nullable<Quaternion>;
  62143. /**
  62144. * Returns a boolean. True if the particle intersects a mesh, else false
  62145. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62146. * @param target is the object (point or mesh) what the intersection is computed against
  62147. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62148. * @returns true if it intersects
  62149. */
  62150. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62151. /**
  62152. * get the rotation matrix of the particle
  62153. * @hidden
  62154. */
  62155. getRotationMatrix(m: Matrix): void;
  62156. }
  62157. /**
  62158. * Represents a group of points in a points cloud system
  62159. * * PCS internal tool, don't use it manually.
  62160. */
  62161. export class PointsGroup {
  62162. /**
  62163. * The group id
  62164. * @hidden
  62165. */
  62166. groupID: number;
  62167. /**
  62168. * image data for group (internal use)
  62169. * @hidden
  62170. */
  62171. _groupImageData: Nullable<ArrayBufferView>;
  62172. /**
  62173. * Image Width (internal use)
  62174. * @hidden
  62175. */
  62176. _groupImgWidth: number;
  62177. /**
  62178. * Image Height (internal use)
  62179. * @hidden
  62180. */
  62181. _groupImgHeight: number;
  62182. /**
  62183. * Custom position function (internal use)
  62184. * @hidden
  62185. */
  62186. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62187. /**
  62188. * density per facet for surface points
  62189. * @hidden
  62190. */
  62191. _groupDensity: number[];
  62192. /**
  62193. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62194. * PCS internal tool, don't use it manually.
  62195. * @hidden
  62196. */
  62197. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62198. }
  62199. }
  62200. declare module "babylonjs/Particles/index" {
  62201. export * from "babylonjs/Particles/baseParticleSystem";
  62202. export * from "babylonjs/Particles/EmitterTypes/index";
  62203. export * from "babylonjs/Particles/gpuParticleSystem";
  62204. export * from "babylonjs/Particles/IParticleSystem";
  62205. export * from "babylonjs/Particles/particle";
  62206. export * from "babylonjs/Particles/particleHelper";
  62207. export * from "babylonjs/Particles/particleSystem";
  62208. export * from "babylonjs/Particles/particleSystemComponent";
  62209. export * from "babylonjs/Particles/particleSystemSet";
  62210. export * from "babylonjs/Particles/solidParticle";
  62211. export * from "babylonjs/Particles/solidParticleSystem";
  62212. export * from "babylonjs/Particles/cloudPoint";
  62213. export * from "babylonjs/Particles/pointsCloudSystem";
  62214. export * from "babylonjs/Particles/subEmitter";
  62215. }
  62216. declare module "babylonjs/Physics/physicsEngineComponent" {
  62217. import { Nullable } from "babylonjs/types";
  62218. import { Observable, Observer } from "babylonjs/Misc/observable";
  62219. import { Vector3 } from "babylonjs/Maths/math.vector";
  62220. import { Mesh } from "babylonjs/Meshes/mesh";
  62221. import { ISceneComponent } from "babylonjs/sceneComponent";
  62222. import { Scene } from "babylonjs/scene";
  62223. import { Node } from "babylonjs/node";
  62224. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62225. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62226. module "babylonjs/scene" {
  62227. interface Scene {
  62228. /** @hidden (Backing field) */
  62229. _physicsEngine: Nullable<IPhysicsEngine>;
  62230. /**
  62231. * Gets the current physics engine
  62232. * @returns a IPhysicsEngine or null if none attached
  62233. */
  62234. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62235. /**
  62236. * Enables physics to the current scene
  62237. * @param gravity defines the scene's gravity for the physics engine
  62238. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62239. * @return a boolean indicating if the physics engine was initialized
  62240. */
  62241. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62242. /**
  62243. * Disables and disposes the physics engine associated with the scene
  62244. */
  62245. disablePhysicsEngine(): void;
  62246. /**
  62247. * Gets a boolean indicating if there is an active physics engine
  62248. * @returns a boolean indicating if there is an active physics engine
  62249. */
  62250. isPhysicsEnabled(): boolean;
  62251. /**
  62252. * Deletes a physics compound impostor
  62253. * @param compound defines the compound to delete
  62254. */
  62255. deleteCompoundImpostor(compound: any): void;
  62256. /**
  62257. * An event triggered when physic simulation is about to be run
  62258. */
  62259. onBeforePhysicsObservable: Observable<Scene>;
  62260. /**
  62261. * An event triggered when physic simulation has been done
  62262. */
  62263. onAfterPhysicsObservable: Observable<Scene>;
  62264. }
  62265. }
  62266. module "babylonjs/Meshes/abstractMesh" {
  62267. interface AbstractMesh {
  62268. /** @hidden */
  62269. _physicsImpostor: Nullable<PhysicsImpostor>;
  62270. /**
  62271. * Gets or sets impostor used for physic simulation
  62272. * @see http://doc.babylonjs.com/features/physics_engine
  62273. */
  62274. physicsImpostor: Nullable<PhysicsImpostor>;
  62275. /**
  62276. * Gets the current physics impostor
  62277. * @see http://doc.babylonjs.com/features/physics_engine
  62278. * @returns a physics impostor or null
  62279. */
  62280. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62281. /** Apply a physic impulse to the mesh
  62282. * @param force defines the force to apply
  62283. * @param contactPoint defines where to apply the force
  62284. * @returns the current mesh
  62285. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62286. */
  62287. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62288. /**
  62289. * Creates a physic joint between two meshes
  62290. * @param otherMesh defines the other mesh to use
  62291. * @param pivot1 defines the pivot to use on this mesh
  62292. * @param pivot2 defines the pivot to use on the other mesh
  62293. * @param options defines additional options (can be plugin dependent)
  62294. * @returns the current mesh
  62295. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62296. */
  62297. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62298. /** @hidden */
  62299. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62300. }
  62301. }
  62302. /**
  62303. * Defines the physics engine scene component responsible to manage a physics engine
  62304. */
  62305. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62306. /**
  62307. * The component name helpful to identify the component in the list of scene components.
  62308. */
  62309. readonly name: string;
  62310. /**
  62311. * The scene the component belongs to.
  62312. */
  62313. scene: Scene;
  62314. /**
  62315. * Creates a new instance of the component for the given scene
  62316. * @param scene Defines the scene to register the component in
  62317. */
  62318. constructor(scene: Scene);
  62319. /**
  62320. * Registers the component in a given scene
  62321. */
  62322. register(): void;
  62323. /**
  62324. * Rebuilds the elements related to this component in case of
  62325. * context lost for instance.
  62326. */
  62327. rebuild(): void;
  62328. /**
  62329. * Disposes the component and the associated ressources
  62330. */
  62331. dispose(): void;
  62332. }
  62333. }
  62334. declare module "babylonjs/Physics/physicsHelper" {
  62335. import { Nullable } from "babylonjs/types";
  62336. import { Vector3 } from "babylonjs/Maths/math.vector";
  62337. import { Mesh } from "babylonjs/Meshes/mesh";
  62338. import { Scene } from "babylonjs/scene";
  62339. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62340. /**
  62341. * A helper for physics simulations
  62342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62343. */
  62344. export class PhysicsHelper {
  62345. private _scene;
  62346. private _physicsEngine;
  62347. /**
  62348. * Initializes the Physics helper
  62349. * @param scene Babylon.js scene
  62350. */
  62351. constructor(scene: Scene);
  62352. /**
  62353. * Applies a radial explosion impulse
  62354. * @param origin the origin of the explosion
  62355. * @param radiusOrEventOptions the radius or the options of radial explosion
  62356. * @param strength the explosion strength
  62357. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62358. * @returns A physics radial explosion event, or null
  62359. */
  62360. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62361. /**
  62362. * Applies a radial explosion force
  62363. * @param origin the origin of the explosion
  62364. * @param radiusOrEventOptions the radius or the options of radial explosion
  62365. * @param strength the explosion strength
  62366. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62367. * @returns A physics radial explosion event, or null
  62368. */
  62369. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62370. /**
  62371. * Creates a gravitational field
  62372. * @param origin the origin of the explosion
  62373. * @param radiusOrEventOptions the radius or the options of radial explosion
  62374. * @param strength the explosion strength
  62375. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62376. * @returns A physics gravitational field event, or null
  62377. */
  62378. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62379. /**
  62380. * Creates a physics updraft event
  62381. * @param origin the origin of the updraft
  62382. * @param radiusOrEventOptions the radius or the options of the updraft
  62383. * @param strength the strength of the updraft
  62384. * @param height the height of the updraft
  62385. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62386. * @returns A physics updraft event, or null
  62387. */
  62388. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62389. /**
  62390. * Creates a physics vortex event
  62391. * @param origin the of the vortex
  62392. * @param radiusOrEventOptions the radius or the options of the vortex
  62393. * @param strength the strength of the vortex
  62394. * @param height the height of the vortex
  62395. * @returns a Physics vortex event, or null
  62396. * A physics vortex event or null
  62397. */
  62398. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62399. }
  62400. /**
  62401. * Represents a physics radial explosion event
  62402. */
  62403. class PhysicsRadialExplosionEvent {
  62404. private _scene;
  62405. private _options;
  62406. private _sphere;
  62407. private _dataFetched;
  62408. /**
  62409. * Initializes a radial explosioin event
  62410. * @param _scene BabylonJS scene
  62411. * @param _options The options for the vortex event
  62412. */
  62413. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62414. /**
  62415. * Returns the data related to the radial explosion event (sphere).
  62416. * @returns The radial explosion event data
  62417. */
  62418. getData(): PhysicsRadialExplosionEventData;
  62419. /**
  62420. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62421. * @param impostor A physics imposter
  62422. * @param origin the origin of the explosion
  62423. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62424. */
  62425. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62426. /**
  62427. * Triggers affecterd impostors callbacks
  62428. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62429. */
  62430. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62431. /**
  62432. * Disposes the sphere.
  62433. * @param force Specifies if the sphere should be disposed by force
  62434. */
  62435. dispose(force?: boolean): void;
  62436. /*** Helpers ***/
  62437. private _prepareSphere;
  62438. private _intersectsWithSphere;
  62439. }
  62440. /**
  62441. * Represents a gravitational field event
  62442. */
  62443. class PhysicsGravitationalFieldEvent {
  62444. private _physicsHelper;
  62445. private _scene;
  62446. private _origin;
  62447. private _options;
  62448. private _tickCallback;
  62449. private _sphere;
  62450. private _dataFetched;
  62451. /**
  62452. * Initializes the physics gravitational field event
  62453. * @param _physicsHelper A physics helper
  62454. * @param _scene BabylonJS scene
  62455. * @param _origin The origin position of the gravitational field event
  62456. * @param _options The options for the vortex event
  62457. */
  62458. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62459. /**
  62460. * Returns the data related to the gravitational field event (sphere).
  62461. * @returns A gravitational field event
  62462. */
  62463. getData(): PhysicsGravitationalFieldEventData;
  62464. /**
  62465. * Enables the gravitational field.
  62466. */
  62467. enable(): void;
  62468. /**
  62469. * Disables the gravitational field.
  62470. */
  62471. disable(): void;
  62472. /**
  62473. * Disposes the sphere.
  62474. * @param force The force to dispose from the gravitational field event
  62475. */
  62476. dispose(force?: boolean): void;
  62477. private _tick;
  62478. }
  62479. /**
  62480. * Represents a physics updraft event
  62481. */
  62482. class PhysicsUpdraftEvent {
  62483. private _scene;
  62484. private _origin;
  62485. private _options;
  62486. private _physicsEngine;
  62487. private _originTop;
  62488. private _originDirection;
  62489. private _tickCallback;
  62490. private _cylinder;
  62491. private _cylinderPosition;
  62492. private _dataFetched;
  62493. /**
  62494. * Initializes the physics updraft event
  62495. * @param _scene BabylonJS scene
  62496. * @param _origin The origin position of the updraft
  62497. * @param _options The options for the updraft event
  62498. */
  62499. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62500. /**
  62501. * Returns the data related to the updraft event (cylinder).
  62502. * @returns A physics updraft event
  62503. */
  62504. getData(): PhysicsUpdraftEventData;
  62505. /**
  62506. * Enables the updraft.
  62507. */
  62508. enable(): void;
  62509. /**
  62510. * Disables the updraft.
  62511. */
  62512. disable(): void;
  62513. /**
  62514. * Disposes the cylinder.
  62515. * @param force Specifies if the updraft should be disposed by force
  62516. */
  62517. dispose(force?: boolean): void;
  62518. private getImpostorHitData;
  62519. private _tick;
  62520. /*** Helpers ***/
  62521. private _prepareCylinder;
  62522. private _intersectsWithCylinder;
  62523. }
  62524. /**
  62525. * Represents a physics vortex event
  62526. */
  62527. class PhysicsVortexEvent {
  62528. private _scene;
  62529. private _origin;
  62530. private _options;
  62531. private _physicsEngine;
  62532. private _originTop;
  62533. private _tickCallback;
  62534. private _cylinder;
  62535. private _cylinderPosition;
  62536. private _dataFetched;
  62537. /**
  62538. * Initializes the physics vortex event
  62539. * @param _scene The BabylonJS scene
  62540. * @param _origin The origin position of the vortex
  62541. * @param _options The options for the vortex event
  62542. */
  62543. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62544. /**
  62545. * Returns the data related to the vortex event (cylinder).
  62546. * @returns The physics vortex event data
  62547. */
  62548. getData(): PhysicsVortexEventData;
  62549. /**
  62550. * Enables the vortex.
  62551. */
  62552. enable(): void;
  62553. /**
  62554. * Disables the cortex.
  62555. */
  62556. disable(): void;
  62557. /**
  62558. * Disposes the sphere.
  62559. * @param force
  62560. */
  62561. dispose(force?: boolean): void;
  62562. private getImpostorHitData;
  62563. private _tick;
  62564. /*** Helpers ***/
  62565. private _prepareCylinder;
  62566. private _intersectsWithCylinder;
  62567. }
  62568. /**
  62569. * Options fot the radial explosion event
  62570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62571. */
  62572. export class PhysicsRadialExplosionEventOptions {
  62573. /**
  62574. * The radius of the sphere for the radial explosion.
  62575. */
  62576. radius: number;
  62577. /**
  62578. * The strenth of the explosion.
  62579. */
  62580. strength: number;
  62581. /**
  62582. * The strenght of the force in correspondence to the distance of the affected object
  62583. */
  62584. falloff: PhysicsRadialImpulseFalloff;
  62585. /**
  62586. * Sphere options for the radial explosion.
  62587. */
  62588. sphere: {
  62589. segments: number;
  62590. diameter: number;
  62591. };
  62592. /**
  62593. * Sphere options for the radial explosion.
  62594. */
  62595. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62596. }
  62597. /**
  62598. * Options fot the updraft event
  62599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62600. */
  62601. export class PhysicsUpdraftEventOptions {
  62602. /**
  62603. * The radius of the cylinder for the vortex
  62604. */
  62605. radius: number;
  62606. /**
  62607. * The strenth of the updraft.
  62608. */
  62609. strength: number;
  62610. /**
  62611. * The height of the cylinder for the updraft.
  62612. */
  62613. height: number;
  62614. /**
  62615. * The mode for the the updraft.
  62616. */
  62617. updraftMode: PhysicsUpdraftMode;
  62618. }
  62619. /**
  62620. * Options fot the vortex event
  62621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62622. */
  62623. export class PhysicsVortexEventOptions {
  62624. /**
  62625. * The radius of the cylinder for the vortex
  62626. */
  62627. radius: number;
  62628. /**
  62629. * The strenth of the vortex.
  62630. */
  62631. strength: number;
  62632. /**
  62633. * The height of the cylinder for the vortex.
  62634. */
  62635. height: number;
  62636. /**
  62637. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62638. */
  62639. centripetalForceThreshold: number;
  62640. /**
  62641. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62642. */
  62643. centripetalForceMultiplier: number;
  62644. /**
  62645. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62646. */
  62647. centrifugalForceMultiplier: number;
  62648. /**
  62649. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62650. */
  62651. updraftForceMultiplier: number;
  62652. }
  62653. /**
  62654. * The strenght of the force in correspondence to the distance of the affected object
  62655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62656. */
  62657. export enum PhysicsRadialImpulseFalloff {
  62658. /** Defines that impulse is constant in strength across it's whole radius */
  62659. Constant = 0,
  62660. /** Defines that impulse gets weaker if it's further from the origin */
  62661. Linear = 1
  62662. }
  62663. /**
  62664. * The strength of the force in correspondence to the distance of the affected object
  62665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62666. */
  62667. export enum PhysicsUpdraftMode {
  62668. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62669. Center = 0,
  62670. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62671. Perpendicular = 1
  62672. }
  62673. /**
  62674. * Interface for a physics hit data
  62675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62676. */
  62677. export interface PhysicsHitData {
  62678. /**
  62679. * The force applied at the contact point
  62680. */
  62681. force: Vector3;
  62682. /**
  62683. * The contact point
  62684. */
  62685. contactPoint: Vector3;
  62686. /**
  62687. * The distance from the origin to the contact point
  62688. */
  62689. distanceFromOrigin: number;
  62690. }
  62691. /**
  62692. * Interface for radial explosion event data
  62693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62694. */
  62695. export interface PhysicsRadialExplosionEventData {
  62696. /**
  62697. * A sphere used for the radial explosion event
  62698. */
  62699. sphere: Mesh;
  62700. }
  62701. /**
  62702. * Interface for gravitational field event data
  62703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62704. */
  62705. export interface PhysicsGravitationalFieldEventData {
  62706. /**
  62707. * A sphere mesh used for the gravitational field event
  62708. */
  62709. sphere: Mesh;
  62710. }
  62711. /**
  62712. * Interface for updraft event data
  62713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62714. */
  62715. export interface PhysicsUpdraftEventData {
  62716. /**
  62717. * A cylinder used for the updraft event
  62718. */
  62719. cylinder: Mesh;
  62720. }
  62721. /**
  62722. * Interface for vortex event data
  62723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62724. */
  62725. export interface PhysicsVortexEventData {
  62726. /**
  62727. * A cylinder used for the vortex event
  62728. */
  62729. cylinder: Mesh;
  62730. }
  62731. /**
  62732. * Interface for an affected physics impostor
  62733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62734. */
  62735. export interface PhysicsAffectedImpostorWithData {
  62736. /**
  62737. * The impostor affected by the effect
  62738. */
  62739. impostor: PhysicsImpostor;
  62740. /**
  62741. * The data about the hit/horce from the explosion
  62742. */
  62743. hitData: PhysicsHitData;
  62744. }
  62745. }
  62746. declare module "babylonjs/Physics/Plugins/index" {
  62747. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62748. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62749. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62750. }
  62751. declare module "babylonjs/Physics/index" {
  62752. export * from "babylonjs/Physics/IPhysicsEngine";
  62753. export * from "babylonjs/Physics/physicsEngine";
  62754. export * from "babylonjs/Physics/physicsEngineComponent";
  62755. export * from "babylonjs/Physics/physicsHelper";
  62756. export * from "babylonjs/Physics/physicsImpostor";
  62757. export * from "babylonjs/Physics/physicsJoint";
  62758. export * from "babylonjs/Physics/Plugins/index";
  62759. }
  62760. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62761. /** @hidden */
  62762. export var blackAndWhitePixelShader: {
  62763. name: string;
  62764. shader: string;
  62765. };
  62766. }
  62767. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62769. import { Camera } from "babylonjs/Cameras/camera";
  62770. import { Engine } from "babylonjs/Engines/engine";
  62771. import "babylonjs/Shaders/blackAndWhite.fragment";
  62772. /**
  62773. * Post process used to render in black and white
  62774. */
  62775. export class BlackAndWhitePostProcess extends PostProcess {
  62776. /**
  62777. * Linear about to convert he result to black and white (default: 1)
  62778. */
  62779. degree: number;
  62780. /**
  62781. * Creates a black and white post process
  62782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62783. * @param name The name of the effect.
  62784. * @param options The required width/height ratio to downsize to before computing the render pass.
  62785. * @param camera The camera to apply the render pass to.
  62786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62787. * @param engine The engine which the post process will be applied. (default: current engine)
  62788. * @param reusable If the post process can be reused on the same frame. (default: false)
  62789. */
  62790. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62791. }
  62792. }
  62793. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62794. import { Nullable } from "babylonjs/types";
  62795. import { Camera } from "babylonjs/Cameras/camera";
  62796. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62797. import { Engine } from "babylonjs/Engines/engine";
  62798. /**
  62799. * This represents a set of one or more post processes in Babylon.
  62800. * A post process can be used to apply a shader to a texture after it is rendered.
  62801. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62802. */
  62803. export class PostProcessRenderEffect {
  62804. private _postProcesses;
  62805. private _getPostProcesses;
  62806. private _singleInstance;
  62807. private _cameras;
  62808. private _indicesForCamera;
  62809. /**
  62810. * Name of the effect
  62811. * @hidden
  62812. */
  62813. _name: string;
  62814. /**
  62815. * Instantiates a post process render effect.
  62816. * A post process can be used to apply a shader to a texture after it is rendered.
  62817. * @param engine The engine the effect is tied to
  62818. * @param name The name of the effect
  62819. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62820. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62821. */
  62822. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62823. /**
  62824. * Checks if all the post processes in the effect are supported.
  62825. */
  62826. readonly isSupported: boolean;
  62827. /**
  62828. * Updates the current state of the effect
  62829. * @hidden
  62830. */
  62831. _update(): void;
  62832. /**
  62833. * Attaches the effect on cameras
  62834. * @param cameras The camera to attach to.
  62835. * @hidden
  62836. */
  62837. _attachCameras(cameras: Camera): void;
  62838. /**
  62839. * Attaches the effect on cameras
  62840. * @param cameras The camera to attach to.
  62841. * @hidden
  62842. */
  62843. _attachCameras(cameras: Camera[]): void;
  62844. /**
  62845. * Detaches the effect on cameras
  62846. * @param cameras The camera to detatch from.
  62847. * @hidden
  62848. */
  62849. _detachCameras(cameras: Camera): void;
  62850. /**
  62851. * Detatches the effect on cameras
  62852. * @param cameras The camera to detatch from.
  62853. * @hidden
  62854. */
  62855. _detachCameras(cameras: Camera[]): void;
  62856. /**
  62857. * Enables the effect on given cameras
  62858. * @param cameras The camera to enable.
  62859. * @hidden
  62860. */
  62861. _enable(cameras: Camera): void;
  62862. /**
  62863. * Enables the effect on given cameras
  62864. * @param cameras The camera to enable.
  62865. * @hidden
  62866. */
  62867. _enable(cameras: Nullable<Camera[]>): void;
  62868. /**
  62869. * Disables the effect on the given cameras
  62870. * @param cameras The camera to disable.
  62871. * @hidden
  62872. */
  62873. _disable(cameras: Camera): void;
  62874. /**
  62875. * Disables the effect on the given cameras
  62876. * @param cameras The camera to disable.
  62877. * @hidden
  62878. */
  62879. _disable(cameras: Nullable<Camera[]>): void;
  62880. /**
  62881. * Gets a list of the post processes contained in the effect.
  62882. * @param camera The camera to get the post processes on.
  62883. * @returns The list of the post processes in the effect.
  62884. */
  62885. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62886. }
  62887. }
  62888. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62889. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62890. /** @hidden */
  62891. export var extractHighlightsPixelShader: {
  62892. name: string;
  62893. shader: string;
  62894. };
  62895. }
  62896. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62897. import { Nullable } from "babylonjs/types";
  62898. import { Camera } from "babylonjs/Cameras/camera";
  62899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62900. import { Engine } from "babylonjs/Engines/engine";
  62901. import "babylonjs/Shaders/extractHighlights.fragment";
  62902. /**
  62903. * 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.
  62904. */
  62905. export class ExtractHighlightsPostProcess extends PostProcess {
  62906. /**
  62907. * The luminance threshold, pixels below this value will be set to black.
  62908. */
  62909. threshold: number;
  62910. /** @hidden */
  62911. _exposure: number;
  62912. /**
  62913. * Post process which has the input texture to be used when performing highlight extraction
  62914. * @hidden
  62915. */
  62916. _inputPostProcess: Nullable<PostProcess>;
  62917. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62918. }
  62919. }
  62920. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62921. /** @hidden */
  62922. export var bloomMergePixelShader: {
  62923. name: string;
  62924. shader: string;
  62925. };
  62926. }
  62927. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62928. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62929. import { Nullable } from "babylonjs/types";
  62930. import { Engine } from "babylonjs/Engines/engine";
  62931. import { Camera } from "babylonjs/Cameras/camera";
  62932. import "babylonjs/Shaders/bloomMerge.fragment";
  62933. /**
  62934. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62935. */
  62936. export class BloomMergePostProcess extends PostProcess {
  62937. /** Weight of the bloom to be added to the original input. */
  62938. weight: number;
  62939. /**
  62940. * Creates a new instance of @see BloomMergePostProcess
  62941. * @param name The name of the effect.
  62942. * @param originalFromInput Post process which's input will be used for the merge.
  62943. * @param blurred Blurred highlights post process which's output will be used.
  62944. * @param weight Weight of the bloom to be added to the original input.
  62945. * @param options The required width/height ratio to downsize to before computing the render pass.
  62946. * @param camera The camera to apply the render pass to.
  62947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62948. * @param engine The engine which the post process will be applied. (default: current engine)
  62949. * @param reusable If the post process can be reused on the same frame. (default: false)
  62950. * @param textureType Type of textures used when performing the post process. (default: 0)
  62951. * @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)
  62952. */
  62953. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62954. /** Weight of the bloom to be added to the original input. */
  62955. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62956. }
  62957. }
  62958. declare module "babylonjs/PostProcesses/bloomEffect" {
  62959. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62960. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62961. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62962. import { Camera } from "babylonjs/Cameras/camera";
  62963. import { Scene } from "babylonjs/scene";
  62964. /**
  62965. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62966. */
  62967. export class BloomEffect extends PostProcessRenderEffect {
  62968. private bloomScale;
  62969. /**
  62970. * @hidden Internal
  62971. */
  62972. _effects: Array<PostProcess>;
  62973. /**
  62974. * @hidden Internal
  62975. */
  62976. _downscale: ExtractHighlightsPostProcess;
  62977. private _blurX;
  62978. private _blurY;
  62979. private _merge;
  62980. /**
  62981. * The luminance threshold to find bright areas of the image to bloom.
  62982. */
  62983. threshold: number;
  62984. /**
  62985. * The strength of the bloom.
  62986. */
  62987. weight: number;
  62988. /**
  62989. * Specifies the size of the bloom blur kernel, relative to the final output size
  62990. */
  62991. kernel: number;
  62992. /**
  62993. * Creates a new instance of @see BloomEffect
  62994. * @param scene The scene the effect belongs to.
  62995. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62996. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62997. * @param bloomWeight The the strength of bloom.
  62998. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62999. * @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)
  63000. */
  63001. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63002. /**
  63003. * Disposes each of the internal effects for a given camera.
  63004. * @param camera The camera to dispose the effect on.
  63005. */
  63006. disposeEffects(camera: Camera): void;
  63007. /**
  63008. * @hidden Internal
  63009. */
  63010. _updateEffects(): void;
  63011. /**
  63012. * Internal
  63013. * @returns if all the contained post processes are ready.
  63014. * @hidden
  63015. */
  63016. _isReady(): boolean;
  63017. }
  63018. }
  63019. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63020. /** @hidden */
  63021. export var chromaticAberrationPixelShader: {
  63022. name: string;
  63023. shader: string;
  63024. };
  63025. }
  63026. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63027. import { Vector2 } from "babylonjs/Maths/math.vector";
  63028. import { Nullable } from "babylonjs/types";
  63029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63030. import { Camera } from "babylonjs/Cameras/camera";
  63031. import { Engine } from "babylonjs/Engines/engine";
  63032. import "babylonjs/Shaders/chromaticAberration.fragment";
  63033. /**
  63034. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63035. */
  63036. export class ChromaticAberrationPostProcess extends PostProcess {
  63037. /**
  63038. * The amount of seperation of rgb channels (default: 30)
  63039. */
  63040. aberrationAmount: number;
  63041. /**
  63042. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63043. */
  63044. radialIntensity: number;
  63045. /**
  63046. * 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))
  63047. */
  63048. direction: Vector2;
  63049. /**
  63050. * 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))
  63051. */
  63052. centerPosition: Vector2;
  63053. /**
  63054. * Creates a new instance ChromaticAberrationPostProcess
  63055. * @param name The name of the effect.
  63056. * @param screenWidth The width of the screen to apply the effect on.
  63057. * @param screenHeight The height of the screen to apply the effect on.
  63058. * @param options The required width/height ratio to downsize to before computing the render pass.
  63059. * @param camera The camera to apply the render pass to.
  63060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63061. * @param engine The engine which the post process will be applied. (default: current engine)
  63062. * @param reusable If the post process can be reused on the same frame. (default: false)
  63063. * @param textureType Type of textures used when performing the post process. (default: 0)
  63064. * @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)
  63065. */
  63066. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63067. }
  63068. }
  63069. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63070. /** @hidden */
  63071. export var circleOfConfusionPixelShader: {
  63072. name: string;
  63073. shader: string;
  63074. };
  63075. }
  63076. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63077. import { Nullable } from "babylonjs/types";
  63078. import { Engine } from "babylonjs/Engines/engine";
  63079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63081. import { Camera } from "babylonjs/Cameras/camera";
  63082. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63083. /**
  63084. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63085. */
  63086. export class CircleOfConfusionPostProcess extends PostProcess {
  63087. /**
  63088. * 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.
  63089. */
  63090. lensSize: number;
  63091. /**
  63092. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63093. */
  63094. fStop: number;
  63095. /**
  63096. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63097. */
  63098. focusDistance: number;
  63099. /**
  63100. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63101. */
  63102. focalLength: number;
  63103. private _depthTexture;
  63104. /**
  63105. * Creates a new instance CircleOfConfusionPostProcess
  63106. * @param name The name of the effect.
  63107. * @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.
  63108. * @param options The required width/height ratio to downsize to before computing the render pass.
  63109. * @param camera The camera to apply the render pass to.
  63110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63111. * @param engine The engine which the post process will be applied. (default: current engine)
  63112. * @param reusable If the post process can be reused on the same frame. (default: false)
  63113. * @param textureType Type of textures used when performing the post process. (default: 0)
  63114. * @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)
  63115. */
  63116. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63117. /**
  63118. * 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.
  63119. */
  63120. depthTexture: RenderTargetTexture;
  63121. }
  63122. }
  63123. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63124. /** @hidden */
  63125. export var colorCorrectionPixelShader: {
  63126. name: string;
  63127. shader: string;
  63128. };
  63129. }
  63130. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63132. import { Engine } from "babylonjs/Engines/engine";
  63133. import { Camera } from "babylonjs/Cameras/camera";
  63134. import "babylonjs/Shaders/colorCorrection.fragment";
  63135. /**
  63136. *
  63137. * This post-process allows the modification of rendered colors by using
  63138. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63139. *
  63140. * The object needs to be provided an url to a texture containing the color
  63141. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63142. * Use an image editing software to tweak the LUT to match your needs.
  63143. *
  63144. * For an example of a color LUT, see here:
  63145. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63146. * For explanations on color grading, see here:
  63147. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63148. *
  63149. */
  63150. export class ColorCorrectionPostProcess extends PostProcess {
  63151. private _colorTableTexture;
  63152. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63153. }
  63154. }
  63155. declare module "babylonjs/Shaders/convolution.fragment" {
  63156. /** @hidden */
  63157. export var convolutionPixelShader: {
  63158. name: string;
  63159. shader: string;
  63160. };
  63161. }
  63162. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63164. import { Nullable } from "babylonjs/types";
  63165. import { Camera } from "babylonjs/Cameras/camera";
  63166. import { Engine } from "babylonjs/Engines/engine";
  63167. import "babylonjs/Shaders/convolution.fragment";
  63168. /**
  63169. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63170. * input texture to perform effects such as edge detection or sharpening
  63171. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63172. */
  63173. export class ConvolutionPostProcess extends PostProcess {
  63174. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63175. kernel: number[];
  63176. /**
  63177. * Creates a new instance ConvolutionPostProcess
  63178. * @param name The name of the effect.
  63179. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63180. * @param options The required width/height ratio to downsize to before computing the render pass.
  63181. * @param camera The camera to apply the render pass to.
  63182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63183. * @param engine The engine which the post process will be applied. (default: current engine)
  63184. * @param reusable If the post process can be reused on the same frame. (default: false)
  63185. * @param textureType Type of textures used when performing the post process. (default: 0)
  63186. */
  63187. constructor(name: string,
  63188. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63189. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63190. /**
  63191. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63192. */
  63193. static EdgeDetect0Kernel: number[];
  63194. /**
  63195. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63196. */
  63197. static EdgeDetect1Kernel: number[];
  63198. /**
  63199. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63200. */
  63201. static EdgeDetect2Kernel: number[];
  63202. /**
  63203. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63204. */
  63205. static SharpenKernel: number[];
  63206. /**
  63207. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63208. */
  63209. static EmbossKernel: number[];
  63210. /**
  63211. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63212. */
  63213. static GaussianKernel: number[];
  63214. }
  63215. }
  63216. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63217. import { Nullable } from "babylonjs/types";
  63218. import { Vector2 } from "babylonjs/Maths/math.vector";
  63219. import { Camera } from "babylonjs/Cameras/camera";
  63220. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63221. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63222. import { Engine } from "babylonjs/Engines/engine";
  63223. import { Scene } from "babylonjs/scene";
  63224. /**
  63225. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63226. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63227. * based on samples that have a large difference in distance than the center pixel.
  63228. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63229. */
  63230. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63231. direction: Vector2;
  63232. /**
  63233. * Creates a new instance CircleOfConfusionPostProcess
  63234. * @param name The name of the effect.
  63235. * @param scene The scene the effect belongs to.
  63236. * @param direction The direction the blur should be applied.
  63237. * @param kernel The size of the kernel used to blur.
  63238. * @param options The required width/height ratio to downsize to before computing the render pass.
  63239. * @param camera The camera to apply the render pass to.
  63240. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63241. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63243. * @param engine The engine which the post process will be applied. (default: current engine)
  63244. * @param reusable If the post process can be reused on the same frame. (default: false)
  63245. * @param textureType Type of textures used when performing the post process. (default: 0)
  63246. * @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)
  63247. */
  63248. 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);
  63249. }
  63250. }
  63251. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63252. /** @hidden */
  63253. export var depthOfFieldMergePixelShader: {
  63254. name: string;
  63255. shader: string;
  63256. };
  63257. }
  63258. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63259. import { Nullable } from "babylonjs/types";
  63260. import { Camera } from "babylonjs/Cameras/camera";
  63261. import { Effect } from "babylonjs/Materials/effect";
  63262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63263. import { Engine } from "babylonjs/Engines/engine";
  63264. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63265. /**
  63266. * Options to be set when merging outputs from the default pipeline.
  63267. */
  63268. export class DepthOfFieldMergePostProcessOptions {
  63269. /**
  63270. * The original image to merge on top of
  63271. */
  63272. originalFromInput: PostProcess;
  63273. /**
  63274. * Parameters to perform the merge of the depth of field effect
  63275. */
  63276. depthOfField?: {
  63277. circleOfConfusion: PostProcess;
  63278. blurSteps: Array<PostProcess>;
  63279. };
  63280. /**
  63281. * Parameters to perform the merge of bloom effect
  63282. */
  63283. bloom?: {
  63284. blurred: PostProcess;
  63285. weight: number;
  63286. };
  63287. }
  63288. /**
  63289. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63290. */
  63291. export class DepthOfFieldMergePostProcess extends PostProcess {
  63292. private blurSteps;
  63293. /**
  63294. * Creates a new instance of DepthOfFieldMergePostProcess
  63295. * @param name The name of the effect.
  63296. * @param originalFromInput Post process which's input will be used for the merge.
  63297. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63298. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63299. * @param options The required width/height ratio to downsize to before computing the render pass.
  63300. * @param camera The camera to apply the render pass to.
  63301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63302. * @param engine The engine which the post process will be applied. (default: current engine)
  63303. * @param reusable If the post process can be reused on the same frame. (default: false)
  63304. * @param textureType Type of textures used when performing the post process. (default: 0)
  63305. * @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)
  63306. */
  63307. 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);
  63308. /**
  63309. * Updates the effect with the current post process compile time values and recompiles the shader.
  63310. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63311. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63312. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63313. * @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
  63314. * @param onCompiled Called when the shader has been compiled.
  63315. * @param onError Called if there is an error when compiling a shader.
  63316. */
  63317. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63318. }
  63319. }
  63320. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63321. import { Nullable } from "babylonjs/types";
  63322. import { Camera } from "babylonjs/Cameras/camera";
  63323. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63324. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63325. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63326. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63327. import { Scene } from "babylonjs/scene";
  63328. /**
  63329. * Specifies the level of max blur that should be applied when using the depth of field effect
  63330. */
  63331. export enum DepthOfFieldEffectBlurLevel {
  63332. /**
  63333. * Subtle blur
  63334. */
  63335. Low = 0,
  63336. /**
  63337. * Medium blur
  63338. */
  63339. Medium = 1,
  63340. /**
  63341. * Large blur
  63342. */
  63343. High = 2
  63344. }
  63345. /**
  63346. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63347. */
  63348. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63349. private _circleOfConfusion;
  63350. /**
  63351. * @hidden Internal, blurs from high to low
  63352. */
  63353. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63354. private _depthOfFieldBlurY;
  63355. private _dofMerge;
  63356. /**
  63357. * @hidden Internal post processes in depth of field effect
  63358. */
  63359. _effects: Array<PostProcess>;
  63360. /**
  63361. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63362. */
  63363. focalLength: number;
  63364. /**
  63365. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63366. */
  63367. fStop: number;
  63368. /**
  63369. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63370. */
  63371. focusDistance: number;
  63372. /**
  63373. * 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.
  63374. */
  63375. lensSize: number;
  63376. /**
  63377. * Creates a new instance DepthOfFieldEffect
  63378. * @param scene The scene the effect belongs to.
  63379. * @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.
  63380. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63381. * @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)
  63382. */
  63383. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63384. /**
  63385. * Get the current class name of the current effet
  63386. * @returns "DepthOfFieldEffect"
  63387. */
  63388. getClassName(): string;
  63389. /**
  63390. * 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.
  63391. */
  63392. depthTexture: RenderTargetTexture;
  63393. /**
  63394. * Disposes each of the internal effects for a given camera.
  63395. * @param camera The camera to dispose the effect on.
  63396. */
  63397. disposeEffects(camera: Camera): void;
  63398. /**
  63399. * @hidden Internal
  63400. */
  63401. _updateEffects(): void;
  63402. /**
  63403. * Internal
  63404. * @returns if all the contained post processes are ready.
  63405. * @hidden
  63406. */
  63407. _isReady(): boolean;
  63408. }
  63409. }
  63410. declare module "babylonjs/Shaders/displayPass.fragment" {
  63411. /** @hidden */
  63412. export var displayPassPixelShader: {
  63413. name: string;
  63414. shader: string;
  63415. };
  63416. }
  63417. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63418. import { Nullable } from "babylonjs/types";
  63419. import { Camera } from "babylonjs/Cameras/camera";
  63420. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63421. import { Engine } from "babylonjs/Engines/engine";
  63422. import "babylonjs/Shaders/displayPass.fragment";
  63423. /**
  63424. * DisplayPassPostProcess which produces an output the same as it's input
  63425. */
  63426. export class DisplayPassPostProcess extends PostProcess {
  63427. /**
  63428. * Creates the DisplayPassPostProcess
  63429. * @param name The name of the effect.
  63430. * @param options The required width/height ratio to downsize to before computing the render pass.
  63431. * @param camera The camera to apply the render pass to.
  63432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63433. * @param engine The engine which the post process will be applied. (default: current engine)
  63434. * @param reusable If the post process can be reused on the same frame. (default: false)
  63435. */
  63436. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63437. }
  63438. }
  63439. declare module "babylonjs/Shaders/filter.fragment" {
  63440. /** @hidden */
  63441. export var filterPixelShader: {
  63442. name: string;
  63443. shader: string;
  63444. };
  63445. }
  63446. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63447. import { Nullable } from "babylonjs/types";
  63448. import { Matrix } from "babylonjs/Maths/math.vector";
  63449. import { Camera } from "babylonjs/Cameras/camera";
  63450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63451. import { Engine } from "babylonjs/Engines/engine";
  63452. import "babylonjs/Shaders/filter.fragment";
  63453. /**
  63454. * Applies a kernel filter to the image
  63455. */
  63456. export class FilterPostProcess extends PostProcess {
  63457. /** The matrix to be applied to the image */
  63458. kernelMatrix: Matrix;
  63459. /**
  63460. *
  63461. * @param name The name of the effect.
  63462. * @param kernelMatrix The matrix to be applied to the image
  63463. * @param options The required width/height ratio to downsize to before computing the render pass.
  63464. * @param camera The camera to apply the render pass to.
  63465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63466. * @param engine The engine which the post process will be applied. (default: current engine)
  63467. * @param reusable If the post process can be reused on the same frame. (default: false)
  63468. */
  63469. constructor(name: string,
  63470. /** The matrix to be applied to the image */
  63471. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63472. }
  63473. }
  63474. declare module "babylonjs/Shaders/fxaa.fragment" {
  63475. /** @hidden */
  63476. export var fxaaPixelShader: {
  63477. name: string;
  63478. shader: string;
  63479. };
  63480. }
  63481. declare module "babylonjs/Shaders/fxaa.vertex" {
  63482. /** @hidden */
  63483. export var fxaaVertexShader: {
  63484. name: string;
  63485. shader: string;
  63486. };
  63487. }
  63488. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63489. import { Nullable } from "babylonjs/types";
  63490. import { Camera } from "babylonjs/Cameras/camera";
  63491. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63492. import { Engine } from "babylonjs/Engines/engine";
  63493. import "babylonjs/Shaders/fxaa.fragment";
  63494. import "babylonjs/Shaders/fxaa.vertex";
  63495. /**
  63496. * Fxaa post process
  63497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63498. */
  63499. export class FxaaPostProcess extends PostProcess {
  63500. /** @hidden */
  63501. texelWidth: number;
  63502. /** @hidden */
  63503. texelHeight: number;
  63504. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63505. private _getDefines;
  63506. }
  63507. }
  63508. declare module "babylonjs/Shaders/grain.fragment" {
  63509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63510. /** @hidden */
  63511. export var grainPixelShader: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63517. import { Nullable } from "babylonjs/types";
  63518. import { Camera } from "babylonjs/Cameras/camera";
  63519. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63520. import { Engine } from "babylonjs/Engines/engine";
  63521. import "babylonjs/Shaders/grain.fragment";
  63522. /**
  63523. * The GrainPostProcess adds noise to the image at mid luminance levels
  63524. */
  63525. export class GrainPostProcess extends PostProcess {
  63526. /**
  63527. * The intensity of the grain added (default: 30)
  63528. */
  63529. intensity: number;
  63530. /**
  63531. * If the grain should be randomized on every frame
  63532. */
  63533. animated: boolean;
  63534. /**
  63535. * Creates a new instance of @see GrainPostProcess
  63536. * @param name The name of the effect.
  63537. * @param options The required width/height ratio to downsize to before computing the render pass.
  63538. * @param camera The camera to apply the render pass to.
  63539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63540. * @param engine The engine which the post process will be applied. (default: current engine)
  63541. * @param reusable If the post process can be reused on the same frame. (default: false)
  63542. * @param textureType Type of textures used when performing the post process. (default: 0)
  63543. * @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)
  63544. */
  63545. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63546. }
  63547. }
  63548. declare module "babylonjs/Shaders/highlights.fragment" {
  63549. /** @hidden */
  63550. export var highlightsPixelShader: {
  63551. name: string;
  63552. shader: string;
  63553. };
  63554. }
  63555. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63556. import { Nullable } from "babylonjs/types";
  63557. import { Camera } from "babylonjs/Cameras/camera";
  63558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63559. import { Engine } from "babylonjs/Engines/engine";
  63560. import "babylonjs/Shaders/highlights.fragment";
  63561. /**
  63562. * Extracts highlights from the image
  63563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63564. */
  63565. export class HighlightsPostProcess extends PostProcess {
  63566. /**
  63567. * Extracts highlights from the image
  63568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63569. * @param name The name of the effect.
  63570. * @param options The required width/height ratio to downsize to before computing the render pass.
  63571. * @param camera The camera to apply the render pass to.
  63572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63573. * @param engine The engine which the post process will be applied. (default: current engine)
  63574. * @param reusable If the post process can be reused on the same frame. (default: false)
  63575. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63576. */
  63577. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63578. }
  63579. }
  63580. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63581. /** @hidden */
  63582. export var mrtFragmentDeclaration: {
  63583. name: string;
  63584. shader: string;
  63585. };
  63586. }
  63587. declare module "babylonjs/Shaders/geometry.fragment" {
  63588. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63589. /** @hidden */
  63590. export var geometryPixelShader: {
  63591. name: string;
  63592. shader: string;
  63593. };
  63594. }
  63595. declare module "babylonjs/Shaders/geometry.vertex" {
  63596. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63597. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63599. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63601. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63602. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63603. /** @hidden */
  63604. export var geometryVertexShader: {
  63605. name: string;
  63606. shader: string;
  63607. };
  63608. }
  63609. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63610. import { Matrix } from "babylonjs/Maths/math.vector";
  63611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63612. import { Mesh } from "babylonjs/Meshes/mesh";
  63613. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63614. import { Effect } from "babylonjs/Materials/effect";
  63615. import { Scene } from "babylonjs/scene";
  63616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63617. import "babylonjs/Shaders/geometry.fragment";
  63618. import "babylonjs/Shaders/geometry.vertex";
  63619. /** @hidden */
  63620. interface ISavedTransformationMatrix {
  63621. world: Matrix;
  63622. viewProjection: Matrix;
  63623. }
  63624. /**
  63625. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63626. */
  63627. export class GeometryBufferRenderer {
  63628. /**
  63629. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63630. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63631. */
  63632. static readonly POSITION_TEXTURE_TYPE: number;
  63633. /**
  63634. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63635. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63636. */
  63637. static readonly VELOCITY_TEXTURE_TYPE: number;
  63638. /**
  63639. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63640. * in order to compute objects velocities when enableVelocity is set to "true"
  63641. * @hidden
  63642. */
  63643. _previousTransformationMatrices: {
  63644. [index: number]: ISavedTransformationMatrix;
  63645. };
  63646. /**
  63647. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63648. * in order to compute objects velocities when enableVelocity is set to "true"
  63649. * @hidden
  63650. */
  63651. _previousBonesTransformationMatrices: {
  63652. [index: number]: Float32Array;
  63653. };
  63654. /**
  63655. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63656. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63657. */
  63658. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63659. private _scene;
  63660. private _multiRenderTarget;
  63661. private _ratio;
  63662. private _enablePosition;
  63663. private _enableVelocity;
  63664. private _positionIndex;
  63665. private _velocityIndex;
  63666. protected _effect: Effect;
  63667. protected _cachedDefines: string;
  63668. /**
  63669. * Set the render list (meshes to be rendered) used in the G buffer.
  63670. */
  63671. renderList: Mesh[];
  63672. /**
  63673. * Gets wether or not G buffer are supported by the running hardware.
  63674. * This requires draw buffer supports
  63675. */
  63676. readonly isSupported: boolean;
  63677. /**
  63678. * Returns the index of the given texture type in the G-Buffer textures array
  63679. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63680. * @returns the index of the given texture type in the G-Buffer textures array
  63681. */
  63682. getTextureIndex(textureType: number): number;
  63683. /**
  63684. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63685. */
  63686. /**
  63687. * Sets whether or not objects positions are enabled for the G buffer.
  63688. */
  63689. enablePosition: boolean;
  63690. /**
  63691. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63692. */
  63693. /**
  63694. * Sets wether or not objects velocities are enabled for the G buffer.
  63695. */
  63696. enableVelocity: boolean;
  63697. /**
  63698. * Gets the scene associated with the buffer.
  63699. */
  63700. readonly scene: Scene;
  63701. /**
  63702. * Gets the ratio used by the buffer during its creation.
  63703. * How big is the buffer related to the main canvas.
  63704. */
  63705. readonly ratio: number;
  63706. /** @hidden */
  63707. static _SceneComponentInitialization: (scene: Scene) => void;
  63708. /**
  63709. * Creates a new G Buffer for the scene
  63710. * @param scene The scene the buffer belongs to
  63711. * @param ratio How big is the buffer related to the main canvas.
  63712. */
  63713. constructor(scene: Scene, ratio?: number);
  63714. /**
  63715. * Checks wether everything is ready to render a submesh to the G buffer.
  63716. * @param subMesh the submesh to check readiness for
  63717. * @param useInstances is the mesh drawn using instance or not
  63718. * @returns true if ready otherwise false
  63719. */
  63720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63721. /**
  63722. * Gets the current underlying G Buffer.
  63723. * @returns the buffer
  63724. */
  63725. getGBuffer(): MultiRenderTarget;
  63726. /**
  63727. * Gets the number of samples used to render the buffer (anti aliasing).
  63728. */
  63729. /**
  63730. * Sets the number of samples used to render the buffer (anti aliasing).
  63731. */
  63732. samples: number;
  63733. /**
  63734. * Disposes the renderer and frees up associated resources.
  63735. */
  63736. dispose(): void;
  63737. protected _createRenderTargets(): void;
  63738. private _copyBonesTransformationMatrices;
  63739. }
  63740. }
  63741. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63742. import { Nullable } from "babylonjs/types";
  63743. import { Scene } from "babylonjs/scene";
  63744. import { ISceneComponent } from "babylonjs/sceneComponent";
  63745. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63746. module "babylonjs/scene" {
  63747. interface Scene {
  63748. /** @hidden (Backing field) */
  63749. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63750. /**
  63751. * Gets or Sets the current geometry buffer associated to the scene.
  63752. */
  63753. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63754. /**
  63755. * Enables a GeometryBufferRender and associates it with the scene
  63756. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63757. * @returns the GeometryBufferRenderer
  63758. */
  63759. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63760. /**
  63761. * Disables the GeometryBufferRender associated with the scene
  63762. */
  63763. disableGeometryBufferRenderer(): void;
  63764. }
  63765. }
  63766. /**
  63767. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63768. * in several rendering techniques.
  63769. */
  63770. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63771. /**
  63772. * The component name helpful to identify the component in the list of scene components.
  63773. */
  63774. readonly name: string;
  63775. /**
  63776. * The scene the component belongs to.
  63777. */
  63778. scene: Scene;
  63779. /**
  63780. * Creates a new instance of the component for the given scene
  63781. * @param scene Defines the scene to register the component in
  63782. */
  63783. constructor(scene: Scene);
  63784. /**
  63785. * Registers the component in a given scene
  63786. */
  63787. register(): void;
  63788. /**
  63789. * Rebuilds the elements related to this component in case of
  63790. * context lost for instance.
  63791. */
  63792. rebuild(): void;
  63793. /**
  63794. * Disposes the component and the associated ressources
  63795. */
  63796. dispose(): void;
  63797. private _gatherRenderTargets;
  63798. }
  63799. }
  63800. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63801. /** @hidden */
  63802. export var motionBlurPixelShader: {
  63803. name: string;
  63804. shader: string;
  63805. };
  63806. }
  63807. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63808. import { Nullable } from "babylonjs/types";
  63809. import { Camera } from "babylonjs/Cameras/camera";
  63810. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63811. import { Scene } from "babylonjs/scene";
  63812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63813. import "babylonjs/Animations/animatable";
  63814. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63815. import "babylonjs/Shaders/motionBlur.fragment";
  63816. import { Engine } from "babylonjs/Engines/engine";
  63817. /**
  63818. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63819. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63820. * As an example, all you have to do is to create the post-process:
  63821. * var mb = new BABYLON.MotionBlurPostProcess(
  63822. * 'mb', // The name of the effect.
  63823. * scene, // The scene containing the objects to blur according to their velocity.
  63824. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63825. * camera // The camera to apply the render pass to.
  63826. * );
  63827. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63828. */
  63829. export class MotionBlurPostProcess extends PostProcess {
  63830. /**
  63831. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63832. */
  63833. motionStrength: number;
  63834. /**
  63835. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63836. */
  63837. /**
  63838. * Sets the number of iterations to be used for motion blur quality
  63839. */
  63840. motionBlurSamples: number;
  63841. private _motionBlurSamples;
  63842. private _geometryBufferRenderer;
  63843. /**
  63844. * Creates a new instance MotionBlurPostProcess
  63845. * @param name The name of the effect.
  63846. * @param scene The scene containing the objects to blur according to their velocity.
  63847. * @param options The required width/height ratio to downsize to before computing the render pass.
  63848. * @param camera The camera to apply the render pass to.
  63849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63850. * @param engine The engine which the post process will be applied. (default: current engine)
  63851. * @param reusable If the post process can be reused on the same frame. (default: false)
  63852. * @param textureType Type of textures used when performing the post process. (default: 0)
  63853. * @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)
  63854. */
  63855. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63856. /**
  63857. * Excludes the given skinned mesh from computing bones velocities.
  63858. * 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.
  63859. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63860. */
  63861. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63862. /**
  63863. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63864. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63865. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63866. */
  63867. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63868. /**
  63869. * Disposes the post process.
  63870. * @param camera The camera to dispose the post process on.
  63871. */
  63872. dispose(camera?: Camera): void;
  63873. }
  63874. }
  63875. declare module "babylonjs/Shaders/refraction.fragment" {
  63876. /** @hidden */
  63877. export var refractionPixelShader: {
  63878. name: string;
  63879. shader: string;
  63880. };
  63881. }
  63882. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63883. import { Color3 } from "babylonjs/Maths/math.color";
  63884. import { Camera } from "babylonjs/Cameras/camera";
  63885. import { Texture } from "babylonjs/Materials/Textures/texture";
  63886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63887. import { Engine } from "babylonjs/Engines/engine";
  63888. import "babylonjs/Shaders/refraction.fragment";
  63889. /**
  63890. * Post process which applies a refractin texture
  63891. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63892. */
  63893. export class RefractionPostProcess extends PostProcess {
  63894. /** the base color of the refraction (used to taint the rendering) */
  63895. color: Color3;
  63896. /** simulated refraction depth */
  63897. depth: number;
  63898. /** the coefficient of the base color (0 to remove base color tainting) */
  63899. colorLevel: number;
  63900. private _refTexture;
  63901. private _ownRefractionTexture;
  63902. /**
  63903. * Gets or sets the refraction texture
  63904. * Please note that you are responsible for disposing the texture if you set it manually
  63905. */
  63906. refractionTexture: Texture;
  63907. /**
  63908. * Initializes the RefractionPostProcess
  63909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63910. * @param name The name of the effect.
  63911. * @param refractionTextureUrl Url of the refraction texture to use
  63912. * @param color the base color of the refraction (used to taint the rendering)
  63913. * @param depth simulated refraction depth
  63914. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63915. * @param camera The camera to apply the render pass to.
  63916. * @param options The required width/height ratio to downsize to before computing the render pass.
  63917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63918. * @param engine The engine which the post process will be applied. (default: current engine)
  63919. * @param reusable If the post process can be reused on the same frame. (default: false)
  63920. */
  63921. constructor(name: string, refractionTextureUrl: string,
  63922. /** the base color of the refraction (used to taint the rendering) */
  63923. color: Color3,
  63924. /** simulated refraction depth */
  63925. depth: number,
  63926. /** the coefficient of the base color (0 to remove base color tainting) */
  63927. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63928. /**
  63929. * Disposes of the post process
  63930. * @param camera Camera to dispose post process on
  63931. */
  63932. dispose(camera: Camera): void;
  63933. }
  63934. }
  63935. declare module "babylonjs/Shaders/sharpen.fragment" {
  63936. /** @hidden */
  63937. export var sharpenPixelShader: {
  63938. name: string;
  63939. shader: string;
  63940. };
  63941. }
  63942. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63943. import { Nullable } from "babylonjs/types";
  63944. import { Camera } from "babylonjs/Cameras/camera";
  63945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63946. import "babylonjs/Shaders/sharpen.fragment";
  63947. import { Engine } from "babylonjs/Engines/engine";
  63948. /**
  63949. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63950. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63951. */
  63952. export class SharpenPostProcess extends PostProcess {
  63953. /**
  63954. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63955. */
  63956. colorAmount: number;
  63957. /**
  63958. * How much sharpness should be applied (default: 0.3)
  63959. */
  63960. edgeAmount: number;
  63961. /**
  63962. * Creates a new instance ConvolutionPostProcess
  63963. * @param name The name of the effect.
  63964. * @param options The required width/height ratio to downsize to before computing the render pass.
  63965. * @param camera The camera to apply the render pass to.
  63966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63967. * @param engine The engine which the post process will be applied. (default: current engine)
  63968. * @param reusable If the post process can be reused on the same frame. (default: false)
  63969. * @param textureType Type of textures used when performing the post process. (default: 0)
  63970. * @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)
  63971. */
  63972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63973. }
  63974. }
  63975. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63976. import { Nullable } from "babylonjs/types";
  63977. import { Camera } from "babylonjs/Cameras/camera";
  63978. import { Engine } from "babylonjs/Engines/engine";
  63979. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63980. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63981. /**
  63982. * PostProcessRenderPipeline
  63983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63984. */
  63985. export class PostProcessRenderPipeline {
  63986. private engine;
  63987. private _renderEffects;
  63988. private _renderEffectsForIsolatedPass;
  63989. /**
  63990. * List of inspectable custom properties (used by the Inspector)
  63991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63992. */
  63993. inspectableCustomProperties: IInspectable[];
  63994. /**
  63995. * @hidden
  63996. */
  63997. protected _cameras: Camera[];
  63998. /** @hidden */
  63999. _name: string;
  64000. /**
  64001. * Gets pipeline name
  64002. */
  64003. readonly name: string;
  64004. /** Gets the list of attached cameras */
  64005. readonly cameras: Camera[];
  64006. /**
  64007. * Initializes a PostProcessRenderPipeline
  64008. * @param engine engine to add the pipeline to
  64009. * @param name name of the pipeline
  64010. */
  64011. constructor(engine: Engine, name: string);
  64012. /**
  64013. * Gets the class name
  64014. * @returns "PostProcessRenderPipeline"
  64015. */
  64016. getClassName(): string;
  64017. /**
  64018. * If all the render effects in the pipeline are supported
  64019. */
  64020. readonly isSupported: boolean;
  64021. /**
  64022. * Adds an effect to the pipeline
  64023. * @param renderEffect the effect to add
  64024. */
  64025. addEffect(renderEffect: PostProcessRenderEffect): void;
  64026. /** @hidden */
  64027. _rebuild(): void;
  64028. /** @hidden */
  64029. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64030. /** @hidden */
  64031. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64032. /** @hidden */
  64033. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64034. /** @hidden */
  64035. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64036. /** @hidden */
  64037. _attachCameras(cameras: Camera, unique: boolean): void;
  64038. /** @hidden */
  64039. _attachCameras(cameras: Camera[], unique: boolean): void;
  64040. /** @hidden */
  64041. _detachCameras(cameras: Camera): void;
  64042. /** @hidden */
  64043. _detachCameras(cameras: Nullable<Camera[]>): void;
  64044. /** @hidden */
  64045. _update(): void;
  64046. /** @hidden */
  64047. _reset(): void;
  64048. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64049. /**
  64050. * Disposes of the pipeline
  64051. */
  64052. dispose(): void;
  64053. }
  64054. }
  64055. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64056. import { Camera } from "babylonjs/Cameras/camera";
  64057. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64058. /**
  64059. * PostProcessRenderPipelineManager class
  64060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64061. */
  64062. export class PostProcessRenderPipelineManager {
  64063. private _renderPipelines;
  64064. /**
  64065. * Initializes a PostProcessRenderPipelineManager
  64066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64067. */
  64068. constructor();
  64069. /**
  64070. * Gets the list of supported render pipelines
  64071. */
  64072. readonly supportedPipelines: PostProcessRenderPipeline[];
  64073. /**
  64074. * Adds a pipeline to the manager
  64075. * @param renderPipeline The pipeline to add
  64076. */
  64077. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64078. /**
  64079. * Attaches a camera to the pipeline
  64080. * @param renderPipelineName The name of the pipeline to attach to
  64081. * @param cameras the camera to attach
  64082. * @param unique if the camera can be attached multiple times to the pipeline
  64083. */
  64084. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64085. /**
  64086. * Detaches a camera from the pipeline
  64087. * @param renderPipelineName The name of the pipeline to detach from
  64088. * @param cameras the camera to detach
  64089. */
  64090. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64091. /**
  64092. * Enables an effect by name on a pipeline
  64093. * @param renderPipelineName the name of the pipeline to enable the effect in
  64094. * @param renderEffectName the name of the effect to enable
  64095. * @param cameras the cameras that the effect should be enabled on
  64096. */
  64097. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64098. /**
  64099. * Disables an effect by name on a pipeline
  64100. * @param renderPipelineName the name of the pipeline to disable the effect in
  64101. * @param renderEffectName the name of the effect to disable
  64102. * @param cameras the cameras that the effect should be disabled on
  64103. */
  64104. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64105. /**
  64106. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64107. */
  64108. update(): void;
  64109. /** @hidden */
  64110. _rebuild(): void;
  64111. /**
  64112. * Disposes of the manager and pipelines
  64113. */
  64114. dispose(): void;
  64115. }
  64116. }
  64117. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64118. import { ISceneComponent } from "babylonjs/sceneComponent";
  64119. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64120. import { Scene } from "babylonjs/scene";
  64121. module "babylonjs/scene" {
  64122. interface Scene {
  64123. /** @hidden (Backing field) */
  64124. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64125. /**
  64126. * Gets the postprocess render pipeline manager
  64127. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64128. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64129. */
  64130. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64131. }
  64132. }
  64133. /**
  64134. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64135. */
  64136. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64137. /**
  64138. * The component name helpfull to identify the component in the list of scene components.
  64139. */
  64140. readonly name: string;
  64141. /**
  64142. * The scene the component belongs to.
  64143. */
  64144. scene: Scene;
  64145. /**
  64146. * Creates a new instance of the component for the given scene
  64147. * @param scene Defines the scene to register the component in
  64148. */
  64149. constructor(scene: Scene);
  64150. /**
  64151. * Registers the component in a given scene
  64152. */
  64153. register(): void;
  64154. /**
  64155. * Rebuilds the elements related to this component in case of
  64156. * context lost for instance.
  64157. */
  64158. rebuild(): void;
  64159. /**
  64160. * Disposes the component and the associated ressources
  64161. */
  64162. dispose(): void;
  64163. private _gatherRenderTargets;
  64164. }
  64165. }
  64166. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64167. import { Nullable } from "babylonjs/types";
  64168. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64169. import { Camera } from "babylonjs/Cameras/camera";
  64170. import { IDisposable } from "babylonjs/scene";
  64171. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64172. import { Scene } from "babylonjs/scene";
  64173. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64174. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64175. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64176. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64177. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64178. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64179. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64180. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64181. import { Animation } from "babylonjs/Animations/animation";
  64182. /**
  64183. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64184. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64185. */
  64186. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64187. private _scene;
  64188. private _camerasToBeAttached;
  64189. /**
  64190. * ID of the sharpen post process,
  64191. */
  64192. private readonly SharpenPostProcessId;
  64193. /**
  64194. * @ignore
  64195. * ID of the image processing post process;
  64196. */
  64197. readonly ImageProcessingPostProcessId: string;
  64198. /**
  64199. * @ignore
  64200. * ID of the Fast Approximate Anti-Aliasing post process;
  64201. */
  64202. readonly FxaaPostProcessId: string;
  64203. /**
  64204. * ID of the chromatic aberration post process,
  64205. */
  64206. private readonly ChromaticAberrationPostProcessId;
  64207. /**
  64208. * ID of the grain post process
  64209. */
  64210. private readonly GrainPostProcessId;
  64211. /**
  64212. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64213. */
  64214. sharpen: SharpenPostProcess;
  64215. private _sharpenEffect;
  64216. private bloom;
  64217. /**
  64218. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64219. */
  64220. depthOfField: DepthOfFieldEffect;
  64221. /**
  64222. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64223. */
  64224. fxaa: FxaaPostProcess;
  64225. /**
  64226. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64227. */
  64228. imageProcessing: ImageProcessingPostProcess;
  64229. /**
  64230. * Chromatic aberration post process which will shift rgb colors in the image
  64231. */
  64232. chromaticAberration: ChromaticAberrationPostProcess;
  64233. private _chromaticAberrationEffect;
  64234. /**
  64235. * Grain post process which add noise to the image
  64236. */
  64237. grain: GrainPostProcess;
  64238. private _grainEffect;
  64239. /**
  64240. * Glow post process which adds a glow to emissive areas of the image
  64241. */
  64242. private _glowLayer;
  64243. /**
  64244. * Animations which can be used to tweak settings over a period of time
  64245. */
  64246. animations: Animation[];
  64247. private _imageProcessingConfigurationObserver;
  64248. private _sharpenEnabled;
  64249. private _bloomEnabled;
  64250. private _depthOfFieldEnabled;
  64251. private _depthOfFieldBlurLevel;
  64252. private _fxaaEnabled;
  64253. private _imageProcessingEnabled;
  64254. private _defaultPipelineTextureType;
  64255. private _bloomScale;
  64256. private _chromaticAberrationEnabled;
  64257. private _grainEnabled;
  64258. private _buildAllowed;
  64259. /**
  64260. * Gets active scene
  64261. */
  64262. readonly scene: Scene;
  64263. /**
  64264. * Enable or disable the sharpen process from the pipeline
  64265. */
  64266. sharpenEnabled: boolean;
  64267. private _resizeObserver;
  64268. private _hardwareScaleLevel;
  64269. private _bloomKernel;
  64270. /**
  64271. * Specifies the size of the bloom blur kernel, relative to the final output size
  64272. */
  64273. bloomKernel: number;
  64274. /**
  64275. * Specifies the weight of the bloom in the final rendering
  64276. */
  64277. private _bloomWeight;
  64278. /**
  64279. * Specifies the luma threshold for the area that will be blurred by the bloom
  64280. */
  64281. private _bloomThreshold;
  64282. private _hdr;
  64283. /**
  64284. * The strength of the bloom.
  64285. */
  64286. bloomWeight: number;
  64287. /**
  64288. * The strength of the bloom.
  64289. */
  64290. bloomThreshold: number;
  64291. /**
  64292. * The scale of the bloom, lower value will provide better performance.
  64293. */
  64294. bloomScale: number;
  64295. /**
  64296. * Enable or disable the bloom from the pipeline
  64297. */
  64298. bloomEnabled: boolean;
  64299. private _rebuildBloom;
  64300. /**
  64301. * If the depth of field is enabled.
  64302. */
  64303. depthOfFieldEnabled: boolean;
  64304. /**
  64305. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64306. */
  64307. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64308. /**
  64309. * If the anti aliasing is enabled.
  64310. */
  64311. fxaaEnabled: boolean;
  64312. private _samples;
  64313. /**
  64314. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64315. */
  64316. samples: number;
  64317. /**
  64318. * If image processing is enabled.
  64319. */
  64320. imageProcessingEnabled: boolean;
  64321. /**
  64322. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64323. */
  64324. glowLayerEnabled: boolean;
  64325. /**
  64326. * Gets the glow layer (or null if not defined)
  64327. */
  64328. readonly glowLayer: Nullable<GlowLayer>;
  64329. /**
  64330. * Enable or disable the chromaticAberration process from the pipeline
  64331. */
  64332. chromaticAberrationEnabled: boolean;
  64333. /**
  64334. * Enable or disable the grain process from the pipeline
  64335. */
  64336. grainEnabled: boolean;
  64337. /**
  64338. * @constructor
  64339. * @param name - The rendering pipeline name (default: "")
  64340. * @param hdr - If high dynamic range textures should be used (default: true)
  64341. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64342. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64343. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64344. */
  64345. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64346. /**
  64347. * Get the class name
  64348. * @returns "DefaultRenderingPipeline"
  64349. */
  64350. getClassName(): string;
  64351. /**
  64352. * Force the compilation of the entire pipeline.
  64353. */
  64354. prepare(): void;
  64355. private _hasCleared;
  64356. private _prevPostProcess;
  64357. private _prevPrevPostProcess;
  64358. private _setAutoClearAndTextureSharing;
  64359. private _depthOfFieldSceneObserver;
  64360. private _buildPipeline;
  64361. private _disposePostProcesses;
  64362. /**
  64363. * Adds a camera to the pipeline
  64364. * @param camera the camera to be added
  64365. */
  64366. addCamera(camera: Camera): void;
  64367. /**
  64368. * Removes a camera from the pipeline
  64369. * @param camera the camera to remove
  64370. */
  64371. removeCamera(camera: Camera): void;
  64372. /**
  64373. * Dispose of the pipeline and stop all post processes
  64374. */
  64375. dispose(): void;
  64376. /**
  64377. * Serialize the rendering pipeline (Used when exporting)
  64378. * @returns the serialized object
  64379. */
  64380. serialize(): any;
  64381. /**
  64382. * Parse the serialized pipeline
  64383. * @param source Source pipeline.
  64384. * @param scene The scene to load the pipeline to.
  64385. * @param rootUrl The URL of the serialized pipeline.
  64386. * @returns An instantiated pipeline from the serialized object.
  64387. */
  64388. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64389. }
  64390. }
  64391. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64392. /** @hidden */
  64393. export var lensHighlightsPixelShader: {
  64394. name: string;
  64395. shader: string;
  64396. };
  64397. }
  64398. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64399. /** @hidden */
  64400. export var depthOfFieldPixelShader: {
  64401. name: string;
  64402. shader: string;
  64403. };
  64404. }
  64405. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64406. import { Camera } from "babylonjs/Cameras/camera";
  64407. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64408. import { Scene } from "babylonjs/scene";
  64409. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64410. import "babylonjs/Shaders/chromaticAberration.fragment";
  64411. import "babylonjs/Shaders/lensHighlights.fragment";
  64412. import "babylonjs/Shaders/depthOfField.fragment";
  64413. /**
  64414. * BABYLON.JS Chromatic Aberration GLSL Shader
  64415. * Author: Olivier Guyot
  64416. * Separates very slightly R, G and B colors on the edges of the screen
  64417. * Inspired by Francois Tarlier & Martins Upitis
  64418. */
  64419. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64420. /**
  64421. * @ignore
  64422. * The chromatic aberration PostProcess id in the pipeline
  64423. */
  64424. LensChromaticAberrationEffect: string;
  64425. /**
  64426. * @ignore
  64427. * The highlights enhancing PostProcess id in the pipeline
  64428. */
  64429. HighlightsEnhancingEffect: string;
  64430. /**
  64431. * @ignore
  64432. * The depth-of-field PostProcess id in the pipeline
  64433. */
  64434. LensDepthOfFieldEffect: string;
  64435. private _scene;
  64436. private _depthTexture;
  64437. private _grainTexture;
  64438. private _chromaticAberrationPostProcess;
  64439. private _highlightsPostProcess;
  64440. private _depthOfFieldPostProcess;
  64441. private _edgeBlur;
  64442. private _grainAmount;
  64443. private _chromaticAberration;
  64444. private _distortion;
  64445. private _highlightsGain;
  64446. private _highlightsThreshold;
  64447. private _dofDistance;
  64448. private _dofAperture;
  64449. private _dofDarken;
  64450. private _dofPentagon;
  64451. private _blurNoise;
  64452. /**
  64453. * @constructor
  64454. *
  64455. * Effect parameters are as follow:
  64456. * {
  64457. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64458. * edge_blur: number; // from 0 to x (1 for realism)
  64459. * distortion: number; // from 0 to x (1 for realism)
  64460. * grain_amount: number; // from 0 to 1
  64461. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64462. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64463. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64464. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64465. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64466. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64467. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64468. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64469. * }
  64470. * Note: if an effect parameter is unset, effect is disabled
  64471. *
  64472. * @param name The rendering pipeline name
  64473. * @param parameters - An object containing all parameters (see above)
  64474. * @param scene The scene linked to this pipeline
  64475. * @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)
  64476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64477. */
  64478. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64479. /**
  64480. * Get the class name
  64481. * @returns "LensRenderingPipeline"
  64482. */
  64483. getClassName(): string;
  64484. /**
  64485. * Gets associated scene
  64486. */
  64487. readonly scene: Scene;
  64488. /**
  64489. * Gets or sets the edge blur
  64490. */
  64491. edgeBlur: number;
  64492. /**
  64493. * Gets or sets the grain amount
  64494. */
  64495. grainAmount: number;
  64496. /**
  64497. * Gets or sets the chromatic aberration amount
  64498. */
  64499. chromaticAberration: number;
  64500. /**
  64501. * Gets or sets the depth of field aperture
  64502. */
  64503. dofAperture: number;
  64504. /**
  64505. * Gets or sets the edge distortion
  64506. */
  64507. edgeDistortion: number;
  64508. /**
  64509. * Gets or sets the depth of field distortion
  64510. */
  64511. dofDistortion: number;
  64512. /**
  64513. * Gets or sets the darken out of focus amount
  64514. */
  64515. darkenOutOfFocus: number;
  64516. /**
  64517. * Gets or sets a boolean indicating if blur noise is enabled
  64518. */
  64519. blurNoise: boolean;
  64520. /**
  64521. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64522. */
  64523. pentagonBokeh: boolean;
  64524. /**
  64525. * Gets or sets the highlight grain amount
  64526. */
  64527. highlightsGain: number;
  64528. /**
  64529. * Gets or sets the highlight threshold
  64530. */
  64531. highlightsThreshold: number;
  64532. /**
  64533. * Sets the amount of blur at the edges
  64534. * @param amount blur amount
  64535. */
  64536. setEdgeBlur(amount: number): void;
  64537. /**
  64538. * Sets edge blur to 0
  64539. */
  64540. disableEdgeBlur(): void;
  64541. /**
  64542. * Sets the amout of grain
  64543. * @param amount Amount of grain
  64544. */
  64545. setGrainAmount(amount: number): void;
  64546. /**
  64547. * Set grain amount to 0
  64548. */
  64549. disableGrain(): void;
  64550. /**
  64551. * Sets the chromatic aberration amount
  64552. * @param amount amount of chromatic aberration
  64553. */
  64554. setChromaticAberration(amount: number): void;
  64555. /**
  64556. * Sets chromatic aberration amount to 0
  64557. */
  64558. disableChromaticAberration(): void;
  64559. /**
  64560. * Sets the EdgeDistortion amount
  64561. * @param amount amount of EdgeDistortion
  64562. */
  64563. setEdgeDistortion(amount: number): void;
  64564. /**
  64565. * Sets edge distortion to 0
  64566. */
  64567. disableEdgeDistortion(): void;
  64568. /**
  64569. * Sets the FocusDistance amount
  64570. * @param amount amount of FocusDistance
  64571. */
  64572. setFocusDistance(amount: number): void;
  64573. /**
  64574. * Disables depth of field
  64575. */
  64576. disableDepthOfField(): void;
  64577. /**
  64578. * Sets the Aperture amount
  64579. * @param amount amount of Aperture
  64580. */
  64581. setAperture(amount: number): void;
  64582. /**
  64583. * Sets the DarkenOutOfFocus amount
  64584. * @param amount amount of DarkenOutOfFocus
  64585. */
  64586. setDarkenOutOfFocus(amount: number): void;
  64587. private _pentagonBokehIsEnabled;
  64588. /**
  64589. * Creates a pentagon bokeh effect
  64590. */
  64591. enablePentagonBokeh(): void;
  64592. /**
  64593. * Disables the pentagon bokeh effect
  64594. */
  64595. disablePentagonBokeh(): void;
  64596. /**
  64597. * Enables noise blur
  64598. */
  64599. enableNoiseBlur(): void;
  64600. /**
  64601. * Disables noise blur
  64602. */
  64603. disableNoiseBlur(): void;
  64604. /**
  64605. * Sets the HighlightsGain amount
  64606. * @param amount amount of HighlightsGain
  64607. */
  64608. setHighlightsGain(amount: number): void;
  64609. /**
  64610. * Sets the HighlightsThreshold amount
  64611. * @param amount amount of HighlightsThreshold
  64612. */
  64613. setHighlightsThreshold(amount: number): void;
  64614. /**
  64615. * Disables highlights
  64616. */
  64617. disableHighlights(): void;
  64618. /**
  64619. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64620. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64621. */
  64622. dispose(disableDepthRender?: boolean): void;
  64623. private _createChromaticAberrationPostProcess;
  64624. private _createHighlightsPostProcess;
  64625. private _createDepthOfFieldPostProcess;
  64626. private _createGrainTexture;
  64627. }
  64628. }
  64629. declare module "babylonjs/Shaders/ssao2.fragment" {
  64630. /** @hidden */
  64631. export var ssao2PixelShader: {
  64632. name: string;
  64633. shader: string;
  64634. };
  64635. }
  64636. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64637. /** @hidden */
  64638. export var ssaoCombinePixelShader: {
  64639. name: string;
  64640. shader: string;
  64641. };
  64642. }
  64643. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64644. import { Camera } from "babylonjs/Cameras/camera";
  64645. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64646. import { Scene } from "babylonjs/scene";
  64647. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64648. import "babylonjs/Shaders/ssao2.fragment";
  64649. import "babylonjs/Shaders/ssaoCombine.fragment";
  64650. /**
  64651. * Render pipeline to produce ssao effect
  64652. */
  64653. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64654. /**
  64655. * @ignore
  64656. * The PassPostProcess id in the pipeline that contains the original scene color
  64657. */
  64658. SSAOOriginalSceneColorEffect: string;
  64659. /**
  64660. * @ignore
  64661. * The SSAO PostProcess id in the pipeline
  64662. */
  64663. SSAORenderEffect: string;
  64664. /**
  64665. * @ignore
  64666. * The horizontal blur PostProcess id in the pipeline
  64667. */
  64668. SSAOBlurHRenderEffect: string;
  64669. /**
  64670. * @ignore
  64671. * The vertical blur PostProcess id in the pipeline
  64672. */
  64673. SSAOBlurVRenderEffect: string;
  64674. /**
  64675. * @ignore
  64676. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64677. */
  64678. SSAOCombineRenderEffect: string;
  64679. /**
  64680. * The output strength of the SSAO post-process. Default value is 1.0.
  64681. */
  64682. totalStrength: number;
  64683. /**
  64684. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64685. */
  64686. maxZ: number;
  64687. /**
  64688. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64689. */
  64690. minZAspect: number;
  64691. private _samples;
  64692. /**
  64693. * Number of samples used for the SSAO calculations. Default value is 8
  64694. */
  64695. samples: number;
  64696. private _textureSamples;
  64697. /**
  64698. * Number of samples to use for antialiasing
  64699. */
  64700. textureSamples: number;
  64701. /**
  64702. * Ratio object used for SSAO ratio and blur ratio
  64703. */
  64704. private _ratio;
  64705. /**
  64706. * Dynamically generated sphere sampler.
  64707. */
  64708. private _sampleSphere;
  64709. /**
  64710. * Blur filter offsets
  64711. */
  64712. private _samplerOffsets;
  64713. private _expensiveBlur;
  64714. /**
  64715. * If bilateral blur should be used
  64716. */
  64717. expensiveBlur: boolean;
  64718. /**
  64719. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64720. */
  64721. radius: number;
  64722. /**
  64723. * The base color of the SSAO post-process
  64724. * The final result is "base + ssao" between [0, 1]
  64725. */
  64726. base: number;
  64727. /**
  64728. * Support test.
  64729. */
  64730. static readonly IsSupported: boolean;
  64731. private _scene;
  64732. private _depthTexture;
  64733. private _normalTexture;
  64734. private _randomTexture;
  64735. private _originalColorPostProcess;
  64736. private _ssaoPostProcess;
  64737. private _blurHPostProcess;
  64738. private _blurVPostProcess;
  64739. private _ssaoCombinePostProcess;
  64740. private _firstUpdate;
  64741. /**
  64742. * Gets active scene
  64743. */
  64744. readonly scene: Scene;
  64745. /**
  64746. * @constructor
  64747. * @param name The rendering pipeline name
  64748. * @param scene The scene linked to this pipeline
  64749. * @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 }
  64750. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64751. */
  64752. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64753. /**
  64754. * Get the class name
  64755. * @returns "SSAO2RenderingPipeline"
  64756. */
  64757. getClassName(): string;
  64758. /**
  64759. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64760. */
  64761. dispose(disableGeometryBufferRenderer?: boolean): void;
  64762. private _createBlurPostProcess;
  64763. /** @hidden */
  64764. _rebuild(): void;
  64765. private _bits;
  64766. private _radicalInverse_VdC;
  64767. private _hammersley;
  64768. private _hemisphereSample_uniform;
  64769. private _generateHemisphere;
  64770. private _createSSAOPostProcess;
  64771. private _createSSAOCombinePostProcess;
  64772. private _createRandomTexture;
  64773. /**
  64774. * Serialize the rendering pipeline (Used when exporting)
  64775. * @returns the serialized object
  64776. */
  64777. serialize(): any;
  64778. /**
  64779. * Parse the serialized pipeline
  64780. * @param source Source pipeline.
  64781. * @param scene The scene to load the pipeline to.
  64782. * @param rootUrl The URL of the serialized pipeline.
  64783. * @returns An instantiated pipeline from the serialized object.
  64784. */
  64785. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64786. }
  64787. }
  64788. declare module "babylonjs/Shaders/ssao.fragment" {
  64789. /** @hidden */
  64790. export var ssaoPixelShader: {
  64791. name: string;
  64792. shader: string;
  64793. };
  64794. }
  64795. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64796. import { Camera } from "babylonjs/Cameras/camera";
  64797. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64798. import { Scene } from "babylonjs/scene";
  64799. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64800. import "babylonjs/Shaders/ssao.fragment";
  64801. import "babylonjs/Shaders/ssaoCombine.fragment";
  64802. /**
  64803. * Render pipeline to produce ssao effect
  64804. */
  64805. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64806. /**
  64807. * @ignore
  64808. * The PassPostProcess id in the pipeline that contains the original scene color
  64809. */
  64810. SSAOOriginalSceneColorEffect: string;
  64811. /**
  64812. * @ignore
  64813. * The SSAO PostProcess id in the pipeline
  64814. */
  64815. SSAORenderEffect: string;
  64816. /**
  64817. * @ignore
  64818. * The horizontal blur PostProcess id in the pipeline
  64819. */
  64820. SSAOBlurHRenderEffect: string;
  64821. /**
  64822. * @ignore
  64823. * The vertical blur PostProcess id in the pipeline
  64824. */
  64825. SSAOBlurVRenderEffect: string;
  64826. /**
  64827. * @ignore
  64828. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64829. */
  64830. SSAOCombineRenderEffect: string;
  64831. /**
  64832. * The output strength of the SSAO post-process. Default value is 1.0.
  64833. */
  64834. totalStrength: number;
  64835. /**
  64836. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64837. */
  64838. radius: number;
  64839. /**
  64840. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64841. * Must not be equal to fallOff and superior to fallOff.
  64842. * Default value is 0.0075
  64843. */
  64844. area: number;
  64845. /**
  64846. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64847. * Must not be equal to area and inferior to area.
  64848. * Default value is 0.000001
  64849. */
  64850. fallOff: number;
  64851. /**
  64852. * The base color of the SSAO post-process
  64853. * The final result is "base + ssao" between [0, 1]
  64854. */
  64855. base: number;
  64856. private _scene;
  64857. private _depthTexture;
  64858. private _randomTexture;
  64859. private _originalColorPostProcess;
  64860. private _ssaoPostProcess;
  64861. private _blurHPostProcess;
  64862. private _blurVPostProcess;
  64863. private _ssaoCombinePostProcess;
  64864. private _firstUpdate;
  64865. /**
  64866. * Gets active scene
  64867. */
  64868. readonly scene: Scene;
  64869. /**
  64870. * @constructor
  64871. * @param name - The rendering pipeline name
  64872. * @param scene - The scene linked to this pipeline
  64873. * @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 }
  64874. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64875. */
  64876. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64877. /**
  64878. * Get the class name
  64879. * @returns "SSAORenderingPipeline"
  64880. */
  64881. getClassName(): string;
  64882. /**
  64883. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64884. */
  64885. dispose(disableDepthRender?: boolean): void;
  64886. private _createBlurPostProcess;
  64887. /** @hidden */
  64888. _rebuild(): void;
  64889. private _createSSAOPostProcess;
  64890. private _createSSAOCombinePostProcess;
  64891. private _createRandomTexture;
  64892. }
  64893. }
  64894. declare module "babylonjs/Shaders/standard.fragment" {
  64895. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64896. /** @hidden */
  64897. export var standardPixelShader: {
  64898. name: string;
  64899. shader: string;
  64900. };
  64901. }
  64902. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64903. import { Nullable } from "babylonjs/types";
  64904. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64905. import { Camera } from "babylonjs/Cameras/camera";
  64906. import { Texture } from "babylonjs/Materials/Textures/texture";
  64907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64908. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64909. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64910. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64911. import { IDisposable } from "babylonjs/scene";
  64912. import { SpotLight } from "babylonjs/Lights/spotLight";
  64913. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64914. import { Scene } from "babylonjs/scene";
  64915. import { Animation } from "babylonjs/Animations/animation";
  64916. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64917. import "babylonjs/Shaders/standard.fragment";
  64918. /**
  64919. * Standard rendering pipeline
  64920. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64921. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64922. */
  64923. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64924. /**
  64925. * Public members
  64926. */
  64927. /**
  64928. * Post-process which contains the original scene color before the pipeline applies all the effects
  64929. */
  64930. originalPostProcess: Nullable<PostProcess>;
  64931. /**
  64932. * Post-process used to down scale an image x4
  64933. */
  64934. downSampleX4PostProcess: Nullable<PostProcess>;
  64935. /**
  64936. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64937. */
  64938. brightPassPostProcess: Nullable<PostProcess>;
  64939. /**
  64940. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64941. */
  64942. blurHPostProcesses: PostProcess[];
  64943. /**
  64944. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64945. */
  64946. blurVPostProcesses: PostProcess[];
  64947. /**
  64948. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64949. */
  64950. textureAdderPostProcess: Nullable<PostProcess>;
  64951. /**
  64952. * Post-process used to create volumetric lighting effect
  64953. */
  64954. volumetricLightPostProcess: Nullable<PostProcess>;
  64955. /**
  64956. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64957. */
  64958. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64959. /**
  64960. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64961. */
  64962. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64963. /**
  64964. * Post-process used to merge the volumetric light effect and the real scene color
  64965. */
  64966. volumetricLightMergePostProces: Nullable<PostProcess>;
  64967. /**
  64968. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64969. */
  64970. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64971. /**
  64972. * Base post-process used to calculate the average luminance of the final image for HDR
  64973. */
  64974. luminancePostProcess: Nullable<PostProcess>;
  64975. /**
  64976. * Post-processes used to create down sample post-processes in order to get
  64977. * the average luminance of the final image for HDR
  64978. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64979. */
  64980. luminanceDownSamplePostProcesses: PostProcess[];
  64981. /**
  64982. * Post-process used to create a HDR effect (light adaptation)
  64983. */
  64984. hdrPostProcess: Nullable<PostProcess>;
  64985. /**
  64986. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64987. */
  64988. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64989. /**
  64990. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64991. */
  64992. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64993. /**
  64994. * Post-process used to merge the final HDR post-process and the real scene color
  64995. */
  64996. hdrFinalPostProcess: Nullable<PostProcess>;
  64997. /**
  64998. * Post-process used to create a lens flare effect
  64999. */
  65000. lensFlarePostProcess: Nullable<PostProcess>;
  65001. /**
  65002. * Post-process that merges the result of the lens flare post-process and the real scene color
  65003. */
  65004. lensFlareComposePostProcess: Nullable<PostProcess>;
  65005. /**
  65006. * Post-process used to create a motion blur effect
  65007. */
  65008. motionBlurPostProcess: Nullable<PostProcess>;
  65009. /**
  65010. * Post-process used to create a depth of field effect
  65011. */
  65012. depthOfFieldPostProcess: Nullable<PostProcess>;
  65013. /**
  65014. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65015. */
  65016. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65017. /**
  65018. * Represents the brightness threshold in order to configure the illuminated surfaces
  65019. */
  65020. brightThreshold: number;
  65021. /**
  65022. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65023. */
  65024. blurWidth: number;
  65025. /**
  65026. * Sets if the blur for highlighted surfaces must be only horizontal
  65027. */
  65028. horizontalBlur: boolean;
  65029. /**
  65030. * Gets the overall exposure used by the pipeline
  65031. */
  65032. /**
  65033. * Sets the overall exposure used by the pipeline
  65034. */
  65035. exposure: number;
  65036. /**
  65037. * Texture used typically to simulate "dirty" on camera lens
  65038. */
  65039. lensTexture: Nullable<Texture>;
  65040. /**
  65041. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65042. */
  65043. volumetricLightCoefficient: number;
  65044. /**
  65045. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65046. */
  65047. volumetricLightPower: number;
  65048. /**
  65049. * Used the set the blur intensity to smooth the volumetric lights
  65050. */
  65051. volumetricLightBlurScale: number;
  65052. /**
  65053. * Light (spot or directional) used to generate the volumetric lights rays
  65054. * The source light must have a shadow generate so the pipeline can get its
  65055. * depth map
  65056. */
  65057. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65058. /**
  65059. * For eye adaptation, represents the minimum luminance the eye can see
  65060. */
  65061. hdrMinimumLuminance: number;
  65062. /**
  65063. * For eye adaptation, represents the decrease luminance speed
  65064. */
  65065. hdrDecreaseRate: number;
  65066. /**
  65067. * For eye adaptation, represents the increase luminance speed
  65068. */
  65069. hdrIncreaseRate: number;
  65070. /**
  65071. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65072. */
  65073. /**
  65074. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65075. */
  65076. hdrAutoExposure: boolean;
  65077. /**
  65078. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65079. */
  65080. lensColorTexture: Nullable<Texture>;
  65081. /**
  65082. * The overall strengh for the lens flare effect
  65083. */
  65084. lensFlareStrength: number;
  65085. /**
  65086. * Dispersion coefficient for lens flare ghosts
  65087. */
  65088. lensFlareGhostDispersal: number;
  65089. /**
  65090. * Main lens flare halo width
  65091. */
  65092. lensFlareHaloWidth: number;
  65093. /**
  65094. * Based on the lens distortion effect, defines how much the lens flare result
  65095. * is distorted
  65096. */
  65097. lensFlareDistortionStrength: number;
  65098. /**
  65099. * Configures the blur intensity used for for lens flare (halo)
  65100. */
  65101. lensFlareBlurWidth: number;
  65102. /**
  65103. * Lens star texture must be used to simulate rays on the flares and is available
  65104. * in the documentation
  65105. */
  65106. lensStarTexture: Nullable<Texture>;
  65107. /**
  65108. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65109. * flare effect by taking account of the dirt texture
  65110. */
  65111. lensFlareDirtTexture: Nullable<Texture>;
  65112. /**
  65113. * Represents the focal length for the depth of field effect
  65114. */
  65115. depthOfFieldDistance: number;
  65116. /**
  65117. * Represents the blur intensity for the blurred part of the depth of field effect
  65118. */
  65119. depthOfFieldBlurWidth: number;
  65120. /**
  65121. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65122. */
  65123. /**
  65124. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65125. */
  65126. motionStrength: number;
  65127. /**
  65128. * Gets wether or not the motion blur post-process is object based or screen based.
  65129. */
  65130. /**
  65131. * Sets wether or not the motion blur post-process should be object based or screen based
  65132. */
  65133. objectBasedMotionBlur: boolean;
  65134. /**
  65135. * List of animations for the pipeline (IAnimatable implementation)
  65136. */
  65137. animations: Animation[];
  65138. /**
  65139. * Private members
  65140. */
  65141. private _scene;
  65142. private _currentDepthOfFieldSource;
  65143. private _basePostProcess;
  65144. private _fixedExposure;
  65145. private _currentExposure;
  65146. private _hdrAutoExposure;
  65147. private _hdrCurrentLuminance;
  65148. private _motionStrength;
  65149. private _isObjectBasedMotionBlur;
  65150. private _floatTextureType;
  65151. private _camerasToBeAttached;
  65152. private _ratio;
  65153. private _bloomEnabled;
  65154. private _depthOfFieldEnabled;
  65155. private _vlsEnabled;
  65156. private _lensFlareEnabled;
  65157. private _hdrEnabled;
  65158. private _motionBlurEnabled;
  65159. private _fxaaEnabled;
  65160. private _motionBlurSamples;
  65161. private _volumetricLightStepsCount;
  65162. private _samples;
  65163. /**
  65164. * @ignore
  65165. * Specifies if the bloom pipeline is enabled
  65166. */
  65167. BloomEnabled: boolean;
  65168. /**
  65169. * @ignore
  65170. * Specifies if the depth of field pipeline is enabed
  65171. */
  65172. DepthOfFieldEnabled: boolean;
  65173. /**
  65174. * @ignore
  65175. * Specifies if the lens flare pipeline is enabed
  65176. */
  65177. LensFlareEnabled: boolean;
  65178. /**
  65179. * @ignore
  65180. * Specifies if the HDR pipeline is enabled
  65181. */
  65182. HDREnabled: boolean;
  65183. /**
  65184. * @ignore
  65185. * Specifies if the volumetric lights scattering effect is enabled
  65186. */
  65187. VLSEnabled: boolean;
  65188. /**
  65189. * @ignore
  65190. * Specifies if the motion blur effect is enabled
  65191. */
  65192. MotionBlurEnabled: boolean;
  65193. /**
  65194. * Specifies if anti-aliasing is enabled
  65195. */
  65196. fxaaEnabled: boolean;
  65197. /**
  65198. * Specifies the number of steps used to calculate the volumetric lights
  65199. * Typically in interval [50, 200]
  65200. */
  65201. volumetricLightStepsCount: number;
  65202. /**
  65203. * Specifies the number of samples used for the motion blur effect
  65204. * Typically in interval [16, 64]
  65205. */
  65206. motionBlurSamples: number;
  65207. /**
  65208. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65209. */
  65210. samples: number;
  65211. /**
  65212. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65213. * @constructor
  65214. * @param name The rendering pipeline name
  65215. * @param scene The scene linked to this pipeline
  65216. * @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)
  65217. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65218. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65219. */
  65220. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65221. private _buildPipeline;
  65222. private _createDownSampleX4PostProcess;
  65223. private _createBrightPassPostProcess;
  65224. private _createBlurPostProcesses;
  65225. private _createTextureAdderPostProcess;
  65226. private _createVolumetricLightPostProcess;
  65227. private _createLuminancePostProcesses;
  65228. private _createHdrPostProcess;
  65229. private _createLensFlarePostProcess;
  65230. private _createDepthOfFieldPostProcess;
  65231. private _createMotionBlurPostProcess;
  65232. private _getDepthTexture;
  65233. private _disposePostProcesses;
  65234. /**
  65235. * Dispose of the pipeline and stop all post processes
  65236. */
  65237. dispose(): void;
  65238. /**
  65239. * Serialize the rendering pipeline (Used when exporting)
  65240. * @returns the serialized object
  65241. */
  65242. serialize(): any;
  65243. /**
  65244. * Parse the serialized pipeline
  65245. * @param source Source pipeline.
  65246. * @param scene The scene to load the pipeline to.
  65247. * @param rootUrl The URL of the serialized pipeline.
  65248. * @returns An instantiated pipeline from the serialized object.
  65249. */
  65250. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65251. /**
  65252. * Luminance steps
  65253. */
  65254. static LuminanceSteps: number;
  65255. }
  65256. }
  65257. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65258. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65259. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65260. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65261. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65262. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65263. }
  65264. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65265. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65266. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65267. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65268. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65269. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65270. }
  65271. declare module "babylonjs/Shaders/tonemap.fragment" {
  65272. /** @hidden */
  65273. export var tonemapPixelShader: {
  65274. name: string;
  65275. shader: string;
  65276. };
  65277. }
  65278. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65279. import { Camera } from "babylonjs/Cameras/camera";
  65280. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65281. import "babylonjs/Shaders/tonemap.fragment";
  65282. import { Engine } from "babylonjs/Engines/engine";
  65283. /** Defines operator used for tonemapping */
  65284. export enum TonemappingOperator {
  65285. /** Hable */
  65286. Hable = 0,
  65287. /** Reinhard */
  65288. Reinhard = 1,
  65289. /** HejiDawson */
  65290. HejiDawson = 2,
  65291. /** Photographic */
  65292. Photographic = 3
  65293. }
  65294. /**
  65295. * Defines a post process to apply tone mapping
  65296. */
  65297. export class TonemapPostProcess extends PostProcess {
  65298. private _operator;
  65299. /** Defines the required exposure adjustement */
  65300. exposureAdjustment: number;
  65301. /**
  65302. * Creates a new TonemapPostProcess
  65303. * @param name defines the name of the postprocess
  65304. * @param _operator defines the operator to use
  65305. * @param exposureAdjustment defines the required exposure adjustement
  65306. * @param camera defines the camera to use (can be null)
  65307. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65308. * @param engine defines the hosting engine (can be ignore if camera is set)
  65309. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65310. */
  65311. constructor(name: string, _operator: TonemappingOperator,
  65312. /** Defines the required exposure adjustement */
  65313. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65314. }
  65315. }
  65316. declare module "babylonjs/Shaders/depth.vertex" {
  65317. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65321. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65322. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65323. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65324. /** @hidden */
  65325. export var depthVertexShader: {
  65326. name: string;
  65327. shader: string;
  65328. };
  65329. }
  65330. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65331. /** @hidden */
  65332. export var volumetricLightScatteringPixelShader: {
  65333. name: string;
  65334. shader: string;
  65335. };
  65336. }
  65337. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65338. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65340. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65341. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65343. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65344. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65345. /** @hidden */
  65346. export var volumetricLightScatteringPassVertexShader: {
  65347. name: string;
  65348. shader: string;
  65349. };
  65350. }
  65351. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65352. /** @hidden */
  65353. export var volumetricLightScatteringPassPixelShader: {
  65354. name: string;
  65355. shader: string;
  65356. };
  65357. }
  65358. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65359. import { Vector3 } from "babylonjs/Maths/math.vector";
  65360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65361. import { Mesh } from "babylonjs/Meshes/mesh";
  65362. import { Camera } from "babylonjs/Cameras/camera";
  65363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65364. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65365. import { Scene } from "babylonjs/scene";
  65366. import "babylonjs/Meshes/Builders/planeBuilder";
  65367. import "babylonjs/Shaders/depth.vertex";
  65368. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65369. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65370. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65371. import { Engine } from "babylonjs/Engines/engine";
  65372. /**
  65373. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65374. */
  65375. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65376. private _volumetricLightScatteringPass;
  65377. private _volumetricLightScatteringRTT;
  65378. private _viewPort;
  65379. private _screenCoordinates;
  65380. private _cachedDefines;
  65381. /**
  65382. * If not undefined, the mesh position is computed from the attached node position
  65383. */
  65384. attachedNode: {
  65385. position: Vector3;
  65386. };
  65387. /**
  65388. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65389. */
  65390. customMeshPosition: Vector3;
  65391. /**
  65392. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65393. */
  65394. useCustomMeshPosition: boolean;
  65395. /**
  65396. * If the post-process should inverse the light scattering direction
  65397. */
  65398. invert: boolean;
  65399. /**
  65400. * The internal mesh used by the post-process
  65401. */
  65402. mesh: Mesh;
  65403. /**
  65404. * @hidden
  65405. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65406. */
  65407. useDiffuseColor: boolean;
  65408. /**
  65409. * Array containing the excluded meshes not rendered in the internal pass
  65410. */
  65411. excludedMeshes: AbstractMesh[];
  65412. /**
  65413. * Controls the overall intensity of the post-process
  65414. */
  65415. exposure: number;
  65416. /**
  65417. * Dissipates each sample's contribution in range [0, 1]
  65418. */
  65419. decay: number;
  65420. /**
  65421. * Controls the overall intensity of each sample
  65422. */
  65423. weight: number;
  65424. /**
  65425. * Controls the density of each sample
  65426. */
  65427. density: number;
  65428. /**
  65429. * @constructor
  65430. * @param name The post-process name
  65431. * @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)
  65432. * @param camera The camera that the post-process will be attached to
  65433. * @param mesh The mesh used to create the light scattering
  65434. * @param samples The post-process quality, default 100
  65435. * @param samplingModeThe post-process filtering mode
  65436. * @param engine The babylon engine
  65437. * @param reusable If the post-process is reusable
  65438. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65439. */
  65440. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65441. /**
  65442. * Returns the string "VolumetricLightScatteringPostProcess"
  65443. * @returns "VolumetricLightScatteringPostProcess"
  65444. */
  65445. getClassName(): string;
  65446. private _isReady;
  65447. /**
  65448. * Sets the new light position for light scattering effect
  65449. * @param position The new custom light position
  65450. */
  65451. setCustomMeshPosition(position: Vector3): void;
  65452. /**
  65453. * Returns the light position for light scattering effect
  65454. * @return Vector3 The custom light position
  65455. */
  65456. getCustomMeshPosition(): Vector3;
  65457. /**
  65458. * Disposes the internal assets and detaches the post-process from the camera
  65459. */
  65460. dispose(camera: Camera): void;
  65461. /**
  65462. * Returns the render target texture used by the post-process
  65463. * @return the render target texture used by the post-process
  65464. */
  65465. getPass(): RenderTargetTexture;
  65466. private _meshExcluded;
  65467. private _createPass;
  65468. private _updateMeshScreenCoordinates;
  65469. /**
  65470. * Creates a default mesh for the Volumeric Light Scattering post-process
  65471. * @param name The mesh name
  65472. * @param scene The scene where to create the mesh
  65473. * @return the default mesh
  65474. */
  65475. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65476. }
  65477. }
  65478. declare module "babylonjs/PostProcesses/index" {
  65479. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65480. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65481. export * from "babylonjs/PostProcesses/bloomEffect";
  65482. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65483. export * from "babylonjs/PostProcesses/blurPostProcess";
  65484. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65485. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65486. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65487. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65488. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65489. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65490. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65491. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65492. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65493. export * from "babylonjs/PostProcesses/filterPostProcess";
  65494. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65495. export * from "babylonjs/PostProcesses/grainPostProcess";
  65496. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65497. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65498. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65499. export * from "babylonjs/PostProcesses/passPostProcess";
  65500. export * from "babylonjs/PostProcesses/postProcess";
  65501. export * from "babylonjs/PostProcesses/postProcessManager";
  65502. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65503. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65504. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65505. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65506. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65507. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65508. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65509. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65510. }
  65511. declare module "babylonjs/Probes/index" {
  65512. export * from "babylonjs/Probes/reflectionProbe";
  65513. }
  65514. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65515. import { Scene } from "babylonjs/scene";
  65516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65517. import { SmartArray } from "babylonjs/Misc/smartArray";
  65518. import { ISceneComponent } from "babylonjs/sceneComponent";
  65519. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65520. import "babylonjs/Meshes/Builders/boxBuilder";
  65521. import "babylonjs/Shaders/color.fragment";
  65522. import "babylonjs/Shaders/color.vertex";
  65523. import { Color3 } from "babylonjs/Maths/math.color";
  65524. module "babylonjs/scene" {
  65525. interface Scene {
  65526. /** @hidden (Backing field) */
  65527. _boundingBoxRenderer: BoundingBoxRenderer;
  65528. /** @hidden (Backing field) */
  65529. _forceShowBoundingBoxes: boolean;
  65530. /**
  65531. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65532. */
  65533. forceShowBoundingBoxes: boolean;
  65534. /**
  65535. * Gets the bounding box renderer associated with the scene
  65536. * @returns a BoundingBoxRenderer
  65537. */
  65538. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65539. }
  65540. }
  65541. module "babylonjs/Meshes/abstractMesh" {
  65542. interface AbstractMesh {
  65543. /** @hidden (Backing field) */
  65544. _showBoundingBox: boolean;
  65545. /**
  65546. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65547. */
  65548. showBoundingBox: boolean;
  65549. }
  65550. }
  65551. /**
  65552. * Component responsible of rendering the bounding box of the meshes in a scene.
  65553. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65554. */
  65555. export class BoundingBoxRenderer implements ISceneComponent {
  65556. /**
  65557. * The component name helpfull to identify the component in the list of scene components.
  65558. */
  65559. readonly name: string;
  65560. /**
  65561. * The scene the component belongs to.
  65562. */
  65563. scene: Scene;
  65564. /**
  65565. * Color of the bounding box lines placed in front of an object
  65566. */
  65567. frontColor: Color3;
  65568. /**
  65569. * Color of the bounding box lines placed behind an object
  65570. */
  65571. backColor: Color3;
  65572. /**
  65573. * Defines if the renderer should show the back lines or not
  65574. */
  65575. showBackLines: boolean;
  65576. /**
  65577. * @hidden
  65578. */
  65579. renderList: SmartArray<BoundingBox>;
  65580. private _colorShader;
  65581. private _vertexBuffers;
  65582. private _indexBuffer;
  65583. private _fillIndexBuffer;
  65584. private _fillIndexData;
  65585. /**
  65586. * Instantiates a new bounding box renderer in a scene.
  65587. * @param scene the scene the renderer renders in
  65588. */
  65589. constructor(scene: Scene);
  65590. /**
  65591. * Registers the component in a given scene
  65592. */
  65593. register(): void;
  65594. private _evaluateSubMesh;
  65595. private _activeMesh;
  65596. private _prepareRessources;
  65597. private _createIndexBuffer;
  65598. /**
  65599. * Rebuilds the elements related to this component in case of
  65600. * context lost for instance.
  65601. */
  65602. rebuild(): void;
  65603. /**
  65604. * @hidden
  65605. */
  65606. reset(): void;
  65607. /**
  65608. * Render the bounding boxes of a specific rendering group
  65609. * @param renderingGroupId defines the rendering group to render
  65610. */
  65611. render(renderingGroupId: number): void;
  65612. /**
  65613. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65614. * @param mesh Define the mesh to render the occlusion bounding box for
  65615. */
  65616. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65617. /**
  65618. * Dispose and release the resources attached to this renderer.
  65619. */
  65620. dispose(): void;
  65621. }
  65622. }
  65623. declare module "babylonjs/Shaders/depth.fragment" {
  65624. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65625. /** @hidden */
  65626. export var depthPixelShader: {
  65627. name: string;
  65628. shader: string;
  65629. };
  65630. }
  65631. declare module "babylonjs/Rendering/depthRenderer" {
  65632. import { Nullable } from "babylonjs/types";
  65633. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65634. import { Scene } from "babylonjs/scene";
  65635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65636. import { Camera } from "babylonjs/Cameras/camera";
  65637. import "babylonjs/Shaders/depth.fragment";
  65638. import "babylonjs/Shaders/depth.vertex";
  65639. /**
  65640. * This represents a depth renderer in Babylon.
  65641. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65642. */
  65643. export class DepthRenderer {
  65644. private _scene;
  65645. private _depthMap;
  65646. private _effect;
  65647. private readonly _storeNonLinearDepth;
  65648. private readonly _clearColor;
  65649. /** Get if the depth renderer is using packed depth or not */
  65650. readonly isPacked: boolean;
  65651. private _cachedDefines;
  65652. private _camera;
  65653. /**
  65654. * Specifiess that the depth renderer will only be used within
  65655. * the camera it is created for.
  65656. * This can help forcing its rendering during the camera processing.
  65657. */
  65658. useOnlyInActiveCamera: boolean;
  65659. /** @hidden */
  65660. static _SceneComponentInitialization: (scene: Scene) => void;
  65661. /**
  65662. * Instantiates a depth renderer
  65663. * @param scene The scene the renderer belongs to
  65664. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65665. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65666. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65667. */
  65668. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65669. /**
  65670. * Creates the depth rendering effect and checks if the effect is ready.
  65671. * @param subMesh The submesh to be used to render the depth map of
  65672. * @param useInstances If multiple world instances should be used
  65673. * @returns if the depth renderer is ready to render the depth map
  65674. */
  65675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65676. /**
  65677. * Gets the texture which the depth map will be written to.
  65678. * @returns The depth map texture
  65679. */
  65680. getDepthMap(): RenderTargetTexture;
  65681. /**
  65682. * Disposes of the depth renderer.
  65683. */
  65684. dispose(): void;
  65685. }
  65686. }
  65687. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65688. import { Nullable } from "babylonjs/types";
  65689. import { Scene } from "babylonjs/scene";
  65690. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65691. import { Camera } from "babylonjs/Cameras/camera";
  65692. import { ISceneComponent } from "babylonjs/sceneComponent";
  65693. module "babylonjs/scene" {
  65694. interface Scene {
  65695. /** @hidden (Backing field) */
  65696. _depthRenderer: {
  65697. [id: string]: DepthRenderer;
  65698. };
  65699. /**
  65700. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65701. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65702. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65703. * @returns the created depth renderer
  65704. */
  65705. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65706. /**
  65707. * Disables a depth renderer for a given camera
  65708. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65709. */
  65710. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65711. }
  65712. }
  65713. /**
  65714. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65715. * in several rendering techniques.
  65716. */
  65717. export class DepthRendererSceneComponent implements ISceneComponent {
  65718. /**
  65719. * The component name helpfull to identify the component in the list of scene components.
  65720. */
  65721. readonly name: string;
  65722. /**
  65723. * The scene the component belongs to.
  65724. */
  65725. scene: Scene;
  65726. /**
  65727. * Creates a new instance of the component for the given scene
  65728. * @param scene Defines the scene to register the component in
  65729. */
  65730. constructor(scene: Scene);
  65731. /**
  65732. * Registers the component in a given scene
  65733. */
  65734. register(): void;
  65735. /**
  65736. * Rebuilds the elements related to this component in case of
  65737. * context lost for instance.
  65738. */
  65739. rebuild(): void;
  65740. /**
  65741. * Disposes the component and the associated ressources
  65742. */
  65743. dispose(): void;
  65744. private _gatherRenderTargets;
  65745. private _gatherActiveCameraRenderTargets;
  65746. }
  65747. }
  65748. declare module "babylonjs/Shaders/outline.fragment" {
  65749. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65750. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65751. /** @hidden */
  65752. export var outlinePixelShader: {
  65753. name: string;
  65754. shader: string;
  65755. };
  65756. }
  65757. declare module "babylonjs/Shaders/outline.vertex" {
  65758. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65759. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65760. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65761. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65762. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65764. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65765. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65766. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65767. /** @hidden */
  65768. export var outlineVertexShader: {
  65769. name: string;
  65770. shader: string;
  65771. };
  65772. }
  65773. declare module "babylonjs/Rendering/outlineRenderer" {
  65774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65775. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65776. import { Scene } from "babylonjs/scene";
  65777. import { ISceneComponent } from "babylonjs/sceneComponent";
  65778. import "babylonjs/Shaders/outline.fragment";
  65779. import "babylonjs/Shaders/outline.vertex";
  65780. module "babylonjs/scene" {
  65781. interface Scene {
  65782. /** @hidden */
  65783. _outlineRenderer: OutlineRenderer;
  65784. /**
  65785. * Gets the outline renderer associated with the scene
  65786. * @returns a OutlineRenderer
  65787. */
  65788. getOutlineRenderer(): OutlineRenderer;
  65789. }
  65790. }
  65791. module "babylonjs/Meshes/abstractMesh" {
  65792. interface AbstractMesh {
  65793. /** @hidden (Backing field) */
  65794. _renderOutline: boolean;
  65795. /**
  65796. * Gets or sets a boolean indicating if the outline must be rendered as well
  65797. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65798. */
  65799. renderOutline: boolean;
  65800. /** @hidden (Backing field) */
  65801. _renderOverlay: boolean;
  65802. /**
  65803. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65804. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65805. */
  65806. renderOverlay: boolean;
  65807. }
  65808. }
  65809. /**
  65810. * This class is responsible to draw bothe outline/overlay of meshes.
  65811. * It should not be used directly but through the available method on mesh.
  65812. */
  65813. export class OutlineRenderer implements ISceneComponent {
  65814. /**
  65815. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65816. */
  65817. private static _StencilReference;
  65818. /**
  65819. * The name of the component. Each component must have a unique name.
  65820. */
  65821. name: string;
  65822. /**
  65823. * The scene the component belongs to.
  65824. */
  65825. scene: Scene;
  65826. /**
  65827. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65828. */
  65829. zOffset: number;
  65830. private _engine;
  65831. private _effect;
  65832. private _cachedDefines;
  65833. private _savedDepthWrite;
  65834. /**
  65835. * Instantiates a new outline renderer. (There could be only one per scene).
  65836. * @param scene Defines the scene it belongs to
  65837. */
  65838. constructor(scene: Scene);
  65839. /**
  65840. * Register the component to one instance of a scene.
  65841. */
  65842. register(): void;
  65843. /**
  65844. * Rebuilds the elements related to this component in case of
  65845. * context lost for instance.
  65846. */
  65847. rebuild(): void;
  65848. /**
  65849. * Disposes the component and the associated ressources.
  65850. */
  65851. dispose(): void;
  65852. /**
  65853. * Renders the outline in the canvas.
  65854. * @param subMesh Defines the sumesh to render
  65855. * @param batch Defines the batch of meshes in case of instances
  65856. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65857. */
  65858. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65859. /**
  65860. * Returns whether or not the outline renderer is ready for a given submesh.
  65861. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65862. * @param subMesh Defines the submesh to check readyness for
  65863. * @param useInstances Defines wheter wee are trying to render instances or not
  65864. * @returns true if ready otherwise false
  65865. */
  65866. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65867. private _beforeRenderingMesh;
  65868. private _afterRenderingMesh;
  65869. }
  65870. }
  65871. declare module "babylonjs/Rendering/index" {
  65872. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65873. export * from "babylonjs/Rendering/depthRenderer";
  65874. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65875. export * from "babylonjs/Rendering/edgesRenderer";
  65876. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65877. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65878. export * from "babylonjs/Rendering/outlineRenderer";
  65879. export * from "babylonjs/Rendering/renderingGroup";
  65880. export * from "babylonjs/Rendering/renderingManager";
  65881. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65882. }
  65883. declare module "babylonjs/Sprites/spritePackedManager" {
  65884. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65885. import { Scene } from "babylonjs/scene";
  65886. /**
  65887. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65888. * @see http://doc.babylonjs.com/babylon101/sprites
  65889. */
  65890. export class SpritePackedManager extends SpriteManager {
  65891. /** defines the packed manager's name */
  65892. name: string;
  65893. /**
  65894. * Creates a new sprite manager from a packed sprite sheet
  65895. * @param name defines the manager's name
  65896. * @param imgUrl defines the sprite sheet url
  65897. * @param capacity defines the maximum allowed number of sprites
  65898. * @param scene defines the hosting scene
  65899. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65900. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65901. * @param samplingMode defines the smapling mode to use with spritesheet
  65902. * @param fromPacked set to true; do not alter
  65903. */
  65904. constructor(
  65905. /** defines the packed manager's name */
  65906. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65907. }
  65908. }
  65909. declare module "babylonjs/Sprites/index" {
  65910. export * from "babylonjs/Sprites/sprite";
  65911. export * from "babylonjs/Sprites/spriteManager";
  65912. export * from "babylonjs/Sprites/spritePackedManager";
  65913. export * from "babylonjs/Sprites/spriteSceneComponent";
  65914. }
  65915. declare module "babylonjs/States/index" {
  65916. export * from "babylonjs/States/alphaCullingState";
  65917. export * from "babylonjs/States/depthCullingState";
  65918. export * from "babylonjs/States/stencilState";
  65919. }
  65920. declare module "babylonjs/Misc/assetsManager" {
  65921. import { Scene } from "babylonjs/scene";
  65922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65923. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65924. import { Skeleton } from "babylonjs/Bones/skeleton";
  65925. import { Observable } from "babylonjs/Misc/observable";
  65926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65927. import { Texture } from "babylonjs/Materials/Textures/texture";
  65928. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65929. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65930. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65931. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65932. /**
  65933. * Defines the list of states available for a task inside a AssetsManager
  65934. */
  65935. export enum AssetTaskState {
  65936. /**
  65937. * Initialization
  65938. */
  65939. INIT = 0,
  65940. /**
  65941. * Running
  65942. */
  65943. RUNNING = 1,
  65944. /**
  65945. * Done
  65946. */
  65947. DONE = 2,
  65948. /**
  65949. * Error
  65950. */
  65951. ERROR = 3
  65952. }
  65953. /**
  65954. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65955. */
  65956. export abstract class AbstractAssetTask {
  65957. /**
  65958. * Task name
  65959. */ name: string;
  65960. /**
  65961. * Callback called when the task is successful
  65962. */
  65963. onSuccess: (task: any) => void;
  65964. /**
  65965. * Callback called when the task is not successful
  65966. */
  65967. onError: (task: any, message?: string, exception?: any) => void;
  65968. /**
  65969. * Creates a new AssetsManager
  65970. * @param name defines the name of the task
  65971. */
  65972. constructor(
  65973. /**
  65974. * Task name
  65975. */ name: string);
  65976. private _isCompleted;
  65977. private _taskState;
  65978. private _errorObject;
  65979. /**
  65980. * Get if the task is completed
  65981. */
  65982. readonly isCompleted: boolean;
  65983. /**
  65984. * Gets the current state of the task
  65985. */
  65986. readonly taskState: AssetTaskState;
  65987. /**
  65988. * Gets the current error object (if task is in error)
  65989. */
  65990. readonly errorObject: {
  65991. message?: string;
  65992. exception?: any;
  65993. };
  65994. /**
  65995. * Internal only
  65996. * @hidden
  65997. */
  65998. _setErrorObject(message?: string, exception?: any): void;
  65999. /**
  66000. * Execute the current task
  66001. * @param scene defines the scene where you want your assets to be loaded
  66002. * @param onSuccess is a callback called when the task is successfully executed
  66003. * @param onError is a callback called if an error occurs
  66004. */
  66005. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66006. /**
  66007. * Execute the current task
  66008. * @param scene defines the scene where you want your assets to be loaded
  66009. * @param onSuccess is a callback called when the task is successfully executed
  66010. * @param onError is a callback called if an error occurs
  66011. */
  66012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66013. /**
  66014. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66015. * This can be used with failed tasks that have the reason for failure fixed.
  66016. */
  66017. reset(): void;
  66018. private onErrorCallback;
  66019. private onDoneCallback;
  66020. }
  66021. /**
  66022. * Define the interface used by progress events raised during assets loading
  66023. */
  66024. export interface IAssetsProgressEvent {
  66025. /**
  66026. * Defines the number of remaining tasks to process
  66027. */
  66028. remainingCount: number;
  66029. /**
  66030. * Defines the total number of tasks
  66031. */
  66032. totalCount: number;
  66033. /**
  66034. * Defines the task that was just processed
  66035. */
  66036. task: AbstractAssetTask;
  66037. }
  66038. /**
  66039. * Class used to share progress information about assets loading
  66040. */
  66041. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66042. /**
  66043. * Defines the number of remaining tasks to process
  66044. */
  66045. remainingCount: number;
  66046. /**
  66047. * Defines the total number of tasks
  66048. */
  66049. totalCount: number;
  66050. /**
  66051. * Defines the task that was just processed
  66052. */
  66053. task: AbstractAssetTask;
  66054. /**
  66055. * Creates a AssetsProgressEvent
  66056. * @param remainingCount defines the number of remaining tasks to process
  66057. * @param totalCount defines the total number of tasks
  66058. * @param task defines the task that was just processed
  66059. */
  66060. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66061. }
  66062. /**
  66063. * Define a task used by AssetsManager to load meshes
  66064. */
  66065. export class MeshAssetTask extends AbstractAssetTask {
  66066. /**
  66067. * Defines the name of the task
  66068. */
  66069. name: string;
  66070. /**
  66071. * Defines the list of mesh's names you want to load
  66072. */
  66073. meshesNames: any;
  66074. /**
  66075. * Defines the root url to use as a base to load your meshes and associated resources
  66076. */
  66077. rootUrl: string;
  66078. /**
  66079. * Defines the filename of the scene to load from
  66080. */
  66081. sceneFilename: string;
  66082. /**
  66083. * Gets the list of loaded meshes
  66084. */
  66085. loadedMeshes: Array<AbstractMesh>;
  66086. /**
  66087. * Gets the list of loaded particle systems
  66088. */
  66089. loadedParticleSystems: Array<IParticleSystem>;
  66090. /**
  66091. * Gets the list of loaded skeletons
  66092. */
  66093. loadedSkeletons: Array<Skeleton>;
  66094. /**
  66095. * Gets the list of loaded animation groups
  66096. */
  66097. loadedAnimationGroups: Array<AnimationGroup>;
  66098. /**
  66099. * Callback called when the task is successful
  66100. */
  66101. onSuccess: (task: MeshAssetTask) => void;
  66102. /**
  66103. * Callback called when the task is successful
  66104. */
  66105. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66106. /**
  66107. * Creates a new MeshAssetTask
  66108. * @param name defines the name of the task
  66109. * @param meshesNames defines the list of mesh's names you want to load
  66110. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66111. * @param sceneFilename defines the filename of the scene to load from
  66112. */
  66113. constructor(
  66114. /**
  66115. * Defines the name of the task
  66116. */
  66117. name: string,
  66118. /**
  66119. * Defines the list of mesh's names you want to load
  66120. */
  66121. meshesNames: any,
  66122. /**
  66123. * Defines the root url to use as a base to load your meshes and associated resources
  66124. */
  66125. rootUrl: string,
  66126. /**
  66127. * Defines the filename of the scene to load from
  66128. */
  66129. sceneFilename: string);
  66130. /**
  66131. * Execute the current task
  66132. * @param scene defines the scene where you want your assets to be loaded
  66133. * @param onSuccess is a callback called when the task is successfully executed
  66134. * @param onError is a callback called if an error occurs
  66135. */
  66136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66137. }
  66138. /**
  66139. * Define a task used by AssetsManager to load text content
  66140. */
  66141. export class TextFileAssetTask extends AbstractAssetTask {
  66142. /**
  66143. * Defines the name of the task
  66144. */
  66145. name: string;
  66146. /**
  66147. * Defines the location of the file to load
  66148. */
  66149. url: string;
  66150. /**
  66151. * Gets the loaded text string
  66152. */
  66153. text: string;
  66154. /**
  66155. * Callback called when the task is successful
  66156. */
  66157. onSuccess: (task: TextFileAssetTask) => void;
  66158. /**
  66159. * Callback called when the task is successful
  66160. */
  66161. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66162. /**
  66163. * Creates a new TextFileAssetTask object
  66164. * @param name defines the name of the task
  66165. * @param url defines the location of the file to load
  66166. */
  66167. constructor(
  66168. /**
  66169. * Defines the name of the task
  66170. */
  66171. name: string,
  66172. /**
  66173. * Defines the location of the file to load
  66174. */
  66175. url: string);
  66176. /**
  66177. * Execute the current task
  66178. * @param scene defines the scene where you want your assets to be loaded
  66179. * @param onSuccess is a callback called when the task is successfully executed
  66180. * @param onError is a callback called if an error occurs
  66181. */
  66182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66183. }
  66184. /**
  66185. * Define a task used by AssetsManager to load binary data
  66186. */
  66187. export class BinaryFileAssetTask extends AbstractAssetTask {
  66188. /**
  66189. * Defines the name of the task
  66190. */
  66191. name: string;
  66192. /**
  66193. * Defines the location of the file to load
  66194. */
  66195. url: string;
  66196. /**
  66197. * Gets the lodaded data (as an array buffer)
  66198. */
  66199. data: ArrayBuffer;
  66200. /**
  66201. * Callback called when the task is successful
  66202. */
  66203. onSuccess: (task: BinaryFileAssetTask) => void;
  66204. /**
  66205. * Callback called when the task is successful
  66206. */
  66207. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66208. /**
  66209. * Creates a new BinaryFileAssetTask object
  66210. * @param name defines the name of the new task
  66211. * @param url defines the location of the file to load
  66212. */
  66213. constructor(
  66214. /**
  66215. * Defines the name of the task
  66216. */
  66217. name: string,
  66218. /**
  66219. * Defines the location of the file to load
  66220. */
  66221. url: string);
  66222. /**
  66223. * Execute the current task
  66224. * @param scene defines the scene where you want your assets to be loaded
  66225. * @param onSuccess is a callback called when the task is successfully executed
  66226. * @param onError is a callback called if an error occurs
  66227. */
  66228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66229. }
  66230. /**
  66231. * Define a task used by AssetsManager to load images
  66232. */
  66233. export class ImageAssetTask extends AbstractAssetTask {
  66234. /**
  66235. * Defines the name of the task
  66236. */
  66237. name: string;
  66238. /**
  66239. * Defines the location of the image to load
  66240. */
  66241. url: string;
  66242. /**
  66243. * Gets the loaded images
  66244. */
  66245. image: HTMLImageElement;
  66246. /**
  66247. * Callback called when the task is successful
  66248. */
  66249. onSuccess: (task: ImageAssetTask) => void;
  66250. /**
  66251. * Callback called when the task is successful
  66252. */
  66253. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66254. /**
  66255. * Creates a new ImageAssetTask
  66256. * @param name defines the name of the task
  66257. * @param url defines the location of the image to load
  66258. */
  66259. constructor(
  66260. /**
  66261. * Defines the name of the task
  66262. */
  66263. name: string,
  66264. /**
  66265. * Defines the location of the image to load
  66266. */
  66267. url: string);
  66268. /**
  66269. * Execute the current task
  66270. * @param scene defines the scene where you want your assets to be loaded
  66271. * @param onSuccess is a callback called when the task is successfully executed
  66272. * @param onError is a callback called if an error occurs
  66273. */
  66274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66275. }
  66276. /**
  66277. * Defines the interface used by texture loading tasks
  66278. */
  66279. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66280. /**
  66281. * Gets the loaded texture
  66282. */
  66283. texture: TEX;
  66284. }
  66285. /**
  66286. * Define a task used by AssetsManager to load 2D textures
  66287. */
  66288. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66289. /**
  66290. * Defines the name of the task
  66291. */
  66292. name: string;
  66293. /**
  66294. * Defines the location of the file to load
  66295. */
  66296. url: string;
  66297. /**
  66298. * Defines if mipmap should not be generated (default is false)
  66299. */
  66300. noMipmap?: boolean | undefined;
  66301. /**
  66302. * Defines if texture must be inverted on Y axis (default is false)
  66303. */
  66304. invertY?: boolean | undefined;
  66305. /**
  66306. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66307. */
  66308. samplingMode: number;
  66309. /**
  66310. * Gets the loaded texture
  66311. */
  66312. texture: Texture;
  66313. /**
  66314. * Callback called when the task is successful
  66315. */
  66316. onSuccess: (task: TextureAssetTask) => void;
  66317. /**
  66318. * Callback called when the task is successful
  66319. */
  66320. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66321. /**
  66322. * Creates a new TextureAssetTask object
  66323. * @param name defines the name of the task
  66324. * @param url defines the location of the file to load
  66325. * @param noMipmap defines if mipmap should not be generated (default is false)
  66326. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66327. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66328. */
  66329. constructor(
  66330. /**
  66331. * Defines the name of the task
  66332. */
  66333. name: string,
  66334. /**
  66335. * Defines the location of the file to load
  66336. */
  66337. url: string,
  66338. /**
  66339. * Defines if mipmap should not be generated (default is false)
  66340. */
  66341. noMipmap?: boolean | undefined,
  66342. /**
  66343. * Defines if texture must be inverted on Y axis (default is false)
  66344. */
  66345. invertY?: boolean | undefined,
  66346. /**
  66347. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66348. */
  66349. samplingMode?: number);
  66350. /**
  66351. * Execute the current task
  66352. * @param scene defines the scene where you want your assets to be loaded
  66353. * @param onSuccess is a callback called when the task is successfully executed
  66354. * @param onError is a callback called if an error occurs
  66355. */
  66356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66357. }
  66358. /**
  66359. * Define a task used by AssetsManager to load cube textures
  66360. */
  66361. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66362. /**
  66363. * Defines the name of the task
  66364. */
  66365. name: string;
  66366. /**
  66367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66368. */
  66369. url: string;
  66370. /**
  66371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66372. */
  66373. extensions?: string[] | undefined;
  66374. /**
  66375. * Defines if mipmaps should not be generated (default is false)
  66376. */
  66377. noMipmap?: boolean | undefined;
  66378. /**
  66379. * Defines the explicit list of files (undefined by default)
  66380. */
  66381. files?: string[] | undefined;
  66382. /**
  66383. * Gets the loaded texture
  66384. */
  66385. texture: CubeTexture;
  66386. /**
  66387. * Callback called when the task is successful
  66388. */
  66389. onSuccess: (task: CubeTextureAssetTask) => void;
  66390. /**
  66391. * Callback called when the task is successful
  66392. */
  66393. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66394. /**
  66395. * Creates a new CubeTextureAssetTask
  66396. * @param name defines the name of the task
  66397. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66398. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66399. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66400. * @param files defines the explicit list of files (undefined by default)
  66401. */
  66402. constructor(
  66403. /**
  66404. * Defines the name of the task
  66405. */
  66406. name: string,
  66407. /**
  66408. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66409. */
  66410. url: string,
  66411. /**
  66412. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66413. */
  66414. extensions?: string[] | undefined,
  66415. /**
  66416. * Defines if mipmaps should not be generated (default is false)
  66417. */
  66418. noMipmap?: boolean | undefined,
  66419. /**
  66420. * Defines the explicit list of files (undefined by default)
  66421. */
  66422. files?: string[] | undefined);
  66423. /**
  66424. * Execute the current task
  66425. * @param scene defines the scene where you want your assets to be loaded
  66426. * @param onSuccess is a callback called when the task is successfully executed
  66427. * @param onError is a callback called if an error occurs
  66428. */
  66429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66430. }
  66431. /**
  66432. * Define a task used by AssetsManager to load HDR cube textures
  66433. */
  66434. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66435. /**
  66436. * Defines the name of the task
  66437. */
  66438. name: string;
  66439. /**
  66440. * Defines the location of the file to load
  66441. */
  66442. url: string;
  66443. /**
  66444. * Defines the desired size (the more it increases the longer the generation will be)
  66445. */
  66446. size: number;
  66447. /**
  66448. * Defines if mipmaps should not be generated (default is false)
  66449. */
  66450. noMipmap: boolean;
  66451. /**
  66452. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66453. */
  66454. generateHarmonics: boolean;
  66455. /**
  66456. * 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)
  66457. */
  66458. gammaSpace: boolean;
  66459. /**
  66460. * Internal Use Only
  66461. */
  66462. reserved: boolean;
  66463. /**
  66464. * Gets the loaded texture
  66465. */
  66466. texture: HDRCubeTexture;
  66467. /**
  66468. * Callback called when the task is successful
  66469. */
  66470. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66471. /**
  66472. * Callback called when the task is successful
  66473. */
  66474. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66475. /**
  66476. * Creates a new HDRCubeTextureAssetTask object
  66477. * @param name defines the name of the task
  66478. * @param url defines the location of the file to load
  66479. * @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.
  66480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66481. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66482. * @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)
  66483. * @param reserved Internal use only
  66484. */
  66485. constructor(
  66486. /**
  66487. * Defines the name of the task
  66488. */
  66489. name: string,
  66490. /**
  66491. * Defines the location of the file to load
  66492. */
  66493. url: string,
  66494. /**
  66495. * Defines the desired size (the more it increases the longer the generation will be)
  66496. */
  66497. size: number,
  66498. /**
  66499. * Defines if mipmaps should not be generated (default is false)
  66500. */
  66501. noMipmap?: boolean,
  66502. /**
  66503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66504. */
  66505. generateHarmonics?: boolean,
  66506. /**
  66507. * 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)
  66508. */
  66509. gammaSpace?: boolean,
  66510. /**
  66511. * Internal Use Only
  66512. */
  66513. reserved?: boolean);
  66514. /**
  66515. * Execute the current task
  66516. * @param scene defines the scene where you want your assets to be loaded
  66517. * @param onSuccess is a callback called when the task is successfully executed
  66518. * @param onError is a callback called if an error occurs
  66519. */
  66520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66521. }
  66522. /**
  66523. * Define a task used by AssetsManager to load Equirectangular cube textures
  66524. */
  66525. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66526. /**
  66527. * Defines the name of the task
  66528. */
  66529. name: string;
  66530. /**
  66531. * Defines the location of the file to load
  66532. */
  66533. url: string;
  66534. /**
  66535. * Defines the desired size (the more it increases the longer the generation will be)
  66536. */
  66537. size: number;
  66538. /**
  66539. * Defines if mipmaps should not be generated (default is false)
  66540. */
  66541. noMipmap: boolean;
  66542. /**
  66543. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66544. * but the standard material would require them in Gamma space) (default is true)
  66545. */
  66546. gammaSpace: boolean;
  66547. /**
  66548. * Gets the loaded texture
  66549. */
  66550. texture: EquiRectangularCubeTexture;
  66551. /**
  66552. * Callback called when the task is successful
  66553. */
  66554. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66555. /**
  66556. * Callback called when the task is successful
  66557. */
  66558. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66559. /**
  66560. * Creates a new EquiRectangularCubeTextureAssetTask object
  66561. * @param name defines the name of the task
  66562. * @param url defines the location of the file to load
  66563. * @param size defines the desired size (the more it increases the longer the generation will be)
  66564. * If the size is omitted this implies you are using a preprocessed cubemap.
  66565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66566. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66567. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66568. * (default is true)
  66569. */
  66570. constructor(
  66571. /**
  66572. * Defines the name of the task
  66573. */
  66574. name: string,
  66575. /**
  66576. * Defines the location of the file to load
  66577. */
  66578. url: string,
  66579. /**
  66580. * Defines the desired size (the more it increases the longer the generation will be)
  66581. */
  66582. size: number,
  66583. /**
  66584. * Defines if mipmaps should not be generated (default is false)
  66585. */
  66586. noMipmap?: boolean,
  66587. /**
  66588. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66589. * but the standard material would require them in Gamma space) (default is true)
  66590. */
  66591. gammaSpace?: boolean);
  66592. /**
  66593. * Execute the current task
  66594. * @param scene defines the scene where you want your assets to be loaded
  66595. * @param onSuccess is a callback called when the task is successfully executed
  66596. * @param onError is a callback called if an error occurs
  66597. */
  66598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66599. }
  66600. /**
  66601. * This class can be used to easily import assets into a scene
  66602. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66603. */
  66604. export class AssetsManager {
  66605. private _scene;
  66606. private _isLoading;
  66607. protected _tasks: AbstractAssetTask[];
  66608. protected _waitingTasksCount: number;
  66609. protected _totalTasksCount: number;
  66610. /**
  66611. * Callback called when all tasks are processed
  66612. */
  66613. onFinish: (tasks: AbstractAssetTask[]) => void;
  66614. /**
  66615. * Callback called when a task is successful
  66616. */
  66617. onTaskSuccess: (task: AbstractAssetTask) => void;
  66618. /**
  66619. * Callback called when a task had an error
  66620. */
  66621. onTaskError: (task: AbstractAssetTask) => void;
  66622. /**
  66623. * Callback called when a task is done (whatever the result is)
  66624. */
  66625. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66626. /**
  66627. * Observable called when all tasks are processed
  66628. */
  66629. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66630. /**
  66631. * Observable called when a task had an error
  66632. */
  66633. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66634. /**
  66635. * Observable called when all tasks were executed
  66636. */
  66637. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66638. /**
  66639. * Observable called when a task is done (whatever the result is)
  66640. */
  66641. onProgressObservable: Observable<IAssetsProgressEvent>;
  66642. /**
  66643. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66645. */
  66646. useDefaultLoadingScreen: boolean;
  66647. /**
  66648. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66649. * when all assets have been downloaded.
  66650. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66651. */
  66652. autoHideLoadingUI: boolean;
  66653. /**
  66654. * Creates a new AssetsManager
  66655. * @param scene defines the scene to work on
  66656. */
  66657. constructor(scene: Scene);
  66658. /**
  66659. * Add a MeshAssetTask to the list of active tasks
  66660. * @param taskName defines the name of the new task
  66661. * @param meshesNames defines the name of meshes to load
  66662. * @param rootUrl defines the root url to use to locate files
  66663. * @param sceneFilename defines the filename of the scene file
  66664. * @returns a new MeshAssetTask object
  66665. */
  66666. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66667. /**
  66668. * Add a TextFileAssetTask to the list of active tasks
  66669. * @param taskName defines the name of the new task
  66670. * @param url defines the url of the file to load
  66671. * @returns a new TextFileAssetTask object
  66672. */
  66673. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66674. /**
  66675. * Add a BinaryFileAssetTask to the list of active tasks
  66676. * @param taskName defines the name of the new task
  66677. * @param url defines the url of the file to load
  66678. * @returns a new BinaryFileAssetTask object
  66679. */
  66680. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66681. /**
  66682. * Add a ImageAssetTask to the list of active tasks
  66683. * @param taskName defines the name of the new task
  66684. * @param url defines the url of the file to load
  66685. * @returns a new ImageAssetTask object
  66686. */
  66687. addImageTask(taskName: string, url: string): ImageAssetTask;
  66688. /**
  66689. * Add a TextureAssetTask to the list of active tasks
  66690. * @param taskName defines the name of the new task
  66691. * @param url defines the url of the file to load
  66692. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66693. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66694. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66695. * @returns a new TextureAssetTask object
  66696. */
  66697. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66698. /**
  66699. * Add a CubeTextureAssetTask to the list of active tasks
  66700. * @param taskName defines the name of the new task
  66701. * @param url defines the url of the file to load
  66702. * @param extensions defines the extension to use to load the cube map (can be null)
  66703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66704. * @param files defines the list of files to load (can be null)
  66705. * @returns a new CubeTextureAssetTask object
  66706. */
  66707. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66708. /**
  66709. *
  66710. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66711. * @param taskName defines the name of the new task
  66712. * @param url defines the url of the file to load
  66713. * @param size defines the size you want for the cubemap (can be null)
  66714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66715. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66716. * @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)
  66717. * @param reserved Internal use only
  66718. * @returns a new HDRCubeTextureAssetTask object
  66719. */
  66720. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66721. /**
  66722. *
  66723. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66724. * @param taskName defines the name of the new task
  66725. * @param url defines the url of the file to load
  66726. * @param size defines the size you want for the cubemap (can be null)
  66727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66728. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66729. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66730. * @returns a new EquiRectangularCubeTextureAssetTask object
  66731. */
  66732. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66733. /**
  66734. * Remove a task from the assets manager.
  66735. * @param task the task to remove
  66736. */
  66737. removeTask(task: AbstractAssetTask): void;
  66738. private _decreaseWaitingTasksCount;
  66739. private _runTask;
  66740. /**
  66741. * Reset the AssetsManager and remove all tasks
  66742. * @return the current instance of the AssetsManager
  66743. */
  66744. reset(): AssetsManager;
  66745. /**
  66746. * Start the loading process
  66747. * @return the current instance of the AssetsManager
  66748. */
  66749. load(): AssetsManager;
  66750. /**
  66751. * Start the loading process as an async operation
  66752. * @return a promise returning the list of failed tasks
  66753. */
  66754. loadAsync(): Promise<void>;
  66755. }
  66756. }
  66757. declare module "babylonjs/Misc/deferred" {
  66758. /**
  66759. * Wrapper class for promise with external resolve and reject.
  66760. */
  66761. export class Deferred<T> {
  66762. /**
  66763. * The promise associated with this deferred object.
  66764. */
  66765. readonly promise: Promise<T>;
  66766. private _resolve;
  66767. private _reject;
  66768. /**
  66769. * The resolve method of the promise associated with this deferred object.
  66770. */
  66771. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66772. /**
  66773. * The reject method of the promise associated with this deferred object.
  66774. */
  66775. readonly reject: (reason?: any) => void;
  66776. /**
  66777. * Constructor for this deferred object.
  66778. */
  66779. constructor();
  66780. }
  66781. }
  66782. declare module "babylonjs/Misc/meshExploder" {
  66783. import { Mesh } from "babylonjs/Meshes/mesh";
  66784. /**
  66785. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66786. */
  66787. export class MeshExploder {
  66788. private _centerMesh;
  66789. private _meshes;
  66790. private _meshesOrigins;
  66791. private _toCenterVectors;
  66792. private _scaledDirection;
  66793. private _newPosition;
  66794. private _centerPosition;
  66795. /**
  66796. * Explodes meshes from a center mesh.
  66797. * @param meshes The meshes to explode.
  66798. * @param centerMesh The mesh to be center of explosion.
  66799. */
  66800. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66801. private _setCenterMesh;
  66802. /**
  66803. * Get class name
  66804. * @returns "MeshExploder"
  66805. */
  66806. getClassName(): string;
  66807. /**
  66808. * "Exploded meshes"
  66809. * @returns Array of meshes with the centerMesh at index 0.
  66810. */
  66811. getMeshes(): Array<Mesh>;
  66812. /**
  66813. * Explodes meshes giving a specific direction
  66814. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66815. */
  66816. explode(direction?: number): void;
  66817. }
  66818. }
  66819. declare module "babylonjs/Misc/filesInput" {
  66820. import { Engine } from "babylonjs/Engines/engine";
  66821. import { Scene } from "babylonjs/scene";
  66822. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66823. /**
  66824. * Class used to help managing file picking and drag'n'drop
  66825. */
  66826. export class FilesInput {
  66827. /**
  66828. * List of files ready to be loaded
  66829. */
  66830. static readonly FilesToLoad: {
  66831. [key: string]: File;
  66832. };
  66833. /**
  66834. * Callback called when a file is processed
  66835. */
  66836. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66837. private _engine;
  66838. private _currentScene;
  66839. private _sceneLoadedCallback;
  66840. private _progressCallback;
  66841. private _additionalRenderLoopLogicCallback;
  66842. private _textureLoadingCallback;
  66843. private _startingProcessingFilesCallback;
  66844. private _onReloadCallback;
  66845. private _errorCallback;
  66846. private _elementToMonitor;
  66847. private _sceneFileToLoad;
  66848. private _filesToLoad;
  66849. /**
  66850. * Creates a new FilesInput
  66851. * @param engine defines the rendering engine
  66852. * @param scene defines the hosting scene
  66853. * @param sceneLoadedCallback callback called when scene is loaded
  66854. * @param progressCallback callback called to track progress
  66855. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66856. * @param textureLoadingCallback callback called when a texture is loading
  66857. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66858. * @param onReloadCallback callback called when a reload is requested
  66859. * @param errorCallback callback call if an error occurs
  66860. */
  66861. 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);
  66862. private _dragEnterHandler;
  66863. private _dragOverHandler;
  66864. private _dropHandler;
  66865. /**
  66866. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66867. * @param elementToMonitor defines the DOM element to track
  66868. */
  66869. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66870. /**
  66871. * Release all associated resources
  66872. */
  66873. dispose(): void;
  66874. private renderFunction;
  66875. private drag;
  66876. private drop;
  66877. private _traverseFolder;
  66878. private _processFiles;
  66879. /**
  66880. * Load files from a drop event
  66881. * @param event defines the drop event to use as source
  66882. */
  66883. loadFiles(event: any): void;
  66884. private _processReload;
  66885. /**
  66886. * Reload the current scene from the loaded files
  66887. */
  66888. reload(): void;
  66889. }
  66890. }
  66891. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66892. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66893. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66894. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66895. }
  66896. declare module "babylonjs/Misc/sceneOptimizer" {
  66897. import { Scene, IDisposable } from "babylonjs/scene";
  66898. import { Observable } from "babylonjs/Misc/observable";
  66899. /**
  66900. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66902. */
  66903. export class SceneOptimization {
  66904. /**
  66905. * Defines the priority of this optimization (0 by default which means first in the list)
  66906. */
  66907. priority: number;
  66908. /**
  66909. * Gets a string describing the action executed by the current optimization
  66910. * @returns description string
  66911. */
  66912. getDescription(): string;
  66913. /**
  66914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66915. * @param scene defines the current scene where to apply this optimization
  66916. * @param optimizer defines the current optimizer
  66917. * @returns true if everything that can be done was applied
  66918. */
  66919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66920. /**
  66921. * Creates the SceneOptimization object
  66922. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66923. * @param desc defines the description associated with the optimization
  66924. */
  66925. constructor(
  66926. /**
  66927. * Defines the priority of this optimization (0 by default which means first in the list)
  66928. */
  66929. priority?: number);
  66930. }
  66931. /**
  66932. * Defines an optimization used to reduce the size of render target textures
  66933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66934. */
  66935. export class TextureOptimization extends SceneOptimization {
  66936. /**
  66937. * Defines the priority of this optimization (0 by default which means first in the list)
  66938. */
  66939. priority: number;
  66940. /**
  66941. * 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
  66942. */
  66943. maximumSize: number;
  66944. /**
  66945. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66946. */
  66947. step: number;
  66948. /**
  66949. * Gets a string describing the action executed by the current optimization
  66950. * @returns description string
  66951. */
  66952. getDescription(): string;
  66953. /**
  66954. * Creates the TextureOptimization object
  66955. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66956. * @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
  66957. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66958. */
  66959. constructor(
  66960. /**
  66961. * Defines the priority of this optimization (0 by default which means first in the list)
  66962. */
  66963. priority?: number,
  66964. /**
  66965. * 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
  66966. */
  66967. maximumSize?: number,
  66968. /**
  66969. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66970. */
  66971. step?: number);
  66972. /**
  66973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66974. * @param scene defines the current scene where to apply this optimization
  66975. * @param optimizer defines the current optimizer
  66976. * @returns true if everything that can be done was applied
  66977. */
  66978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66979. }
  66980. /**
  66981. * Defines an optimization used to increase or decrease the rendering resolution
  66982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66983. */
  66984. export class HardwareScalingOptimization extends SceneOptimization {
  66985. /**
  66986. * Defines the priority of this optimization (0 by default which means first in the list)
  66987. */
  66988. priority: number;
  66989. /**
  66990. * Defines the maximum scale to use (2 by default)
  66991. */
  66992. maximumScale: number;
  66993. /**
  66994. * Defines the step to use between two passes (0.5 by default)
  66995. */
  66996. step: number;
  66997. private _currentScale;
  66998. private _directionOffset;
  66999. /**
  67000. * Gets a string describing the action executed by the current optimization
  67001. * @return description string
  67002. */
  67003. getDescription(): string;
  67004. /**
  67005. * Creates the HardwareScalingOptimization object
  67006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67007. * @param maximumScale defines the maximum scale to use (2 by default)
  67008. * @param step defines the step to use between two passes (0.5 by default)
  67009. */
  67010. constructor(
  67011. /**
  67012. * Defines the priority of this optimization (0 by default which means first in the list)
  67013. */
  67014. priority?: number,
  67015. /**
  67016. * Defines the maximum scale to use (2 by default)
  67017. */
  67018. maximumScale?: number,
  67019. /**
  67020. * Defines the step to use between two passes (0.5 by default)
  67021. */
  67022. step?: number);
  67023. /**
  67024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67025. * @param scene defines the current scene where to apply this optimization
  67026. * @param optimizer defines the current optimizer
  67027. * @returns true if everything that can be done was applied
  67028. */
  67029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67030. }
  67031. /**
  67032. * Defines an optimization used to remove shadows
  67033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67034. */
  67035. export class ShadowsOptimization extends SceneOptimization {
  67036. /**
  67037. * Gets a string describing the action executed by the current optimization
  67038. * @return description string
  67039. */
  67040. getDescription(): string;
  67041. /**
  67042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67043. * @param scene defines the current scene where to apply this optimization
  67044. * @param optimizer defines the current optimizer
  67045. * @returns true if everything that can be done was applied
  67046. */
  67047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67048. }
  67049. /**
  67050. * Defines an optimization used to turn post-processes off
  67051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67052. */
  67053. export class PostProcessesOptimization extends SceneOptimization {
  67054. /**
  67055. * Gets a string describing the action executed by the current optimization
  67056. * @return description string
  67057. */
  67058. getDescription(): string;
  67059. /**
  67060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67061. * @param scene defines the current scene where to apply this optimization
  67062. * @param optimizer defines the current optimizer
  67063. * @returns true if everything that can be done was applied
  67064. */
  67065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67066. }
  67067. /**
  67068. * Defines an optimization used to turn lens flares off
  67069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67070. */
  67071. export class LensFlaresOptimization extends SceneOptimization {
  67072. /**
  67073. * Gets a string describing the action executed by the current optimization
  67074. * @return description string
  67075. */
  67076. getDescription(): string;
  67077. /**
  67078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67079. * @param scene defines the current scene where to apply this optimization
  67080. * @param optimizer defines the current optimizer
  67081. * @returns true if everything that can be done was applied
  67082. */
  67083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67084. }
  67085. /**
  67086. * Defines an optimization based on user defined callback.
  67087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67088. */
  67089. export class CustomOptimization extends SceneOptimization {
  67090. /**
  67091. * Callback called to apply the custom optimization.
  67092. */
  67093. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67094. /**
  67095. * Callback called to get custom description
  67096. */
  67097. onGetDescription: () => string;
  67098. /**
  67099. * Gets a string describing the action executed by the current optimization
  67100. * @returns description string
  67101. */
  67102. getDescription(): string;
  67103. /**
  67104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67105. * @param scene defines the current scene where to apply this optimization
  67106. * @param optimizer defines the current optimizer
  67107. * @returns true if everything that can be done was applied
  67108. */
  67109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67110. }
  67111. /**
  67112. * Defines an optimization used to turn particles off
  67113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67114. */
  67115. export class ParticlesOptimization extends SceneOptimization {
  67116. /**
  67117. * Gets a string describing the action executed by the current optimization
  67118. * @return description string
  67119. */
  67120. getDescription(): string;
  67121. /**
  67122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67123. * @param scene defines the current scene where to apply this optimization
  67124. * @param optimizer defines the current optimizer
  67125. * @returns true if everything that can be done was applied
  67126. */
  67127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67128. }
  67129. /**
  67130. * Defines an optimization used to turn render targets off
  67131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67132. */
  67133. export class RenderTargetsOptimization extends SceneOptimization {
  67134. /**
  67135. * Gets a string describing the action executed by the current optimization
  67136. * @return description string
  67137. */
  67138. getDescription(): string;
  67139. /**
  67140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67141. * @param scene defines the current scene where to apply this optimization
  67142. * @param optimizer defines the current optimizer
  67143. * @returns true if everything that can be done was applied
  67144. */
  67145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67146. }
  67147. /**
  67148. * Defines an optimization used to merge meshes with compatible materials
  67149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67150. */
  67151. export class MergeMeshesOptimization extends SceneOptimization {
  67152. private static _UpdateSelectionTree;
  67153. /**
  67154. * Gets or sets a boolean which defines if optimization octree has to be updated
  67155. */
  67156. /**
  67157. * Gets or sets a boolean which defines if optimization octree has to be updated
  67158. */
  67159. static UpdateSelectionTree: boolean;
  67160. /**
  67161. * Gets a string describing the action executed by the current optimization
  67162. * @return description string
  67163. */
  67164. getDescription(): string;
  67165. private _canBeMerged;
  67166. /**
  67167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67168. * @param scene defines the current scene where to apply this optimization
  67169. * @param optimizer defines the current optimizer
  67170. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67171. * @returns true if everything that can be done was applied
  67172. */
  67173. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67174. }
  67175. /**
  67176. * Defines a list of options used by SceneOptimizer
  67177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67178. */
  67179. export class SceneOptimizerOptions {
  67180. /**
  67181. * Defines the target frame rate to reach (60 by default)
  67182. */
  67183. targetFrameRate: number;
  67184. /**
  67185. * Defines the interval between two checkes (2000ms by default)
  67186. */
  67187. trackerDuration: number;
  67188. /**
  67189. * Gets the list of optimizations to apply
  67190. */
  67191. optimizations: SceneOptimization[];
  67192. /**
  67193. * Creates a new list of options used by SceneOptimizer
  67194. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67195. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67196. */
  67197. constructor(
  67198. /**
  67199. * Defines the target frame rate to reach (60 by default)
  67200. */
  67201. targetFrameRate?: number,
  67202. /**
  67203. * Defines the interval between two checkes (2000ms by default)
  67204. */
  67205. trackerDuration?: number);
  67206. /**
  67207. * Add a new optimization
  67208. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67209. * @returns the current SceneOptimizerOptions
  67210. */
  67211. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67212. /**
  67213. * Add a new custom optimization
  67214. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67215. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67217. * @returns the current SceneOptimizerOptions
  67218. */
  67219. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67220. /**
  67221. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67222. * @param targetFrameRate defines the target frame rate (60 by default)
  67223. * @returns a SceneOptimizerOptions object
  67224. */
  67225. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67226. /**
  67227. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67228. * @param targetFrameRate defines the target frame rate (60 by default)
  67229. * @returns a SceneOptimizerOptions object
  67230. */
  67231. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67232. /**
  67233. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67234. * @param targetFrameRate defines the target frame rate (60 by default)
  67235. * @returns a SceneOptimizerOptions object
  67236. */
  67237. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67238. }
  67239. /**
  67240. * Class used to run optimizations in order to reach a target frame rate
  67241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67242. */
  67243. export class SceneOptimizer implements IDisposable {
  67244. private _isRunning;
  67245. private _options;
  67246. private _scene;
  67247. private _currentPriorityLevel;
  67248. private _targetFrameRate;
  67249. private _trackerDuration;
  67250. private _currentFrameRate;
  67251. private _sceneDisposeObserver;
  67252. private _improvementMode;
  67253. /**
  67254. * Defines an observable called when the optimizer reaches the target frame rate
  67255. */
  67256. onSuccessObservable: Observable<SceneOptimizer>;
  67257. /**
  67258. * Defines an observable called when the optimizer enables an optimization
  67259. */
  67260. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67261. /**
  67262. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67263. */
  67264. onFailureObservable: Observable<SceneOptimizer>;
  67265. /**
  67266. * Gets a boolean indicating if the optimizer is in improvement mode
  67267. */
  67268. readonly isInImprovementMode: boolean;
  67269. /**
  67270. * Gets the current priority level (0 at start)
  67271. */
  67272. readonly currentPriorityLevel: number;
  67273. /**
  67274. * Gets the current frame rate checked by the SceneOptimizer
  67275. */
  67276. readonly currentFrameRate: number;
  67277. /**
  67278. * Gets or sets the current target frame rate (60 by default)
  67279. */
  67280. /**
  67281. * Gets or sets the current target frame rate (60 by default)
  67282. */
  67283. targetFrameRate: number;
  67284. /**
  67285. * Gets or sets the current interval between two checks (every 2000ms by default)
  67286. */
  67287. /**
  67288. * Gets or sets the current interval between two checks (every 2000ms by default)
  67289. */
  67290. trackerDuration: number;
  67291. /**
  67292. * Gets the list of active optimizations
  67293. */
  67294. readonly optimizations: SceneOptimization[];
  67295. /**
  67296. * Creates a new SceneOptimizer
  67297. * @param scene defines the scene to work on
  67298. * @param options defines the options to use with the SceneOptimizer
  67299. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67300. * @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)
  67301. */
  67302. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67303. /**
  67304. * Stops the current optimizer
  67305. */
  67306. stop(): void;
  67307. /**
  67308. * Reset the optimizer to initial step (current priority level = 0)
  67309. */
  67310. reset(): void;
  67311. /**
  67312. * Start the optimizer. By default it will try to reach a specific framerate
  67313. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67314. */
  67315. start(): void;
  67316. private _checkCurrentState;
  67317. /**
  67318. * Release all resources
  67319. */
  67320. dispose(): void;
  67321. /**
  67322. * Helper function to create a SceneOptimizer with one single line of code
  67323. * @param scene defines the scene to work on
  67324. * @param options defines the options to use with the SceneOptimizer
  67325. * @param onSuccess defines a callback to call on success
  67326. * @param onFailure defines a callback to call on failure
  67327. * @returns the new SceneOptimizer object
  67328. */
  67329. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67330. }
  67331. }
  67332. declare module "babylonjs/Misc/sceneSerializer" {
  67333. import { Scene } from "babylonjs/scene";
  67334. /**
  67335. * Class used to serialize a scene into a string
  67336. */
  67337. export class SceneSerializer {
  67338. /**
  67339. * Clear cache used by a previous serialization
  67340. */
  67341. static ClearCache(): void;
  67342. /**
  67343. * Serialize a scene into a JSON compatible object
  67344. * @param scene defines the scene to serialize
  67345. * @returns a JSON compatible object
  67346. */
  67347. static Serialize(scene: Scene): any;
  67348. /**
  67349. * Serialize a mesh into a JSON compatible object
  67350. * @param toSerialize defines the mesh to serialize
  67351. * @param withParents defines if parents must be serialized as well
  67352. * @param withChildren defines if children must be serialized as well
  67353. * @returns a JSON compatible object
  67354. */
  67355. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67356. }
  67357. }
  67358. declare module "babylonjs/Misc/textureTools" {
  67359. import { Texture } from "babylonjs/Materials/Textures/texture";
  67360. /**
  67361. * Class used to host texture specific utilities
  67362. */
  67363. export class TextureTools {
  67364. /**
  67365. * Uses the GPU to create a copy texture rescaled at a given size
  67366. * @param texture Texture to copy from
  67367. * @param width defines the desired width
  67368. * @param height defines the desired height
  67369. * @param useBilinearMode defines if bilinear mode has to be used
  67370. * @return the generated texture
  67371. */
  67372. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67373. }
  67374. }
  67375. declare module "babylonjs/Misc/videoRecorder" {
  67376. import { Nullable } from "babylonjs/types";
  67377. import { Engine } from "babylonjs/Engines/engine";
  67378. /**
  67379. * This represents the different options available for the video capture.
  67380. */
  67381. export interface VideoRecorderOptions {
  67382. /** Defines the mime type of the video. */
  67383. mimeType: string;
  67384. /** Defines the FPS the video should be recorded at. */
  67385. fps: number;
  67386. /** Defines the chunk size for the recording data. */
  67387. recordChunckSize: number;
  67388. /** The audio tracks to attach to the recording. */
  67389. audioTracks?: MediaStreamTrack[];
  67390. }
  67391. /**
  67392. * This can help with recording videos from BabylonJS.
  67393. * This is based on the available WebRTC functionalities of the browser.
  67394. *
  67395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67396. */
  67397. export class VideoRecorder {
  67398. private static readonly _defaultOptions;
  67399. /**
  67400. * Returns whether or not the VideoRecorder is available in your browser.
  67401. * @param engine Defines the Babylon Engine.
  67402. * @returns true if supported otherwise false.
  67403. */
  67404. static IsSupported(engine: Engine): boolean;
  67405. private readonly _options;
  67406. private _canvas;
  67407. private _mediaRecorder;
  67408. private _recordedChunks;
  67409. private _fileName;
  67410. private _resolve;
  67411. private _reject;
  67412. /**
  67413. * True when a recording is already in progress.
  67414. */
  67415. readonly isRecording: boolean;
  67416. /**
  67417. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67418. * @param engine Defines the BabylonJS Engine you wish to record.
  67419. * @param options Defines options that can be used to customize the capture.
  67420. */
  67421. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67422. /**
  67423. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67424. */
  67425. stopRecording(): void;
  67426. /**
  67427. * Starts recording the canvas for a max duration specified in parameters.
  67428. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67429. * If null no automatic download will start and you can rely on the promise to get the data back.
  67430. * @param maxDuration Defines the maximum recording time in seconds.
  67431. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67432. * @return A promise callback at the end of the recording with the video data in Blob.
  67433. */
  67434. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67435. /**
  67436. * Releases internal resources used during the recording.
  67437. */
  67438. dispose(): void;
  67439. private _handleDataAvailable;
  67440. private _handleError;
  67441. private _handleStop;
  67442. }
  67443. }
  67444. declare module "babylonjs/Misc/screenshotTools" {
  67445. import { Camera } from "babylonjs/Cameras/camera";
  67446. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67447. import { Engine } from "babylonjs/Engines/engine";
  67448. /**
  67449. * Class containing a set of static utilities functions for screenshots
  67450. */
  67451. export class ScreenshotTools {
  67452. /**
  67453. * Captures a screenshot of the current rendering
  67454. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67455. * @param engine defines the rendering engine
  67456. * @param camera defines the source camera
  67457. * @param size This parameter can be set to a single number or to an object with the
  67458. * following (optional) properties: precision, width, height. If a single number is passed,
  67459. * it will be used for both width and height. If an object is passed, the screenshot size
  67460. * will be derived from the parameters. The precision property is a multiplier allowing
  67461. * rendering at a higher or lower resolution
  67462. * @param successCallback defines the callback receives a single parameter which contains the
  67463. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67464. * src parameter of an <img> to display it
  67465. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67466. * Check your browser for supported MIME types
  67467. */
  67468. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67469. /**
  67470. * Captures a screenshot of the current rendering
  67471. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67472. * @param engine defines the rendering engine
  67473. * @param camera defines the source camera
  67474. * @param size This parameter can be set to a single number or to an object with the
  67475. * following (optional) properties: precision, width, height. If a single number is passed,
  67476. * it will be used for both width and height. If an object is passed, the screenshot size
  67477. * will be derived from the parameters. The precision property is a multiplier allowing
  67478. * rendering at a higher or lower resolution
  67479. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67480. * Check your browser for supported MIME types
  67481. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67482. * to the src parameter of an <img> to display it
  67483. */
  67484. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67485. /**
  67486. * Generates an image screenshot from the specified camera.
  67487. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67488. * @param engine The engine to use for rendering
  67489. * @param camera The camera to use for rendering
  67490. * @param size This parameter can be set to a single number or to an object with the
  67491. * following (optional) properties: precision, width, height. If a single number is passed,
  67492. * it will be used for both width and height. If an object is passed, the screenshot size
  67493. * will be derived from the parameters. The precision property is a multiplier allowing
  67494. * rendering at a higher or lower resolution
  67495. * @param successCallback The callback receives a single parameter which contains the
  67496. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67497. * src parameter of an <img> to display it
  67498. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67499. * Check your browser for supported MIME types
  67500. * @param samples Texture samples (default: 1)
  67501. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67502. * @param fileName A name for for the downloaded file.
  67503. */
  67504. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67505. /**
  67506. * Generates an image screenshot from the specified camera.
  67507. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67508. * @param engine The engine to use for rendering
  67509. * @param camera The camera to use for rendering
  67510. * @param size This parameter can be set to a single number or to an object with the
  67511. * following (optional) properties: precision, width, height. If a single number is passed,
  67512. * it will be used for both width and height. If an object is passed, the screenshot size
  67513. * will be derived from the parameters. The precision property is a multiplier allowing
  67514. * rendering at a higher or lower resolution
  67515. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67516. * Check your browser for supported MIME types
  67517. * @param samples Texture samples (default: 1)
  67518. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67519. * @param fileName A name for for the downloaded file.
  67520. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67521. * to the src parameter of an <img> to display it
  67522. */
  67523. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67524. /**
  67525. * Gets height and width for screenshot size
  67526. * @private
  67527. */
  67528. private static _getScreenshotSize;
  67529. }
  67530. }
  67531. declare module "babylonjs/Misc/dataReader" {
  67532. /**
  67533. * Interface for a data buffer
  67534. */
  67535. export interface IDataBuffer {
  67536. /**
  67537. * Reads bytes from the data buffer.
  67538. * @param byteOffset The byte offset to read
  67539. * @param byteLength The byte length to read
  67540. * @returns A promise that resolves when the bytes are read
  67541. */
  67542. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67543. /**
  67544. * The byte length of the buffer.
  67545. */
  67546. readonly byteLength: number;
  67547. }
  67548. /**
  67549. * Utility class for reading from a data buffer
  67550. */
  67551. export class DataReader {
  67552. /**
  67553. * The data buffer associated with this data reader.
  67554. */
  67555. readonly buffer: IDataBuffer;
  67556. /**
  67557. * The current byte offset from the beginning of the data buffer.
  67558. */
  67559. byteOffset: number;
  67560. private _dataView;
  67561. private _dataByteOffset;
  67562. /**
  67563. * Constructor
  67564. * @param buffer The buffer to read
  67565. */
  67566. constructor(buffer: IDataBuffer);
  67567. /**
  67568. * Loads the given byte length.
  67569. * @param byteLength The byte length to load
  67570. * @returns A promise that resolves when the load is complete
  67571. */
  67572. loadAsync(byteLength: number): Promise<void>;
  67573. /**
  67574. * Read a unsigned 32-bit integer from the currently loaded data range.
  67575. * @returns The 32-bit integer read
  67576. */
  67577. readUint32(): number;
  67578. /**
  67579. * Read a byte array from the currently loaded data range.
  67580. * @param byteLength The byte length to read
  67581. * @returns The byte array read
  67582. */
  67583. readUint8Array(byteLength: number): Uint8Array;
  67584. /**
  67585. * Read a string from the currently loaded data range.
  67586. * @param byteLength The byte length to read
  67587. * @returns The string read
  67588. */
  67589. readString(byteLength: number): string;
  67590. /**
  67591. * Skips the given byte length the currently loaded data range.
  67592. * @param byteLength The byte length to skip
  67593. */
  67594. skipBytes(byteLength: number): void;
  67595. }
  67596. }
  67597. declare module "babylonjs/Misc/index" {
  67598. export * from "babylonjs/Misc/andOrNotEvaluator";
  67599. export * from "babylonjs/Misc/assetsManager";
  67600. export * from "babylonjs/Misc/dds";
  67601. export * from "babylonjs/Misc/decorators";
  67602. export * from "babylonjs/Misc/deferred";
  67603. export * from "babylonjs/Misc/environmentTextureTools";
  67604. export * from "babylonjs/Misc/meshExploder";
  67605. export * from "babylonjs/Misc/filesInput";
  67606. export * from "babylonjs/Misc/HighDynamicRange/index";
  67607. export * from "babylonjs/Misc/khronosTextureContainer";
  67608. export * from "babylonjs/Misc/observable";
  67609. export * from "babylonjs/Misc/performanceMonitor";
  67610. export * from "babylonjs/Misc/promise";
  67611. export * from "babylonjs/Misc/sceneOptimizer";
  67612. export * from "babylonjs/Misc/sceneSerializer";
  67613. export * from "babylonjs/Misc/smartArray";
  67614. export * from "babylonjs/Misc/stringDictionary";
  67615. export * from "babylonjs/Misc/tags";
  67616. export * from "babylonjs/Misc/textureTools";
  67617. export * from "babylonjs/Misc/tga";
  67618. export * from "babylonjs/Misc/tools";
  67619. export * from "babylonjs/Misc/videoRecorder";
  67620. export * from "babylonjs/Misc/virtualJoystick";
  67621. export * from "babylonjs/Misc/workerPool";
  67622. export * from "babylonjs/Misc/logger";
  67623. export * from "babylonjs/Misc/typeStore";
  67624. export * from "babylonjs/Misc/filesInputStore";
  67625. export * from "babylonjs/Misc/deepCopier";
  67626. export * from "babylonjs/Misc/pivotTools";
  67627. export * from "babylonjs/Misc/precisionDate";
  67628. export * from "babylonjs/Misc/screenshotTools";
  67629. export * from "babylonjs/Misc/typeStore";
  67630. export * from "babylonjs/Misc/webRequest";
  67631. export * from "babylonjs/Misc/iInspectable";
  67632. export * from "babylonjs/Misc/brdfTextureTools";
  67633. export * from "babylonjs/Misc/rgbdTextureTools";
  67634. export * from "babylonjs/Misc/gradients";
  67635. export * from "babylonjs/Misc/perfCounter";
  67636. export * from "babylonjs/Misc/fileRequest";
  67637. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67638. export * from "babylonjs/Misc/retryStrategy";
  67639. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67640. export * from "babylonjs/Misc/canvasGenerator";
  67641. export * from "babylonjs/Misc/fileTools";
  67642. export * from "babylonjs/Misc/stringTools";
  67643. export * from "babylonjs/Misc/dataReader";
  67644. }
  67645. declare module "babylonjs/index" {
  67646. export * from "babylonjs/abstractScene";
  67647. export * from "babylonjs/Actions/index";
  67648. export * from "babylonjs/Animations/index";
  67649. export * from "babylonjs/assetContainer";
  67650. export * from "babylonjs/Audio/index";
  67651. export * from "babylonjs/Behaviors/index";
  67652. export * from "babylonjs/Bones/index";
  67653. export * from "babylonjs/Cameras/index";
  67654. export * from "babylonjs/Collisions/index";
  67655. export * from "babylonjs/Culling/index";
  67656. export * from "babylonjs/Debug/index";
  67657. export * from "babylonjs/Engines/index";
  67658. export * from "babylonjs/Events/index";
  67659. export * from "babylonjs/Gamepads/index";
  67660. export * from "babylonjs/Gizmos/index";
  67661. export * from "babylonjs/Helpers/index";
  67662. export * from "babylonjs/Instrumentation/index";
  67663. export * from "babylonjs/Layers/index";
  67664. export * from "babylonjs/LensFlares/index";
  67665. export * from "babylonjs/Lights/index";
  67666. export * from "babylonjs/Loading/index";
  67667. export * from "babylonjs/Materials/index";
  67668. export * from "babylonjs/Maths/index";
  67669. export * from "babylonjs/Meshes/index";
  67670. export * from "babylonjs/Morph/index";
  67671. export * from "babylonjs/Navigation/index";
  67672. export * from "babylonjs/node";
  67673. export * from "babylonjs/Offline/index";
  67674. export * from "babylonjs/Particles/index";
  67675. export * from "babylonjs/Physics/index";
  67676. export * from "babylonjs/PostProcesses/index";
  67677. export * from "babylonjs/Probes/index";
  67678. export * from "babylonjs/Rendering/index";
  67679. export * from "babylonjs/scene";
  67680. export * from "babylonjs/sceneComponent";
  67681. export * from "babylonjs/Sprites/index";
  67682. export * from "babylonjs/States/index";
  67683. export * from "babylonjs/Misc/index";
  67684. export * from "babylonjs/types";
  67685. }
  67686. declare module "babylonjs/Animations/pathCursor" {
  67687. import { Vector3 } from "babylonjs/Maths/math.vector";
  67688. import { Path2 } from "babylonjs/Maths/math.path";
  67689. /**
  67690. * A cursor which tracks a point on a path
  67691. */
  67692. export class PathCursor {
  67693. private path;
  67694. /**
  67695. * Stores path cursor callbacks for when an onchange event is triggered
  67696. */
  67697. private _onchange;
  67698. /**
  67699. * The value of the path cursor
  67700. */
  67701. value: number;
  67702. /**
  67703. * The animation array of the path cursor
  67704. */
  67705. animations: Animation[];
  67706. /**
  67707. * Initializes the path cursor
  67708. * @param path The path to track
  67709. */
  67710. constructor(path: Path2);
  67711. /**
  67712. * Gets the cursor point on the path
  67713. * @returns A point on the path cursor at the cursor location
  67714. */
  67715. getPoint(): Vector3;
  67716. /**
  67717. * Moves the cursor ahead by the step amount
  67718. * @param step The amount to move the cursor forward
  67719. * @returns This path cursor
  67720. */
  67721. moveAhead(step?: number): PathCursor;
  67722. /**
  67723. * Moves the cursor behind by the step amount
  67724. * @param step The amount to move the cursor back
  67725. * @returns This path cursor
  67726. */
  67727. moveBack(step?: number): PathCursor;
  67728. /**
  67729. * Moves the cursor by the step amount
  67730. * If the step amount is greater than one, an exception is thrown
  67731. * @param step The amount to move the cursor
  67732. * @returns This path cursor
  67733. */
  67734. move(step: number): PathCursor;
  67735. /**
  67736. * Ensures that the value is limited between zero and one
  67737. * @returns This path cursor
  67738. */
  67739. private ensureLimits;
  67740. /**
  67741. * Runs onchange callbacks on change (used by the animation engine)
  67742. * @returns This path cursor
  67743. */
  67744. private raiseOnChange;
  67745. /**
  67746. * Executes a function on change
  67747. * @param f A path cursor onchange callback
  67748. * @returns This path cursor
  67749. */
  67750. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67751. }
  67752. }
  67753. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67755. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67756. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67757. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67758. }
  67759. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67760. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67761. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67762. }
  67763. declare module "babylonjs/Engines/Processors/index" {
  67764. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67765. export * from "babylonjs/Engines/Processors/Expressions/index";
  67766. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67767. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67768. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67769. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67770. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67771. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67772. }
  67773. declare module "babylonjs/Legacy/legacy" {
  67774. import * as Babylon from "babylonjs/index";
  67775. export * from "babylonjs/index";
  67776. }
  67777. declare module "babylonjs/Shaders/blur.fragment" {
  67778. /** @hidden */
  67779. export var blurPixelShader: {
  67780. name: string;
  67781. shader: string;
  67782. };
  67783. }
  67784. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67785. /** @hidden */
  67786. export var pointCloudVertexDeclaration: {
  67787. name: string;
  67788. shader: string;
  67789. };
  67790. }
  67791. declare module "babylonjs" {
  67792. export * from "babylonjs/Legacy/legacy";
  67793. }
  67794. declare module BABYLON {
  67795. /** Alias type for value that can be null */
  67796. export type Nullable<T> = T | null;
  67797. /**
  67798. * Alias type for number that are floats
  67799. * @ignorenaming
  67800. */
  67801. export type float = number;
  67802. /**
  67803. * Alias type for number that are doubles.
  67804. * @ignorenaming
  67805. */
  67806. export type double = number;
  67807. /**
  67808. * Alias type for number that are integer
  67809. * @ignorenaming
  67810. */
  67811. export type int = number;
  67812. /** Alias type for number array or Float32Array */
  67813. export type FloatArray = number[] | Float32Array;
  67814. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67815. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67816. /**
  67817. * Alias for types that can be used by a Buffer or VertexBuffer.
  67818. */
  67819. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67820. /**
  67821. * Alias type for primitive types
  67822. * @ignorenaming
  67823. */
  67824. type Primitive = undefined | null | boolean | string | number | Function;
  67825. /**
  67826. * Type modifier to make all the properties of an object Readonly
  67827. */
  67828. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67829. /**
  67830. * Type modifier to make all the properties of an object Readonly recursively
  67831. */
  67832. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67833. /**
  67834. * Type modifier to make object properties readonly.
  67835. */
  67836. export type DeepImmutableObject<T> = {
  67837. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67838. };
  67839. /** @hidden */
  67840. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67841. }
  67842. }
  67843. declare module BABYLON {
  67844. /**
  67845. * A class serves as a medium between the observable and its observers
  67846. */
  67847. export class EventState {
  67848. /**
  67849. * Create a new EventState
  67850. * @param mask defines the mask associated with this state
  67851. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67852. * @param target defines the original target of the state
  67853. * @param currentTarget defines the current target of the state
  67854. */
  67855. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67856. /**
  67857. * Initialize the current event state
  67858. * @param mask defines the mask associated with this state
  67859. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67860. * @param target defines the original target of the state
  67861. * @param currentTarget defines the current target of the state
  67862. * @returns the current event state
  67863. */
  67864. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67865. /**
  67866. * An Observer can set this property to true to prevent subsequent observers of being notified
  67867. */
  67868. skipNextObservers: boolean;
  67869. /**
  67870. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67871. */
  67872. mask: number;
  67873. /**
  67874. * The object that originally notified the event
  67875. */
  67876. target?: any;
  67877. /**
  67878. * The current object in the bubbling phase
  67879. */
  67880. currentTarget?: any;
  67881. /**
  67882. * This will be populated with the return value of the last function that was executed.
  67883. * If it is the first function in the callback chain it will be the event data.
  67884. */
  67885. lastReturnValue?: any;
  67886. }
  67887. /**
  67888. * Represent an Observer registered to a given Observable object.
  67889. */
  67890. export class Observer<T> {
  67891. /**
  67892. * Defines the callback to call when the observer is notified
  67893. */
  67894. callback: (eventData: T, eventState: EventState) => void;
  67895. /**
  67896. * Defines the mask of the observer (used to filter notifications)
  67897. */
  67898. mask: number;
  67899. /**
  67900. * Defines the current scope used to restore the JS context
  67901. */
  67902. scope: any;
  67903. /** @hidden */
  67904. _willBeUnregistered: boolean;
  67905. /**
  67906. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67907. */
  67908. unregisterOnNextCall: boolean;
  67909. /**
  67910. * Creates a new observer
  67911. * @param callback defines the callback to call when the observer is notified
  67912. * @param mask defines the mask of the observer (used to filter notifications)
  67913. * @param scope defines the current scope used to restore the JS context
  67914. */
  67915. constructor(
  67916. /**
  67917. * Defines the callback to call when the observer is notified
  67918. */
  67919. callback: (eventData: T, eventState: EventState) => void,
  67920. /**
  67921. * Defines the mask of the observer (used to filter notifications)
  67922. */
  67923. mask: number,
  67924. /**
  67925. * Defines the current scope used to restore the JS context
  67926. */
  67927. scope?: any);
  67928. }
  67929. /**
  67930. * Represent a list of observers registered to multiple Observables object.
  67931. */
  67932. export class MultiObserver<T> {
  67933. private _observers;
  67934. private _observables;
  67935. /**
  67936. * Release associated resources
  67937. */
  67938. dispose(): void;
  67939. /**
  67940. * Raise a callback when one of the observable will notify
  67941. * @param observables defines a list of observables to watch
  67942. * @param callback defines the callback to call on notification
  67943. * @param mask defines the mask used to filter notifications
  67944. * @param scope defines the current scope used to restore the JS context
  67945. * @returns the new MultiObserver
  67946. */
  67947. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67948. }
  67949. /**
  67950. * The Observable class is a simple implementation of the Observable pattern.
  67951. *
  67952. * 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.
  67953. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67954. * 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).
  67955. * 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.
  67956. */
  67957. export class Observable<T> {
  67958. private _observers;
  67959. private _eventState;
  67960. private _onObserverAdded;
  67961. /**
  67962. * Gets the list of observers
  67963. */
  67964. readonly observers: Array<Observer<T>>;
  67965. /**
  67966. * Creates a new observable
  67967. * @param onObserverAdded defines a callback to call when a new observer is added
  67968. */
  67969. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67970. /**
  67971. * Create a new Observer with the specified callback
  67972. * @param callback the callback that will be executed for that Observer
  67973. * @param mask the mask used to filter observers
  67974. * @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.
  67975. * @param scope optional scope for the callback to be called from
  67976. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67977. * @returns the new observer created for the callback
  67978. */
  67979. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67980. /**
  67981. * Create a new Observer with the specified callback and unregisters after the next notification
  67982. * @param callback the callback that will be executed for that Observer
  67983. * @returns the new observer created for the callback
  67984. */
  67985. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67986. /**
  67987. * Remove an Observer from the Observable object
  67988. * @param observer the instance of the Observer to remove
  67989. * @returns false if it doesn't belong to this Observable
  67990. */
  67991. remove(observer: Nullable<Observer<T>>): boolean;
  67992. /**
  67993. * Remove a callback from the Observable object
  67994. * @param callback the callback to remove
  67995. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67996. * @returns false if it doesn't belong to this Observable
  67997. */
  67998. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67999. private _deferUnregister;
  68000. private _remove;
  68001. /**
  68002. * Moves the observable to the top of the observer list making it get called first when notified
  68003. * @param observer the observer to move
  68004. */
  68005. makeObserverTopPriority(observer: Observer<T>): void;
  68006. /**
  68007. * Moves the observable to the bottom of the observer list making it get called last when notified
  68008. * @param observer the observer to move
  68009. */
  68010. makeObserverBottomPriority(observer: Observer<T>): void;
  68011. /**
  68012. * Notify all Observers by calling their respective callback with the given data
  68013. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68014. * @param eventData defines the data to send to all observers
  68015. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68016. * @param target defines the original target of the state
  68017. * @param currentTarget defines the current target of the state
  68018. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68019. */
  68020. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68021. /**
  68022. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68023. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68024. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68025. * and it is crucial that all callbacks will be executed.
  68026. * The order of the callbacks is kept, callbacks are not executed parallel.
  68027. *
  68028. * @param eventData The data to be sent to each callback
  68029. * @param mask is used to filter observers defaults to -1
  68030. * @param target defines the callback target (see EventState)
  68031. * @param currentTarget defines he current object in the bubbling phase
  68032. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68033. */
  68034. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68035. /**
  68036. * Notify a specific observer
  68037. * @param observer defines the observer to notify
  68038. * @param eventData defines the data to be sent to each callback
  68039. * @param mask is used to filter observers defaults to -1
  68040. */
  68041. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68042. /**
  68043. * Gets a boolean indicating if the observable has at least one observer
  68044. * @returns true is the Observable has at least one Observer registered
  68045. */
  68046. hasObservers(): boolean;
  68047. /**
  68048. * Clear the list of observers
  68049. */
  68050. clear(): void;
  68051. /**
  68052. * Clone the current observable
  68053. * @returns a new observable
  68054. */
  68055. clone(): Observable<T>;
  68056. /**
  68057. * Does this observable handles observer registered with a given mask
  68058. * @param mask defines the mask to be tested
  68059. * @return whether or not one observer registered with the given mask is handeled
  68060. **/
  68061. hasSpecificMask(mask?: number): boolean;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68067. * Babylon.js
  68068. */
  68069. export class DomManagement {
  68070. /**
  68071. * Checks if the window object exists
  68072. * @returns true if the window object exists
  68073. */
  68074. static IsWindowObjectExist(): boolean;
  68075. /**
  68076. * Checks if the navigator object exists
  68077. * @returns true if the navigator object exists
  68078. */
  68079. static IsNavigatorAvailable(): boolean;
  68080. /**
  68081. * Extracts text content from a DOM element hierarchy
  68082. * @param element defines the root element
  68083. * @returns a string
  68084. */
  68085. static GetDOMTextContent(element: HTMLElement): string;
  68086. }
  68087. }
  68088. declare module BABYLON {
  68089. /**
  68090. * Logger used througouht the application to allow configuration of
  68091. * the log level required for the messages.
  68092. */
  68093. export class Logger {
  68094. /**
  68095. * No log
  68096. */
  68097. static readonly NoneLogLevel: number;
  68098. /**
  68099. * Only message logs
  68100. */
  68101. static readonly MessageLogLevel: number;
  68102. /**
  68103. * Only warning logs
  68104. */
  68105. static readonly WarningLogLevel: number;
  68106. /**
  68107. * Only error logs
  68108. */
  68109. static readonly ErrorLogLevel: number;
  68110. /**
  68111. * All logs
  68112. */
  68113. static readonly AllLogLevel: number;
  68114. private static _LogCache;
  68115. /**
  68116. * Gets a value indicating the number of loading errors
  68117. * @ignorenaming
  68118. */
  68119. static errorsCount: number;
  68120. /**
  68121. * Callback called when a new log is added
  68122. */
  68123. static OnNewCacheEntry: (entry: string) => void;
  68124. private static _AddLogEntry;
  68125. private static _FormatMessage;
  68126. private static _LogDisabled;
  68127. private static _LogEnabled;
  68128. private static _WarnDisabled;
  68129. private static _WarnEnabled;
  68130. private static _ErrorDisabled;
  68131. private static _ErrorEnabled;
  68132. /**
  68133. * Log a message to the console
  68134. */
  68135. static Log: (message: string) => void;
  68136. /**
  68137. * Write a warning message to the console
  68138. */
  68139. static Warn: (message: string) => void;
  68140. /**
  68141. * Write an error message to the console
  68142. */
  68143. static Error: (message: string) => void;
  68144. /**
  68145. * Gets current log cache (list of logs)
  68146. */
  68147. static readonly LogCache: string;
  68148. /**
  68149. * Clears the log cache
  68150. */
  68151. static ClearLogCache(): void;
  68152. /**
  68153. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68154. */
  68155. static LogLevels: number;
  68156. }
  68157. }
  68158. declare module BABYLON {
  68159. /** @hidden */
  68160. export class _TypeStore {
  68161. /** @hidden */
  68162. static RegisteredTypes: {
  68163. [key: string]: Object;
  68164. };
  68165. /** @hidden */
  68166. static GetClass(fqdn: string): any;
  68167. }
  68168. }
  68169. declare module BABYLON {
  68170. /**
  68171. * Helper to manipulate strings
  68172. */
  68173. export class StringTools {
  68174. /**
  68175. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68176. * @param str Source string
  68177. * @param suffix Suffix to search for in the source string
  68178. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68179. */
  68180. static EndsWith(str: string, suffix: string): boolean;
  68181. /**
  68182. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68183. * @param str Source string
  68184. * @param suffix Suffix to search for in the source string
  68185. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68186. */
  68187. static StartsWith(str: string, suffix: string): boolean;
  68188. /**
  68189. * Decodes a buffer into a string
  68190. * @param buffer The buffer to decode
  68191. * @returns The decoded string
  68192. */
  68193. static Decode(buffer: Uint8Array | Uint16Array): string;
  68194. /**
  68195. * Encode a buffer to a base64 string
  68196. * @param buffer defines the buffer to encode
  68197. * @returns the encoded string
  68198. */
  68199. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68200. }
  68201. }
  68202. declare module BABYLON {
  68203. /**
  68204. * Class containing a set of static utilities functions for deep copy.
  68205. */
  68206. export class DeepCopier {
  68207. /**
  68208. * Tries to copy an object by duplicating every property
  68209. * @param source defines the source object
  68210. * @param destination defines the target object
  68211. * @param doNotCopyList defines a list of properties to avoid
  68212. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68213. */
  68214. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68215. }
  68216. }
  68217. declare module BABYLON {
  68218. /**
  68219. * Class containing a set of static utilities functions for precision date
  68220. */
  68221. export class PrecisionDate {
  68222. /**
  68223. * Gets either window.performance.now() if supported or Date.now() else
  68224. */
  68225. static readonly Now: number;
  68226. }
  68227. }
  68228. declare module BABYLON {
  68229. /** @hidden */
  68230. export class _DevTools {
  68231. static WarnImport(name: string): string;
  68232. }
  68233. }
  68234. declare module BABYLON {
  68235. /**
  68236. * Interface used to define the mechanism to get data from the network
  68237. */
  68238. export interface IWebRequest {
  68239. /**
  68240. * Returns client's response url
  68241. */
  68242. responseURL: string;
  68243. /**
  68244. * Returns client's status
  68245. */
  68246. status: number;
  68247. /**
  68248. * Returns client's status as a text
  68249. */
  68250. statusText: string;
  68251. }
  68252. }
  68253. declare module BABYLON {
  68254. /**
  68255. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68256. */
  68257. export class WebRequest implements IWebRequest {
  68258. private _xhr;
  68259. /**
  68260. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68261. * i.e. when loading files, where the server/service expects an Authorization header
  68262. */
  68263. static CustomRequestHeaders: {
  68264. [key: string]: string;
  68265. };
  68266. /**
  68267. * Add callback functions in this array to update all the requests before they get sent to the network
  68268. */
  68269. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68270. private _injectCustomRequestHeaders;
  68271. /**
  68272. * Gets or sets a function to be called when loading progress changes
  68273. */
  68274. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68275. /**
  68276. * Returns client's state
  68277. */
  68278. readonly readyState: number;
  68279. /**
  68280. * Returns client's status
  68281. */
  68282. readonly status: number;
  68283. /**
  68284. * Returns client's status as a text
  68285. */
  68286. readonly statusText: string;
  68287. /**
  68288. * Returns client's response
  68289. */
  68290. readonly response: any;
  68291. /**
  68292. * Returns client's response url
  68293. */
  68294. readonly responseURL: string;
  68295. /**
  68296. * Returns client's response as text
  68297. */
  68298. readonly responseText: string;
  68299. /**
  68300. * Gets or sets the expected response type
  68301. */
  68302. responseType: XMLHttpRequestResponseType;
  68303. /** @hidden */
  68304. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68305. /** @hidden */
  68306. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68307. /**
  68308. * Cancels any network activity
  68309. */
  68310. abort(): void;
  68311. /**
  68312. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68313. * @param body defines an optional request body
  68314. */
  68315. send(body?: Document | BodyInit | null): void;
  68316. /**
  68317. * Sets the request method, request URL
  68318. * @param method defines the method to use (GET, POST, etc..)
  68319. * @param url defines the url to connect with
  68320. */
  68321. open(method: string, url: string): void;
  68322. /**
  68323. * Sets the value of a request header.
  68324. * @param name The name of the header whose value is to be set
  68325. * @param value The value to set as the body of the header
  68326. */
  68327. setRequestHeader(name: string, value: string): void;
  68328. /**
  68329. * Get the string containing the text of a particular header's value.
  68330. * @param name The name of the header
  68331. * @returns The string containing the text of the given header name
  68332. */
  68333. getResponseHeader(name: string): Nullable<string>;
  68334. }
  68335. }
  68336. declare module BABYLON {
  68337. /**
  68338. * File request interface
  68339. */
  68340. export interface IFileRequest {
  68341. /**
  68342. * Raised when the request is complete (success or error).
  68343. */
  68344. onCompleteObservable: Observable<IFileRequest>;
  68345. /**
  68346. * Aborts the request for a file.
  68347. */
  68348. abort: () => void;
  68349. }
  68350. }
  68351. declare module BABYLON {
  68352. /**
  68353. * Define options used to create a render target texture
  68354. */
  68355. export class RenderTargetCreationOptions {
  68356. /**
  68357. * Specifies is mipmaps must be generated
  68358. */
  68359. generateMipMaps?: boolean;
  68360. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68361. generateDepthBuffer?: boolean;
  68362. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68363. generateStencilBuffer?: boolean;
  68364. /** Defines texture type (int by default) */
  68365. type?: number;
  68366. /** Defines sampling mode (trilinear by default) */
  68367. samplingMode?: number;
  68368. /** Defines format (RGBA by default) */
  68369. format?: number;
  68370. }
  68371. }
  68372. declare module BABYLON {
  68373. /**
  68374. * @hidden
  68375. **/
  68376. export class _TimeToken {
  68377. _startTimeQuery: Nullable<WebGLQuery>;
  68378. _endTimeQuery: Nullable<WebGLQuery>;
  68379. _timeElapsedQuery: Nullable<WebGLQuery>;
  68380. _timeElapsedQueryEnded: boolean;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /** Defines the cross module used constants to avoid circular dependncies */
  68385. export class Constants {
  68386. /** Defines that alpha blending is disabled */
  68387. static readonly ALPHA_DISABLE: number;
  68388. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68389. static readonly ALPHA_ADD: number;
  68390. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68391. static readonly ALPHA_COMBINE: number;
  68392. /** Defines that alpha blending to DEST - SRC * DEST */
  68393. static readonly ALPHA_SUBTRACT: number;
  68394. /** Defines that alpha blending to SRC * DEST */
  68395. static readonly ALPHA_MULTIPLY: number;
  68396. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68397. static readonly ALPHA_MAXIMIZED: number;
  68398. /** Defines that alpha blending to SRC + DEST */
  68399. static readonly ALPHA_ONEONE: number;
  68400. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68401. static readonly ALPHA_PREMULTIPLIED: number;
  68402. /**
  68403. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68404. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68405. */
  68406. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68407. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68408. static readonly ALPHA_INTERPOLATE: number;
  68409. /**
  68410. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68411. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68412. */
  68413. static readonly ALPHA_SCREENMODE: number;
  68414. /**
  68415. * Defines that alpha blending to SRC + DST
  68416. * Alpha will be set to SRC ALPHA + DST ALPHA
  68417. */
  68418. static readonly ALPHA_ONEONE_ONEONE: number;
  68419. /**
  68420. * Defines that alpha blending to SRC * DST ALPHA + DST
  68421. * Alpha will be set to 0
  68422. */
  68423. static readonly ALPHA_ALPHATOCOLOR: number;
  68424. /**
  68425. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68426. */
  68427. static readonly ALPHA_REVERSEONEMINUS: number;
  68428. /**
  68429. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68430. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68431. */
  68432. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68433. /**
  68434. * Defines that alpha blending to SRC + DST
  68435. * Alpha will be set to SRC ALPHA
  68436. */
  68437. static readonly ALPHA_ONEONE_ONEZERO: number;
  68438. /** Defines that alpha blending equation a SUM */
  68439. static readonly ALPHA_EQUATION_ADD: number;
  68440. /** Defines that alpha blending equation a SUBSTRACTION */
  68441. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68442. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68443. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68444. /** Defines that alpha blending equation a MAX operation */
  68445. static readonly ALPHA_EQUATION_MAX: number;
  68446. /** Defines that alpha blending equation a MIN operation */
  68447. static readonly ALPHA_EQUATION_MIN: number;
  68448. /**
  68449. * Defines that alpha blending equation a DARKEN operation:
  68450. * It takes the min of the src and sums the alpha channels.
  68451. */
  68452. static readonly ALPHA_EQUATION_DARKEN: number;
  68453. /** Defines that the ressource is not delayed*/
  68454. static readonly DELAYLOADSTATE_NONE: number;
  68455. /** Defines that the ressource was successfully delay loaded */
  68456. static readonly DELAYLOADSTATE_LOADED: number;
  68457. /** Defines that the ressource is currently delay loading */
  68458. static readonly DELAYLOADSTATE_LOADING: number;
  68459. /** Defines that the ressource is delayed and has not started loading */
  68460. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68462. static readonly NEVER: number;
  68463. /** 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 */
  68464. static readonly ALWAYS: number;
  68465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68466. static readonly LESS: number;
  68467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68468. static readonly EQUAL: number;
  68469. /** 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 */
  68470. static readonly LEQUAL: number;
  68471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68472. static readonly GREATER: number;
  68473. /** 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 */
  68474. static readonly GEQUAL: number;
  68475. /** 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 */
  68476. static readonly NOTEQUAL: number;
  68477. /** Passed to stencilOperation to specify that stencil value must be kept */
  68478. static readonly KEEP: number;
  68479. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68480. static readonly REPLACE: number;
  68481. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68482. static readonly INCR: number;
  68483. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68484. static readonly DECR: number;
  68485. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68486. static readonly INVERT: number;
  68487. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68488. static readonly INCR_WRAP: number;
  68489. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68490. static readonly DECR_WRAP: number;
  68491. /** Texture is not repeating outside of 0..1 UVs */
  68492. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68493. /** Texture is repeating outside of 0..1 UVs */
  68494. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68495. /** Texture is repeating and mirrored */
  68496. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68497. /** ALPHA */
  68498. static readonly TEXTUREFORMAT_ALPHA: number;
  68499. /** LUMINANCE */
  68500. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68501. /** LUMINANCE_ALPHA */
  68502. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68503. /** RGB */
  68504. static readonly TEXTUREFORMAT_RGB: number;
  68505. /** RGBA */
  68506. static readonly TEXTUREFORMAT_RGBA: number;
  68507. /** RED */
  68508. static readonly TEXTUREFORMAT_RED: number;
  68509. /** RED (2nd reference) */
  68510. static readonly TEXTUREFORMAT_R: number;
  68511. /** RG */
  68512. static readonly TEXTUREFORMAT_RG: number;
  68513. /** RED_INTEGER */
  68514. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68515. /** RED_INTEGER (2nd reference) */
  68516. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68517. /** RG_INTEGER */
  68518. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68519. /** RGB_INTEGER */
  68520. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68521. /** RGBA_INTEGER */
  68522. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68523. /** UNSIGNED_BYTE */
  68524. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68525. /** UNSIGNED_BYTE (2nd reference) */
  68526. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68527. /** FLOAT */
  68528. static readonly TEXTURETYPE_FLOAT: number;
  68529. /** HALF_FLOAT */
  68530. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68531. /** BYTE */
  68532. static readonly TEXTURETYPE_BYTE: number;
  68533. /** SHORT */
  68534. static readonly TEXTURETYPE_SHORT: number;
  68535. /** UNSIGNED_SHORT */
  68536. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68537. /** INT */
  68538. static readonly TEXTURETYPE_INT: number;
  68539. /** UNSIGNED_INT */
  68540. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68541. /** UNSIGNED_SHORT_4_4_4_4 */
  68542. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68543. /** UNSIGNED_SHORT_5_5_5_1 */
  68544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68545. /** UNSIGNED_SHORT_5_6_5 */
  68546. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68547. /** UNSIGNED_INT_2_10_10_10_REV */
  68548. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68549. /** UNSIGNED_INT_24_8 */
  68550. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68551. /** UNSIGNED_INT_10F_11F_11F_REV */
  68552. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68553. /** UNSIGNED_INT_5_9_9_9_REV */
  68554. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68555. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68556. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68557. /** nearest is mag = nearest and min = nearest and mip = linear */
  68558. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68560. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68561. /** Trilinear is mag = linear and min = linear and mip = linear */
  68562. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68563. /** nearest is mag = nearest and min = nearest and mip = linear */
  68564. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68565. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68566. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68567. /** Trilinear is mag = linear and min = linear and mip = linear */
  68568. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68569. /** mag = nearest and min = nearest and mip = nearest */
  68570. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68571. /** mag = nearest and min = linear and mip = nearest */
  68572. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68573. /** mag = nearest and min = linear and mip = linear */
  68574. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68575. /** mag = nearest and min = linear and mip = none */
  68576. static readonly TEXTURE_NEAREST_LINEAR: number;
  68577. /** mag = nearest and min = nearest and mip = none */
  68578. static readonly TEXTURE_NEAREST_NEAREST: number;
  68579. /** mag = linear and min = nearest and mip = nearest */
  68580. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68581. /** mag = linear and min = nearest and mip = linear */
  68582. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68583. /** mag = linear and min = linear and mip = none */
  68584. static readonly TEXTURE_LINEAR_LINEAR: number;
  68585. /** mag = linear and min = nearest and mip = none */
  68586. static readonly TEXTURE_LINEAR_NEAREST: number;
  68587. /** Explicit coordinates mode */
  68588. static readonly TEXTURE_EXPLICIT_MODE: number;
  68589. /** Spherical coordinates mode */
  68590. static readonly TEXTURE_SPHERICAL_MODE: number;
  68591. /** Planar coordinates mode */
  68592. static readonly TEXTURE_PLANAR_MODE: number;
  68593. /** Cubic coordinates mode */
  68594. static readonly TEXTURE_CUBIC_MODE: number;
  68595. /** Projection coordinates mode */
  68596. static readonly TEXTURE_PROJECTION_MODE: number;
  68597. /** Skybox coordinates mode */
  68598. static readonly TEXTURE_SKYBOX_MODE: number;
  68599. /** Inverse Cubic coordinates mode */
  68600. static readonly TEXTURE_INVCUBIC_MODE: number;
  68601. /** Equirectangular coordinates mode */
  68602. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68603. /** Equirectangular Fixed coordinates mode */
  68604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68605. /** Equirectangular Fixed Mirrored coordinates mode */
  68606. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68607. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68608. static readonly SCALEMODE_FLOOR: number;
  68609. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68610. static readonly SCALEMODE_NEAREST: number;
  68611. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68612. static readonly SCALEMODE_CEILING: number;
  68613. /**
  68614. * The dirty texture flag value
  68615. */
  68616. static readonly MATERIAL_TextureDirtyFlag: number;
  68617. /**
  68618. * The dirty light flag value
  68619. */
  68620. static readonly MATERIAL_LightDirtyFlag: number;
  68621. /**
  68622. * The dirty fresnel flag value
  68623. */
  68624. static readonly MATERIAL_FresnelDirtyFlag: number;
  68625. /**
  68626. * The dirty attribute flag value
  68627. */
  68628. static readonly MATERIAL_AttributesDirtyFlag: number;
  68629. /**
  68630. * The dirty misc flag value
  68631. */
  68632. static readonly MATERIAL_MiscDirtyFlag: number;
  68633. /**
  68634. * The all dirty flag value
  68635. */
  68636. static readonly MATERIAL_AllDirtyFlag: number;
  68637. /**
  68638. * Returns the triangle fill mode
  68639. */
  68640. static readonly MATERIAL_TriangleFillMode: number;
  68641. /**
  68642. * Returns the wireframe mode
  68643. */
  68644. static readonly MATERIAL_WireFrameFillMode: number;
  68645. /**
  68646. * Returns the point fill mode
  68647. */
  68648. static readonly MATERIAL_PointFillMode: number;
  68649. /**
  68650. * Returns the point list draw mode
  68651. */
  68652. static readonly MATERIAL_PointListDrawMode: number;
  68653. /**
  68654. * Returns the line list draw mode
  68655. */
  68656. static readonly MATERIAL_LineListDrawMode: number;
  68657. /**
  68658. * Returns the line loop draw mode
  68659. */
  68660. static readonly MATERIAL_LineLoopDrawMode: number;
  68661. /**
  68662. * Returns the line strip draw mode
  68663. */
  68664. static readonly MATERIAL_LineStripDrawMode: number;
  68665. /**
  68666. * Returns the triangle strip draw mode
  68667. */
  68668. static readonly MATERIAL_TriangleStripDrawMode: number;
  68669. /**
  68670. * Returns the triangle fan draw mode
  68671. */
  68672. static readonly MATERIAL_TriangleFanDrawMode: number;
  68673. /**
  68674. * Stores the clock-wise side orientation
  68675. */
  68676. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68677. /**
  68678. * Stores the counter clock-wise side orientation
  68679. */
  68680. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68681. /**
  68682. * Nothing
  68683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68684. */
  68685. static readonly ACTION_NothingTrigger: number;
  68686. /**
  68687. * On pick
  68688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68689. */
  68690. static readonly ACTION_OnPickTrigger: number;
  68691. /**
  68692. * On left pick
  68693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68694. */
  68695. static readonly ACTION_OnLeftPickTrigger: number;
  68696. /**
  68697. * On right pick
  68698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68699. */
  68700. static readonly ACTION_OnRightPickTrigger: number;
  68701. /**
  68702. * On center pick
  68703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68704. */
  68705. static readonly ACTION_OnCenterPickTrigger: number;
  68706. /**
  68707. * On pick down
  68708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68709. */
  68710. static readonly ACTION_OnPickDownTrigger: number;
  68711. /**
  68712. * On double pick
  68713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68714. */
  68715. static readonly ACTION_OnDoublePickTrigger: number;
  68716. /**
  68717. * On pick up
  68718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68719. */
  68720. static readonly ACTION_OnPickUpTrigger: number;
  68721. /**
  68722. * On pick out.
  68723. * This trigger will only be raised if you also declared a OnPickDown
  68724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68725. */
  68726. static readonly ACTION_OnPickOutTrigger: number;
  68727. /**
  68728. * On long press
  68729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68730. */
  68731. static readonly ACTION_OnLongPressTrigger: number;
  68732. /**
  68733. * On pointer over
  68734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68735. */
  68736. static readonly ACTION_OnPointerOverTrigger: number;
  68737. /**
  68738. * On pointer out
  68739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68740. */
  68741. static readonly ACTION_OnPointerOutTrigger: number;
  68742. /**
  68743. * On every frame
  68744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68745. */
  68746. static readonly ACTION_OnEveryFrameTrigger: number;
  68747. /**
  68748. * On intersection enter
  68749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68750. */
  68751. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68752. /**
  68753. * On intersection exit
  68754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68755. */
  68756. static readonly ACTION_OnIntersectionExitTrigger: number;
  68757. /**
  68758. * On key down
  68759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68760. */
  68761. static readonly ACTION_OnKeyDownTrigger: number;
  68762. /**
  68763. * On key up
  68764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68765. */
  68766. static readonly ACTION_OnKeyUpTrigger: number;
  68767. /**
  68768. * Billboard mode will only apply to Y axis
  68769. */
  68770. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68771. /**
  68772. * Billboard mode will apply to all axes
  68773. */
  68774. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68775. /**
  68776. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68777. */
  68778. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68779. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68780. * Test order :
  68781. * Is the bounding sphere outside the frustum ?
  68782. * If not, are the bounding box vertices outside the frustum ?
  68783. * It not, then the cullable object is in the frustum.
  68784. */
  68785. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68786. /** Culling strategy : Bounding Sphere Only.
  68787. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68788. * It's also less accurate than the standard because some not visible objects can still be selected.
  68789. * Test : is the bounding sphere outside the frustum ?
  68790. * If not, then the cullable object is in the frustum.
  68791. */
  68792. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68793. /** Culling strategy : Optimistic Inclusion.
  68794. * This in an inclusion test first, then the standard exclusion test.
  68795. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68796. * 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.
  68797. * Anyway, it's as accurate as the standard strategy.
  68798. * Test :
  68799. * Is the cullable object bounding sphere center in the frustum ?
  68800. * If not, apply the default culling strategy.
  68801. */
  68802. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68803. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68804. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68805. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68806. * 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.
  68807. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68808. * Test :
  68809. * Is the cullable object bounding sphere center in the frustum ?
  68810. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68811. */
  68812. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68813. /**
  68814. * No logging while loading
  68815. */
  68816. static readonly SCENELOADER_NO_LOGGING: number;
  68817. /**
  68818. * Minimal logging while loading
  68819. */
  68820. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68821. /**
  68822. * Summary logging while loading
  68823. */
  68824. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68825. /**
  68826. * Detailled logging while loading
  68827. */
  68828. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68829. }
  68830. }
  68831. declare module BABYLON {
  68832. /**
  68833. * This represents the required contract to create a new type of texture loader.
  68834. */
  68835. export interface IInternalTextureLoader {
  68836. /**
  68837. * Defines wether the loader supports cascade loading the different faces.
  68838. */
  68839. supportCascades: boolean;
  68840. /**
  68841. * This returns if the loader support the current file information.
  68842. * @param extension defines the file extension of the file being loaded
  68843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68844. * @param fallback defines the fallback internal texture if any
  68845. * @param isBase64 defines whether the texture is encoded as a base64
  68846. * @param isBuffer defines whether the texture data are stored as a buffer
  68847. * @returns true if the loader can load the specified file
  68848. */
  68849. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68850. /**
  68851. * Transform the url before loading if required.
  68852. * @param rootUrl the url of the texture
  68853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68854. * @returns the transformed texture
  68855. */
  68856. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68857. /**
  68858. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68859. * @param rootUrl the url of the texture
  68860. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68861. * @returns the fallback texture
  68862. */
  68863. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68864. /**
  68865. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68866. * @param data contains the texture data
  68867. * @param texture defines the BabylonJS internal texture
  68868. * @param createPolynomials will be true if polynomials have been requested
  68869. * @param onLoad defines the callback to trigger once the texture is ready
  68870. * @param onError defines the callback to trigger in case of error
  68871. */
  68872. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68873. /**
  68874. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68875. * @param data contains the texture data
  68876. * @param texture defines the BabylonJS internal texture
  68877. * @param callback defines the method to call once ready to upload
  68878. */
  68879. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /**
  68884. * Class used to store and describe the pipeline context associated with an effect
  68885. */
  68886. export interface IPipelineContext {
  68887. /**
  68888. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68889. */
  68890. isAsync: boolean;
  68891. /**
  68892. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68893. */
  68894. isReady: boolean;
  68895. /** @hidden */
  68896. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /**
  68901. * Class used to store gfx data (like WebGLBuffer)
  68902. */
  68903. export class DataBuffer {
  68904. /**
  68905. * Gets or sets the number of objects referencing this buffer
  68906. */
  68907. references: number;
  68908. /** Gets or sets the size of the underlying buffer */
  68909. capacity: number;
  68910. /**
  68911. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68912. */
  68913. is32Bits: boolean;
  68914. /**
  68915. * Gets the underlying buffer
  68916. */
  68917. readonly underlyingResource: any;
  68918. }
  68919. }
  68920. declare module BABYLON {
  68921. /** @hidden */
  68922. export interface IShaderProcessor {
  68923. attributeProcessor?: (attribute: string) => string;
  68924. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68925. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68926. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68927. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68928. lineProcessor?: (line: string, isFragment: boolean) => string;
  68929. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68930. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68931. }
  68932. }
  68933. declare module BABYLON {
  68934. /** @hidden */
  68935. export interface ProcessingOptions {
  68936. defines: string[];
  68937. indexParameters: any;
  68938. isFragment: boolean;
  68939. shouldUseHighPrecisionShader: boolean;
  68940. supportsUniformBuffers: boolean;
  68941. shadersRepository: string;
  68942. includesShadersStore: {
  68943. [key: string]: string;
  68944. };
  68945. processor?: IShaderProcessor;
  68946. version: string;
  68947. platformName: string;
  68948. lookForClosingBracketForUniformBuffer?: boolean;
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /** @hidden */
  68953. export class ShaderCodeNode {
  68954. line: string;
  68955. children: ShaderCodeNode[];
  68956. additionalDefineKey?: string;
  68957. additionalDefineValue?: string;
  68958. isValid(preprocessors: {
  68959. [key: string]: string;
  68960. }): boolean;
  68961. process(preprocessors: {
  68962. [key: string]: string;
  68963. }, options: ProcessingOptions): string;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /** @hidden */
  68968. export class ShaderCodeCursor {
  68969. private _lines;
  68970. lineIndex: number;
  68971. readonly currentLine: string;
  68972. readonly canRead: boolean;
  68973. lines: string[];
  68974. }
  68975. }
  68976. declare module BABYLON {
  68977. /** @hidden */
  68978. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68979. process(preprocessors: {
  68980. [key: string]: string;
  68981. }, options: ProcessingOptions): string;
  68982. }
  68983. }
  68984. declare module BABYLON {
  68985. /** @hidden */
  68986. export class ShaderDefineExpression {
  68987. isTrue(preprocessors: {
  68988. [key: string]: string;
  68989. }): boolean;
  68990. }
  68991. }
  68992. declare module BABYLON {
  68993. /** @hidden */
  68994. export class ShaderCodeTestNode extends ShaderCodeNode {
  68995. testExpression: ShaderDefineExpression;
  68996. isValid(preprocessors: {
  68997. [key: string]: string;
  68998. }): boolean;
  68999. }
  69000. }
  69001. declare module BABYLON {
  69002. /** @hidden */
  69003. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69004. define: string;
  69005. not: boolean;
  69006. constructor(define: string, not?: boolean);
  69007. isTrue(preprocessors: {
  69008. [key: string]: string;
  69009. }): boolean;
  69010. }
  69011. }
  69012. declare module BABYLON {
  69013. /** @hidden */
  69014. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69015. leftOperand: ShaderDefineExpression;
  69016. rightOperand: ShaderDefineExpression;
  69017. isTrue(preprocessors: {
  69018. [key: string]: string;
  69019. }): boolean;
  69020. }
  69021. }
  69022. declare module BABYLON {
  69023. /** @hidden */
  69024. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69025. leftOperand: ShaderDefineExpression;
  69026. rightOperand: ShaderDefineExpression;
  69027. isTrue(preprocessors: {
  69028. [key: string]: string;
  69029. }): boolean;
  69030. }
  69031. }
  69032. declare module BABYLON {
  69033. /** @hidden */
  69034. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69035. define: string;
  69036. operand: string;
  69037. testValue: string;
  69038. constructor(define: string, operand: string, testValue: string);
  69039. isTrue(preprocessors: {
  69040. [key: string]: string;
  69041. }): boolean;
  69042. }
  69043. }
  69044. declare module BABYLON {
  69045. /**
  69046. * Class used to enable access to offline support
  69047. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69048. */
  69049. export interface IOfflineProvider {
  69050. /**
  69051. * Gets a boolean indicating if scene must be saved in the database
  69052. */
  69053. enableSceneOffline: boolean;
  69054. /**
  69055. * Gets a boolean indicating if textures must be saved in the database
  69056. */
  69057. enableTexturesOffline: boolean;
  69058. /**
  69059. * Open the offline support and make it available
  69060. * @param successCallback defines the callback to call on success
  69061. * @param errorCallback defines the callback to call on error
  69062. */
  69063. open(successCallback: () => void, errorCallback: () => void): void;
  69064. /**
  69065. * Loads an image from the offline support
  69066. * @param url defines the url to load from
  69067. * @param image defines the target DOM image
  69068. */
  69069. loadImage(url: string, image: HTMLImageElement): void;
  69070. /**
  69071. * Loads a file from offline support
  69072. * @param url defines the URL to load from
  69073. * @param sceneLoaded defines a callback to call on success
  69074. * @param progressCallBack defines a callback to call when progress changed
  69075. * @param errorCallback defines a callback to call on error
  69076. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69077. */
  69078. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69079. }
  69080. }
  69081. declare module BABYLON {
  69082. /**
  69083. * Class used to help managing file picking and drag'n'drop
  69084. * File Storage
  69085. */
  69086. export class FilesInputStore {
  69087. /**
  69088. * List of files ready to be loaded
  69089. */
  69090. static FilesToLoad: {
  69091. [key: string]: File;
  69092. };
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /**
  69097. * Class used to define a retry strategy when error happens while loading assets
  69098. */
  69099. export class RetryStrategy {
  69100. /**
  69101. * Function used to defines an exponential back off strategy
  69102. * @param maxRetries defines the maximum number of retries (3 by default)
  69103. * @param baseInterval defines the interval between retries
  69104. * @returns the strategy function to use
  69105. */
  69106. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69107. }
  69108. }
  69109. declare module BABYLON {
  69110. /**
  69111. * @ignore
  69112. * Application error to support additional information when loading a file
  69113. */
  69114. export abstract class BaseError extends Error {
  69115. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69116. }
  69117. }
  69118. declare module BABYLON {
  69119. /** @ignore */
  69120. export class LoadFileError extends BaseError {
  69121. request?: WebRequest;
  69122. file?: File;
  69123. /**
  69124. * Creates a new LoadFileError
  69125. * @param message defines the message of the error
  69126. * @param request defines the optional web request
  69127. * @param file defines the optional file
  69128. */
  69129. constructor(message: string, object?: WebRequest | File);
  69130. }
  69131. /** @ignore */
  69132. export class RequestFileError extends BaseError {
  69133. request: WebRequest;
  69134. /**
  69135. * Creates a new LoadFileError
  69136. * @param message defines the message of the error
  69137. * @param request defines the optional web request
  69138. */
  69139. constructor(message: string, request: WebRequest);
  69140. }
  69141. /** @ignore */
  69142. export class ReadFileError extends BaseError {
  69143. file: File;
  69144. /**
  69145. * Creates a new ReadFileError
  69146. * @param message defines the message of the error
  69147. * @param file defines the optional file
  69148. */
  69149. constructor(message: string, file: File);
  69150. }
  69151. /**
  69152. * @hidden
  69153. */
  69154. export class FileTools {
  69155. /**
  69156. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69157. */
  69158. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69159. /**
  69160. * Gets or sets the base URL to use to load assets
  69161. */
  69162. static BaseUrl: string;
  69163. /**
  69164. * Default behaviour for cors in the application.
  69165. * It can be a string if the expected behavior is identical in the entire app.
  69166. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69167. */
  69168. static CorsBehavior: string | ((url: string | string[]) => string);
  69169. /**
  69170. * Gets or sets a function used to pre-process url before using them to load assets
  69171. */
  69172. static PreprocessUrl: (url: string) => string;
  69173. /**
  69174. * Removes unwanted characters from an url
  69175. * @param url defines the url to clean
  69176. * @returns the cleaned url
  69177. */
  69178. private static _CleanUrl;
  69179. /**
  69180. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69181. * @param url define the url we are trying
  69182. * @param element define the dom element where to configure the cors policy
  69183. */
  69184. static SetCorsBehavior(url: string | string[], element: {
  69185. crossOrigin: string | null;
  69186. }): void;
  69187. /**
  69188. * Loads an image as an HTMLImageElement.
  69189. * @param input url string, ArrayBuffer, or Blob to load
  69190. * @param onLoad callback called when the image successfully loads
  69191. * @param onError callback called when the image fails to load
  69192. * @param offlineProvider offline provider for caching
  69193. * @param mimeType optional mime type
  69194. * @returns the HTMLImageElement of the loaded image
  69195. */
  69196. 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>;
  69197. /**
  69198. * Reads a file from a File object
  69199. * @param file defines the file to load
  69200. * @param onSuccess defines the callback to call when data is loaded
  69201. * @param onProgress defines the callback to call during loading process
  69202. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69203. * @param onError defines the callback to call when an error occurs
  69204. * @returns a file request object
  69205. */
  69206. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69207. /**
  69208. * Loads a file from a url
  69209. * @param url url to load
  69210. * @param onSuccess callback called when the file successfully loads
  69211. * @param onProgress callback called while file is loading (if the server supports this mode)
  69212. * @param offlineProvider defines the offline provider for caching
  69213. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69214. * @param onError callback called when the file fails to load
  69215. * @returns a file request object
  69216. */
  69217. 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;
  69218. /**
  69219. * Loads a file
  69220. * @param url url to load
  69221. * @param onSuccess callback called when the file successfully loads
  69222. * @param onProgress callback called while file is loading (if the server supports this mode)
  69223. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69224. * @param onError callback called when the file fails to load
  69225. * @param onOpened callback called when the web request is opened
  69226. * @returns a file request object
  69227. */
  69228. 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;
  69229. /**
  69230. * Checks if the loaded document was accessed via `file:`-Protocol.
  69231. * @returns boolean
  69232. */
  69233. static IsFileURL(): boolean;
  69234. }
  69235. }
  69236. declare module BABYLON {
  69237. /** @hidden */
  69238. export class ShaderProcessor {
  69239. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69240. private static _ProcessPrecision;
  69241. private static _ExtractOperation;
  69242. private static _BuildSubExpression;
  69243. private static _BuildExpression;
  69244. private static _MoveCursorWithinIf;
  69245. private static _MoveCursor;
  69246. private static _EvaluatePreProcessors;
  69247. private static _PreparePreProcessors;
  69248. private static _ProcessShaderConversion;
  69249. private static _ProcessIncludes;
  69250. }
  69251. }
  69252. declare module BABYLON {
  69253. /**
  69254. * @hidden
  69255. */
  69256. export interface IColor4Like {
  69257. r: float;
  69258. g: float;
  69259. b: float;
  69260. a: float;
  69261. }
  69262. /**
  69263. * @hidden
  69264. */
  69265. export interface IColor3Like {
  69266. r: float;
  69267. g: float;
  69268. b: float;
  69269. }
  69270. /**
  69271. * @hidden
  69272. */
  69273. export interface IVector4Like {
  69274. x: float;
  69275. y: float;
  69276. z: float;
  69277. w: float;
  69278. }
  69279. /**
  69280. * @hidden
  69281. */
  69282. export interface IVector3Like {
  69283. x: float;
  69284. y: float;
  69285. z: float;
  69286. }
  69287. /**
  69288. * @hidden
  69289. */
  69290. export interface IVector2Like {
  69291. x: float;
  69292. y: float;
  69293. }
  69294. /**
  69295. * @hidden
  69296. */
  69297. export interface IMatrixLike {
  69298. toArray(): DeepImmutable<Float32Array>;
  69299. updateFlag: int;
  69300. }
  69301. /**
  69302. * @hidden
  69303. */
  69304. export interface IViewportLike {
  69305. x: float;
  69306. y: float;
  69307. width: float;
  69308. height: float;
  69309. }
  69310. /**
  69311. * @hidden
  69312. */
  69313. export interface IPlaneLike {
  69314. normal: IVector3Like;
  69315. d: float;
  69316. normalize(): void;
  69317. }
  69318. }
  69319. declare module BABYLON {
  69320. /**
  69321. * Interface used to define common properties for effect fallbacks
  69322. */
  69323. export interface IEffectFallbacks {
  69324. /**
  69325. * Removes the defines that should be removed when falling back.
  69326. * @param currentDefines defines the current define statements for the shader.
  69327. * @param effect defines the current effect we try to compile
  69328. * @returns The resulting defines with defines of the current rank removed.
  69329. */
  69330. reduce(currentDefines: string, effect: Effect): string;
  69331. /**
  69332. * Removes the fallback from the bound mesh.
  69333. */
  69334. unBindMesh(): void;
  69335. /**
  69336. * Checks to see if more fallbacks are still availible.
  69337. */
  69338. hasMoreFallbacks: boolean;
  69339. }
  69340. }
  69341. declare module BABYLON {
  69342. /**
  69343. * Class used to evalaute queries containing `and` and `or` operators
  69344. */
  69345. export class AndOrNotEvaluator {
  69346. /**
  69347. * Evaluate a query
  69348. * @param query defines the query to evaluate
  69349. * @param evaluateCallback defines the callback used to filter result
  69350. * @returns true if the query matches
  69351. */
  69352. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69353. private static _HandleParenthesisContent;
  69354. private static _SimplifyNegation;
  69355. }
  69356. }
  69357. declare module BABYLON {
  69358. /**
  69359. * Class used to store custom tags
  69360. */
  69361. export class Tags {
  69362. /**
  69363. * Adds support for tags on the given object
  69364. * @param obj defines the object to use
  69365. */
  69366. static EnableFor(obj: any): void;
  69367. /**
  69368. * Removes tags support
  69369. * @param obj defines the object to use
  69370. */
  69371. static DisableFor(obj: any): void;
  69372. /**
  69373. * Gets a boolean indicating if the given object has tags
  69374. * @param obj defines the object to use
  69375. * @returns a boolean
  69376. */
  69377. static HasTags(obj: any): boolean;
  69378. /**
  69379. * Gets the tags available on a given object
  69380. * @param obj defines the object to use
  69381. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69382. * @returns the tags
  69383. */
  69384. static GetTags(obj: any, asString?: boolean): any;
  69385. /**
  69386. * Adds tags to an object
  69387. * @param obj defines the object to use
  69388. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69389. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69390. */
  69391. static AddTagsTo(obj: any, tagsString: string): void;
  69392. /**
  69393. * @hidden
  69394. */
  69395. static _AddTagTo(obj: any, tag: string): void;
  69396. /**
  69397. * Removes specific tags from a specific object
  69398. * @param obj defines the object to use
  69399. * @param tagsString defines the tags to remove
  69400. */
  69401. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69402. /**
  69403. * @hidden
  69404. */
  69405. static _RemoveTagFrom(obj: any, tag: string): void;
  69406. /**
  69407. * Defines if tags hosted on an object match a given query
  69408. * @param obj defines the object to use
  69409. * @param tagsQuery defines the tag query
  69410. * @returns a boolean
  69411. */
  69412. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /**
  69417. * Scalar computation library
  69418. */
  69419. export class Scalar {
  69420. /**
  69421. * Two pi constants convenient for computation.
  69422. */
  69423. static TwoPi: number;
  69424. /**
  69425. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69426. * @param a number
  69427. * @param b number
  69428. * @param epsilon (default = 1.401298E-45)
  69429. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69430. */
  69431. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69432. /**
  69433. * Returns a string : the upper case translation of the number i to hexadecimal.
  69434. * @param i number
  69435. * @returns the upper case translation of the number i to hexadecimal.
  69436. */
  69437. static ToHex(i: number): string;
  69438. /**
  69439. * Returns -1 if value is negative and +1 is value is positive.
  69440. * @param value the value
  69441. * @returns the value itself if it's equal to zero.
  69442. */
  69443. static Sign(value: number): number;
  69444. /**
  69445. * Returns the value itself if it's between min and max.
  69446. * Returns min if the value is lower than min.
  69447. * Returns max if the value is greater than max.
  69448. * @param value the value to clmap
  69449. * @param min the min value to clamp to (default: 0)
  69450. * @param max the max value to clamp to (default: 1)
  69451. * @returns the clamped value
  69452. */
  69453. static Clamp(value: number, min?: number, max?: number): number;
  69454. /**
  69455. * the log2 of value.
  69456. * @param value the value to compute log2 of
  69457. * @returns the log2 of value.
  69458. */
  69459. static Log2(value: number): number;
  69460. /**
  69461. * Loops the value, so that it is never larger than length and never smaller than 0.
  69462. *
  69463. * This is similar to the modulo operator but it works with floating point numbers.
  69464. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69465. * With t = 5 and length = 2.5, the result would be 0.0.
  69466. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69467. * @param value the value
  69468. * @param length the length
  69469. * @returns the looped value
  69470. */
  69471. static Repeat(value: number, length: number): number;
  69472. /**
  69473. * Normalize the value between 0.0 and 1.0 using min and max values
  69474. * @param value value to normalize
  69475. * @param min max to normalize between
  69476. * @param max min to normalize between
  69477. * @returns the normalized value
  69478. */
  69479. static Normalize(value: number, min: number, max: number): number;
  69480. /**
  69481. * Denormalize the value from 0.0 and 1.0 using min and max values
  69482. * @param normalized value to denormalize
  69483. * @param min max to denormalize between
  69484. * @param max min to denormalize between
  69485. * @returns the denormalized value
  69486. */
  69487. static Denormalize(normalized: number, min: number, max: number): number;
  69488. /**
  69489. * Calculates the shortest difference between two given angles given in degrees.
  69490. * @param current current angle in degrees
  69491. * @param target target angle in degrees
  69492. * @returns the delta
  69493. */
  69494. static DeltaAngle(current: number, target: number): number;
  69495. /**
  69496. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69497. * @param tx value
  69498. * @param length length
  69499. * @returns The returned value will move back and forth between 0 and length
  69500. */
  69501. static PingPong(tx: number, length: number): number;
  69502. /**
  69503. * Interpolates between min and max with smoothing at the limits.
  69504. *
  69505. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69506. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69507. * @param from from
  69508. * @param to to
  69509. * @param tx value
  69510. * @returns the smooth stepped value
  69511. */
  69512. static SmoothStep(from: number, to: number, tx: number): number;
  69513. /**
  69514. * Moves a value current towards target.
  69515. *
  69516. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69517. * Negative values of maxDelta pushes the value away from target.
  69518. * @param current current value
  69519. * @param target target value
  69520. * @param maxDelta max distance to move
  69521. * @returns resulting value
  69522. */
  69523. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69524. /**
  69525. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69526. *
  69527. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69528. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69529. * @param current current value
  69530. * @param target target value
  69531. * @param maxDelta max distance to move
  69532. * @returns resulting angle
  69533. */
  69534. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69535. /**
  69536. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69537. * @param start start value
  69538. * @param end target value
  69539. * @param amount amount to lerp between
  69540. * @returns the lerped value
  69541. */
  69542. static Lerp(start: number, end: number, amount: number): number;
  69543. /**
  69544. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69545. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69546. * @param start start value
  69547. * @param end target value
  69548. * @param amount amount to lerp between
  69549. * @returns the lerped value
  69550. */
  69551. static LerpAngle(start: number, end: number, amount: number): number;
  69552. /**
  69553. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69554. * @param a start value
  69555. * @param b target value
  69556. * @param value value between a and b
  69557. * @returns the inverseLerp value
  69558. */
  69559. static InverseLerp(a: number, b: number, value: number): number;
  69560. /**
  69561. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69562. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69563. * @param value1 spline value
  69564. * @param tangent1 spline value
  69565. * @param value2 spline value
  69566. * @param tangent2 spline value
  69567. * @param amount input value
  69568. * @returns hermite result
  69569. */
  69570. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69571. /**
  69572. * Returns a random float number between and min and max values
  69573. * @param min min value of random
  69574. * @param max max value of random
  69575. * @returns random value
  69576. */
  69577. static RandomRange(min: number, max: number): number;
  69578. /**
  69579. * This function returns percentage of a number in a given range.
  69580. *
  69581. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69582. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69583. * @param number to convert to percentage
  69584. * @param min min range
  69585. * @param max max range
  69586. * @returns the percentage
  69587. */
  69588. static RangeToPercent(number: number, min: number, max: number): number;
  69589. /**
  69590. * This function returns number that corresponds to the percentage in a given range.
  69591. *
  69592. * PercentToRange(0.34,0,100) will return 34.
  69593. * @param percent to convert to number
  69594. * @param min min range
  69595. * @param max max range
  69596. * @returns the number
  69597. */
  69598. static PercentToRange(percent: number, min: number, max: number): number;
  69599. /**
  69600. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69601. * @param angle The angle to normalize in radian.
  69602. * @return The converted angle.
  69603. */
  69604. static NormalizeRadians(angle: number): number;
  69605. }
  69606. }
  69607. declare module BABYLON {
  69608. /**
  69609. * Constant used to convert a value to gamma space
  69610. * @ignorenaming
  69611. */
  69612. export const ToGammaSpace: number;
  69613. /**
  69614. * Constant used to convert a value to linear space
  69615. * @ignorenaming
  69616. */
  69617. export const ToLinearSpace = 2.2;
  69618. /**
  69619. * Constant used to define the minimal number value in Babylon.js
  69620. * @ignorenaming
  69621. */
  69622. let Epsilon: number;
  69623. }
  69624. declare module BABYLON {
  69625. /**
  69626. * Class used to represent a viewport on screen
  69627. */
  69628. export class Viewport {
  69629. /** viewport left coordinate */
  69630. x: number;
  69631. /** viewport top coordinate */
  69632. y: number;
  69633. /**viewport width */
  69634. width: number;
  69635. /** viewport height */
  69636. height: number;
  69637. /**
  69638. * Creates a Viewport object located at (x, y) and sized (width, height)
  69639. * @param x defines viewport left coordinate
  69640. * @param y defines viewport top coordinate
  69641. * @param width defines the viewport width
  69642. * @param height defines the viewport height
  69643. */
  69644. constructor(
  69645. /** viewport left coordinate */
  69646. x: number,
  69647. /** viewport top coordinate */
  69648. y: number,
  69649. /**viewport width */
  69650. width: number,
  69651. /** viewport height */
  69652. height: number);
  69653. /**
  69654. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69655. * @param renderWidth defines the rendering width
  69656. * @param renderHeight defines the rendering height
  69657. * @returns a new Viewport
  69658. */
  69659. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69660. /**
  69661. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69662. * @param renderWidth defines the rendering width
  69663. * @param renderHeight defines the rendering height
  69664. * @param ref defines the target viewport
  69665. * @returns the current viewport
  69666. */
  69667. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69668. /**
  69669. * Returns a new Viewport copied from the current one
  69670. * @returns a new Viewport
  69671. */
  69672. clone(): Viewport;
  69673. }
  69674. }
  69675. declare module BABYLON {
  69676. /**
  69677. * Class containing a set of static utilities functions for arrays.
  69678. */
  69679. export class ArrayTools {
  69680. /**
  69681. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69682. * @param size the number of element to construct and put in the array
  69683. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69684. * @returns a new array filled with new objects
  69685. */
  69686. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /**
  69691. * Class representing a vector containing 2 coordinates
  69692. */
  69693. export class Vector2 {
  69694. /** defines the first coordinate */
  69695. x: number;
  69696. /** defines the second coordinate */
  69697. y: number;
  69698. /**
  69699. * Creates a new Vector2 from the given x and y coordinates
  69700. * @param x defines the first coordinate
  69701. * @param y defines the second coordinate
  69702. */
  69703. constructor(
  69704. /** defines the first coordinate */
  69705. x?: number,
  69706. /** defines the second coordinate */
  69707. y?: number);
  69708. /**
  69709. * Gets a string with the Vector2 coordinates
  69710. * @returns a string with the Vector2 coordinates
  69711. */
  69712. toString(): string;
  69713. /**
  69714. * Gets class name
  69715. * @returns the string "Vector2"
  69716. */
  69717. getClassName(): string;
  69718. /**
  69719. * Gets current vector hash code
  69720. * @returns the Vector2 hash code as a number
  69721. */
  69722. getHashCode(): number;
  69723. /**
  69724. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69725. * @param array defines the source array
  69726. * @param index defines the offset in source array
  69727. * @returns the current Vector2
  69728. */
  69729. toArray(array: FloatArray, index?: number): Vector2;
  69730. /**
  69731. * Copy the current vector to an array
  69732. * @returns a new array with 2 elements: the Vector2 coordinates.
  69733. */
  69734. asArray(): number[];
  69735. /**
  69736. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69737. * @param source defines the source Vector2
  69738. * @returns the current updated Vector2
  69739. */
  69740. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69741. /**
  69742. * Sets the Vector2 coordinates with the given floats
  69743. * @param x defines the first coordinate
  69744. * @param y defines the second coordinate
  69745. * @returns the current updated Vector2
  69746. */
  69747. copyFromFloats(x: number, y: number): Vector2;
  69748. /**
  69749. * Sets the Vector2 coordinates with the given floats
  69750. * @param x defines the first coordinate
  69751. * @param y defines the second coordinate
  69752. * @returns the current updated Vector2
  69753. */
  69754. set(x: number, y: number): Vector2;
  69755. /**
  69756. * Add another vector with the current one
  69757. * @param otherVector defines the other vector
  69758. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69759. */
  69760. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69761. /**
  69762. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69763. * @param otherVector defines the other vector
  69764. * @param result defines the target vector
  69765. * @returns the unmodified current Vector2
  69766. */
  69767. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69768. /**
  69769. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69770. * @param otherVector defines the other vector
  69771. * @returns the current updated Vector2
  69772. */
  69773. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69774. /**
  69775. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69776. * @param otherVector defines the other vector
  69777. * @returns a new Vector2
  69778. */
  69779. addVector3(otherVector: Vector3): Vector2;
  69780. /**
  69781. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69782. * @param otherVector defines the other vector
  69783. * @returns a new Vector2
  69784. */
  69785. subtract(otherVector: Vector2): Vector2;
  69786. /**
  69787. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69788. * @param otherVector defines the other vector
  69789. * @param result defines the target vector
  69790. * @returns the unmodified current Vector2
  69791. */
  69792. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69793. /**
  69794. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69795. * @param otherVector defines the other vector
  69796. * @returns the current updated Vector2
  69797. */
  69798. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69799. /**
  69800. * Multiplies in place the current Vector2 coordinates by the given ones
  69801. * @param otherVector defines the other vector
  69802. * @returns the current updated Vector2
  69803. */
  69804. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69805. /**
  69806. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69807. * @param otherVector defines the other vector
  69808. * @returns a new Vector2
  69809. */
  69810. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69811. /**
  69812. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69813. * @param otherVector defines the other vector
  69814. * @param result defines the target vector
  69815. * @returns the unmodified current Vector2
  69816. */
  69817. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69818. /**
  69819. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69820. * @param x defines the first coordinate
  69821. * @param y defines the second coordinate
  69822. * @returns a new Vector2
  69823. */
  69824. multiplyByFloats(x: number, y: number): Vector2;
  69825. /**
  69826. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69827. * @param otherVector defines the other vector
  69828. * @returns a new Vector2
  69829. */
  69830. divide(otherVector: Vector2): Vector2;
  69831. /**
  69832. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69833. * @param otherVector defines the other vector
  69834. * @param result defines the target vector
  69835. * @returns the unmodified current Vector2
  69836. */
  69837. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69838. /**
  69839. * Divides the current Vector2 coordinates by the given ones
  69840. * @param otherVector defines the other vector
  69841. * @returns the current updated Vector2
  69842. */
  69843. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69844. /**
  69845. * Gets a new Vector2 with current Vector2 negated coordinates
  69846. * @returns a new Vector2
  69847. */
  69848. negate(): Vector2;
  69849. /**
  69850. * Multiply the Vector2 coordinates by scale
  69851. * @param scale defines the scaling factor
  69852. * @returns the current updated Vector2
  69853. */
  69854. scaleInPlace(scale: number): Vector2;
  69855. /**
  69856. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69857. * @param scale defines the scaling factor
  69858. * @returns a new Vector2
  69859. */
  69860. scale(scale: number): Vector2;
  69861. /**
  69862. * Scale the current Vector2 values by a factor to a given Vector2
  69863. * @param scale defines the scale factor
  69864. * @param result defines the Vector2 object where to store the result
  69865. * @returns the unmodified current Vector2
  69866. */
  69867. scaleToRef(scale: number, result: Vector2): Vector2;
  69868. /**
  69869. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69870. * @param scale defines the scale factor
  69871. * @param result defines the Vector2 object where to store the result
  69872. * @returns the unmodified current Vector2
  69873. */
  69874. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69875. /**
  69876. * Gets a boolean if two vectors are equals
  69877. * @param otherVector defines the other vector
  69878. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69879. */
  69880. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69881. /**
  69882. * Gets a boolean if two vectors are equals (using an epsilon value)
  69883. * @param otherVector defines the other vector
  69884. * @param epsilon defines the minimal distance to consider equality
  69885. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69886. */
  69887. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69888. /**
  69889. * Gets a new Vector2 from current Vector2 floored values
  69890. * @returns a new Vector2
  69891. */
  69892. floor(): Vector2;
  69893. /**
  69894. * Gets a new Vector2 from current Vector2 floored values
  69895. * @returns a new Vector2
  69896. */
  69897. fract(): Vector2;
  69898. /**
  69899. * Gets the length of the vector
  69900. * @returns the vector length (float)
  69901. */
  69902. length(): number;
  69903. /**
  69904. * Gets the vector squared length
  69905. * @returns the vector squared length (float)
  69906. */
  69907. lengthSquared(): number;
  69908. /**
  69909. * Normalize the vector
  69910. * @returns the current updated Vector2
  69911. */
  69912. normalize(): Vector2;
  69913. /**
  69914. * Gets a new Vector2 copied from the Vector2
  69915. * @returns a new Vector2
  69916. */
  69917. clone(): Vector2;
  69918. /**
  69919. * Gets a new Vector2(0, 0)
  69920. * @returns a new Vector2
  69921. */
  69922. static Zero(): Vector2;
  69923. /**
  69924. * Gets a new Vector2(1, 1)
  69925. * @returns a new Vector2
  69926. */
  69927. static One(): Vector2;
  69928. /**
  69929. * Gets a new Vector2 set from the given index element of the given array
  69930. * @param array defines the data source
  69931. * @param offset defines the offset in the data source
  69932. * @returns a new Vector2
  69933. */
  69934. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69935. /**
  69936. * Sets "result" from the given index element of the given array
  69937. * @param array defines the data source
  69938. * @param offset defines the offset in the data source
  69939. * @param result defines the target vector
  69940. */
  69941. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69942. /**
  69943. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69944. * @param value1 defines 1st point of control
  69945. * @param value2 defines 2nd point of control
  69946. * @param value3 defines 3rd point of control
  69947. * @param value4 defines 4th point of control
  69948. * @param amount defines the interpolation factor
  69949. * @returns a new Vector2
  69950. */
  69951. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69952. /**
  69953. * 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".
  69954. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69955. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69956. * @param value defines the value to clamp
  69957. * @param min defines the lower limit
  69958. * @param max defines the upper limit
  69959. * @returns a new Vector2
  69960. */
  69961. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69962. /**
  69963. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69964. * @param value1 defines the 1st control point
  69965. * @param tangent1 defines the outgoing tangent
  69966. * @param value2 defines the 2nd control point
  69967. * @param tangent2 defines the incoming tangent
  69968. * @param amount defines the interpolation factor
  69969. * @returns a new Vector2
  69970. */
  69971. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69972. /**
  69973. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69974. * @param start defines the start vector
  69975. * @param end defines the end vector
  69976. * @param amount defines the interpolation factor
  69977. * @returns a new Vector2
  69978. */
  69979. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69980. /**
  69981. * Gets the dot product of the vector "left" and the vector "right"
  69982. * @param left defines first vector
  69983. * @param right defines second vector
  69984. * @returns the dot product (float)
  69985. */
  69986. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69987. /**
  69988. * Returns a new Vector2 equal to the normalized given vector
  69989. * @param vector defines the vector to normalize
  69990. * @returns a new Vector2
  69991. */
  69992. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69993. /**
  69994. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69995. * @param left defines 1st vector
  69996. * @param right defines 2nd vector
  69997. * @returns a new Vector2
  69998. */
  69999. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70000. /**
  70001. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70002. * @param left defines 1st vector
  70003. * @param right defines 2nd vector
  70004. * @returns a new Vector2
  70005. */
  70006. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70007. /**
  70008. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70009. * @param vector defines the vector to transform
  70010. * @param transformation defines the matrix to apply
  70011. * @returns a new Vector2
  70012. */
  70013. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70014. /**
  70015. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70016. * @param vector defines the vector to transform
  70017. * @param transformation defines the matrix to apply
  70018. * @param result defines the target vector
  70019. */
  70020. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70021. /**
  70022. * Determines if a given vector is included in a triangle
  70023. * @param p defines the vector to test
  70024. * @param p0 defines 1st triangle point
  70025. * @param p1 defines 2nd triangle point
  70026. * @param p2 defines 3rd triangle point
  70027. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70028. */
  70029. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70030. /**
  70031. * Gets the distance between the vectors "value1" and "value2"
  70032. * @param value1 defines first vector
  70033. * @param value2 defines second vector
  70034. * @returns the distance between vectors
  70035. */
  70036. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70037. /**
  70038. * Returns the squared distance between the vectors "value1" and "value2"
  70039. * @param value1 defines first vector
  70040. * @param value2 defines second vector
  70041. * @returns the squared distance between vectors
  70042. */
  70043. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70044. /**
  70045. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70046. * @param value1 defines first vector
  70047. * @param value2 defines second vector
  70048. * @returns a new Vector2
  70049. */
  70050. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70051. /**
  70052. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70053. * @param p defines the middle point
  70054. * @param segA defines one point of the segment
  70055. * @param segB defines the other point of the segment
  70056. * @returns the shortest distance
  70057. */
  70058. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70059. }
  70060. /**
  70061. * Classed used to store (x,y,z) vector representation
  70062. * A Vector3 is the main object used in 3D geometry
  70063. * It can represent etiher the coordinates of a point the space, either a direction
  70064. * Reminder: js uses a left handed forward facing system
  70065. */
  70066. export class Vector3 {
  70067. /**
  70068. * Defines the first coordinates (on X axis)
  70069. */
  70070. x: number;
  70071. /**
  70072. * Defines the second coordinates (on Y axis)
  70073. */
  70074. y: number;
  70075. /**
  70076. * Defines the third coordinates (on Z axis)
  70077. */
  70078. z: number;
  70079. private static _UpReadOnly;
  70080. private static _ZeroReadOnly;
  70081. /**
  70082. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70083. * @param x defines the first coordinates (on X axis)
  70084. * @param y defines the second coordinates (on Y axis)
  70085. * @param z defines the third coordinates (on Z axis)
  70086. */
  70087. constructor(
  70088. /**
  70089. * Defines the first coordinates (on X axis)
  70090. */
  70091. x?: number,
  70092. /**
  70093. * Defines the second coordinates (on Y axis)
  70094. */
  70095. y?: number,
  70096. /**
  70097. * Defines the third coordinates (on Z axis)
  70098. */
  70099. z?: number);
  70100. /**
  70101. * Creates a string representation of the Vector3
  70102. * @returns a string with the Vector3 coordinates.
  70103. */
  70104. toString(): string;
  70105. /**
  70106. * Gets the class name
  70107. * @returns the string "Vector3"
  70108. */
  70109. getClassName(): string;
  70110. /**
  70111. * Creates the Vector3 hash code
  70112. * @returns a number which tends to be unique between Vector3 instances
  70113. */
  70114. getHashCode(): number;
  70115. /**
  70116. * Creates an array containing three elements : the coordinates of the Vector3
  70117. * @returns a new array of numbers
  70118. */
  70119. asArray(): number[];
  70120. /**
  70121. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70122. * @param array defines the destination array
  70123. * @param index defines the offset in the destination array
  70124. * @returns the current Vector3
  70125. */
  70126. toArray(array: FloatArray, index?: number): Vector3;
  70127. /**
  70128. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70129. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70130. */
  70131. toQuaternion(): Quaternion;
  70132. /**
  70133. * Adds the given vector to the current Vector3
  70134. * @param otherVector defines the second operand
  70135. * @returns the current updated Vector3
  70136. */
  70137. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70138. /**
  70139. * Adds the given coordinates to the current Vector3
  70140. * @param x defines the x coordinate of the operand
  70141. * @param y defines the y coordinate of the operand
  70142. * @param z defines the z coordinate of the operand
  70143. * @returns the current updated Vector3
  70144. */
  70145. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70146. /**
  70147. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70148. * @param otherVector defines the second operand
  70149. * @returns the resulting Vector3
  70150. */
  70151. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70152. /**
  70153. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70154. * @param otherVector defines the second operand
  70155. * @param result defines the Vector3 object where to store the result
  70156. * @returns the current Vector3
  70157. */
  70158. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70159. /**
  70160. * Subtract the given vector from the current Vector3
  70161. * @param otherVector defines the second operand
  70162. * @returns the current updated Vector3
  70163. */
  70164. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70165. /**
  70166. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70167. * @param otherVector defines the second operand
  70168. * @returns the resulting Vector3
  70169. */
  70170. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70171. /**
  70172. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70173. * @param otherVector defines the second operand
  70174. * @param result defines the Vector3 object where to store the result
  70175. * @returns the current Vector3
  70176. */
  70177. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70178. /**
  70179. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70180. * @param x defines the x coordinate of the operand
  70181. * @param y defines the y coordinate of the operand
  70182. * @param z defines the z coordinate of the operand
  70183. * @returns the resulting Vector3
  70184. */
  70185. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70186. /**
  70187. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70188. * @param x defines the x coordinate of the operand
  70189. * @param y defines the y coordinate of the operand
  70190. * @param z defines the z coordinate of the operand
  70191. * @param result defines the Vector3 object where to store the result
  70192. * @returns the current Vector3
  70193. */
  70194. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70195. /**
  70196. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70197. * @returns a new Vector3
  70198. */
  70199. negate(): Vector3;
  70200. /**
  70201. * Multiplies the Vector3 coordinates by the float "scale"
  70202. * @param scale defines the multiplier factor
  70203. * @returns the current updated Vector3
  70204. */
  70205. scaleInPlace(scale: number): Vector3;
  70206. /**
  70207. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70208. * @param scale defines the multiplier factor
  70209. * @returns a new Vector3
  70210. */
  70211. scale(scale: number): Vector3;
  70212. /**
  70213. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70214. * @param scale defines the multiplier factor
  70215. * @param result defines the Vector3 object where to store the result
  70216. * @returns the current Vector3
  70217. */
  70218. scaleToRef(scale: number, result: Vector3): Vector3;
  70219. /**
  70220. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70221. * @param scale defines the scale factor
  70222. * @param result defines the Vector3 object where to store the result
  70223. * @returns the unmodified current Vector3
  70224. */
  70225. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70226. /**
  70227. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70228. * @param otherVector defines the second operand
  70229. * @returns true if both vectors are equals
  70230. */
  70231. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70232. /**
  70233. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70234. * @param otherVector defines the second operand
  70235. * @param epsilon defines the minimal distance to define values as equals
  70236. * @returns true if both vectors are distant less than epsilon
  70237. */
  70238. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70239. /**
  70240. * Returns true if the current Vector3 coordinates equals the given floats
  70241. * @param x defines the x coordinate of the operand
  70242. * @param y defines the y coordinate of the operand
  70243. * @param z defines the z coordinate of the operand
  70244. * @returns true if both vectors are equals
  70245. */
  70246. equalsToFloats(x: number, y: number, z: number): boolean;
  70247. /**
  70248. * Multiplies the current Vector3 coordinates by the given ones
  70249. * @param otherVector defines the second operand
  70250. * @returns the current updated Vector3
  70251. */
  70252. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70253. /**
  70254. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70255. * @param otherVector defines the second operand
  70256. * @returns the new Vector3
  70257. */
  70258. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70259. /**
  70260. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70261. * @param otherVector defines the second operand
  70262. * @param result defines the Vector3 object where to store the result
  70263. * @returns the current Vector3
  70264. */
  70265. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70266. /**
  70267. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70268. * @param x defines the x coordinate of the operand
  70269. * @param y defines the y coordinate of the operand
  70270. * @param z defines the z coordinate of the operand
  70271. * @returns the new Vector3
  70272. */
  70273. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70274. /**
  70275. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70276. * @param otherVector defines the second operand
  70277. * @returns the new Vector3
  70278. */
  70279. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70280. /**
  70281. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70282. * @param otherVector defines the second operand
  70283. * @param result defines the Vector3 object where to store the result
  70284. * @returns the current Vector3
  70285. */
  70286. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70287. /**
  70288. * Divides the current Vector3 coordinates by the given ones.
  70289. * @param otherVector defines the second operand
  70290. * @returns the current updated Vector3
  70291. */
  70292. divideInPlace(otherVector: Vector3): Vector3;
  70293. /**
  70294. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70295. * @param other defines the second operand
  70296. * @returns the current updated Vector3
  70297. */
  70298. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70299. /**
  70300. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70301. * @param other defines the second operand
  70302. * @returns the current updated Vector3
  70303. */
  70304. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70305. /**
  70306. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70307. * @param x defines the x coordinate of the operand
  70308. * @param y defines the y coordinate of the operand
  70309. * @param z defines the z coordinate of the operand
  70310. * @returns the current updated Vector3
  70311. */
  70312. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70313. /**
  70314. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70315. * @param x defines the x coordinate of the operand
  70316. * @param y defines the y coordinate of the operand
  70317. * @param z defines the z coordinate of the operand
  70318. * @returns the current updated Vector3
  70319. */
  70320. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70321. /**
  70322. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70323. * Check if is non uniform within a certain amount of decimal places to account for this
  70324. * @param epsilon the amount the values can differ
  70325. * @returns if the the vector is non uniform to a certain number of decimal places
  70326. */
  70327. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70328. /**
  70329. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70330. */
  70331. readonly isNonUniform: boolean;
  70332. /**
  70333. * Gets a new Vector3 from current Vector3 floored values
  70334. * @returns a new Vector3
  70335. */
  70336. floor(): Vector3;
  70337. /**
  70338. * Gets a new Vector3 from current Vector3 floored values
  70339. * @returns a new Vector3
  70340. */
  70341. fract(): Vector3;
  70342. /**
  70343. * Gets the length of the Vector3
  70344. * @returns the length of the Vector3
  70345. */
  70346. length(): number;
  70347. /**
  70348. * Gets the squared length of the Vector3
  70349. * @returns squared length of the Vector3
  70350. */
  70351. lengthSquared(): number;
  70352. /**
  70353. * Normalize the current Vector3.
  70354. * Please note that this is an in place operation.
  70355. * @returns the current updated Vector3
  70356. */
  70357. normalize(): Vector3;
  70358. /**
  70359. * Reorders the x y z properties of the vector in place
  70360. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70361. * @returns the current updated vector
  70362. */
  70363. reorderInPlace(order: string): this;
  70364. /**
  70365. * Rotates the vector around 0,0,0 by a quaternion
  70366. * @param quaternion the rotation quaternion
  70367. * @param result vector to store the result
  70368. * @returns the resulting vector
  70369. */
  70370. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70371. /**
  70372. * Rotates a vector around a given point
  70373. * @param quaternion the rotation quaternion
  70374. * @param point the point to rotate around
  70375. * @param result vector to store the result
  70376. * @returns the resulting vector
  70377. */
  70378. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70379. /**
  70380. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70381. * The cross product is then orthogonal to both current and "other"
  70382. * @param other defines the right operand
  70383. * @returns the cross product
  70384. */
  70385. cross(other: Vector3): Vector3;
  70386. /**
  70387. * Normalize the current Vector3 with the given input length.
  70388. * Please note that this is an in place operation.
  70389. * @param len the length of the vector
  70390. * @returns the current updated Vector3
  70391. */
  70392. normalizeFromLength(len: number): Vector3;
  70393. /**
  70394. * Normalize the current Vector3 to a new vector
  70395. * @returns the new Vector3
  70396. */
  70397. normalizeToNew(): Vector3;
  70398. /**
  70399. * Normalize the current Vector3 to the reference
  70400. * @param reference define the Vector3 to update
  70401. * @returns the updated Vector3
  70402. */
  70403. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70404. /**
  70405. * Creates a new Vector3 copied from the current Vector3
  70406. * @returns the new Vector3
  70407. */
  70408. clone(): Vector3;
  70409. /**
  70410. * Copies the given vector coordinates to the current Vector3 ones
  70411. * @param source defines the source Vector3
  70412. * @returns the current updated Vector3
  70413. */
  70414. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70415. /**
  70416. * Copies the given floats to the current Vector3 coordinates
  70417. * @param x defines the x coordinate of the operand
  70418. * @param y defines the y coordinate of the operand
  70419. * @param z defines the z coordinate of the operand
  70420. * @returns the current updated Vector3
  70421. */
  70422. copyFromFloats(x: number, y: number, z: number): Vector3;
  70423. /**
  70424. * Copies the given floats to the current Vector3 coordinates
  70425. * @param x defines the x coordinate of the operand
  70426. * @param y defines the y coordinate of the operand
  70427. * @param z defines the z coordinate of the operand
  70428. * @returns the current updated Vector3
  70429. */
  70430. set(x: number, y: number, z: number): Vector3;
  70431. /**
  70432. * Copies the given float to the current Vector3 coordinates
  70433. * @param v defines the x, y and z coordinates of the operand
  70434. * @returns the current updated Vector3
  70435. */
  70436. setAll(v: number): Vector3;
  70437. /**
  70438. * Get the clip factor between two vectors
  70439. * @param vector0 defines the first operand
  70440. * @param vector1 defines the second operand
  70441. * @param axis defines the axis to use
  70442. * @param size defines the size along the axis
  70443. * @returns the clip factor
  70444. */
  70445. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70446. /**
  70447. * Get angle between two vectors
  70448. * @param vector0 angle between vector0 and vector1
  70449. * @param vector1 angle between vector0 and vector1
  70450. * @param normal direction of the normal
  70451. * @return the angle between vector0 and vector1
  70452. */
  70453. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70454. /**
  70455. * Returns a new Vector3 set from the index "offset" of the given array
  70456. * @param array defines the source array
  70457. * @param offset defines the offset in the source array
  70458. * @returns the new Vector3
  70459. */
  70460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70461. /**
  70462. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70463. * This function is deprecated. Use FromArray instead
  70464. * @param array defines the source array
  70465. * @param offset defines the offset in the source array
  70466. * @returns the new Vector3
  70467. */
  70468. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70469. /**
  70470. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70471. * @param array defines the source array
  70472. * @param offset defines the offset in the source array
  70473. * @param result defines the Vector3 where to store the result
  70474. */
  70475. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70476. /**
  70477. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70478. * This function is deprecated. Use FromArrayToRef instead.
  70479. * @param array defines the source array
  70480. * @param offset defines the offset in the source array
  70481. * @param result defines the Vector3 where to store the result
  70482. */
  70483. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70484. /**
  70485. * Sets the given vector "result" with the given floats.
  70486. * @param x defines the x coordinate of the source
  70487. * @param y defines the y coordinate of the source
  70488. * @param z defines the z coordinate of the source
  70489. * @param result defines the Vector3 where to store the result
  70490. */
  70491. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70492. /**
  70493. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70494. * @returns a new empty Vector3
  70495. */
  70496. static Zero(): Vector3;
  70497. /**
  70498. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70499. * @returns a new unit Vector3
  70500. */
  70501. static One(): Vector3;
  70502. /**
  70503. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70504. * @returns a new up Vector3
  70505. */
  70506. static Up(): Vector3;
  70507. /**
  70508. * Gets a up Vector3 that must not be updated
  70509. */
  70510. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70511. /**
  70512. * Gets a zero Vector3 that must not be updated
  70513. */
  70514. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70515. /**
  70516. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70517. * @returns a new down Vector3
  70518. */
  70519. static Down(): Vector3;
  70520. /**
  70521. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70522. * @returns a new forward Vector3
  70523. */
  70524. static Forward(): Vector3;
  70525. /**
  70526. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70527. * @returns a new forward Vector3
  70528. */
  70529. static Backward(): Vector3;
  70530. /**
  70531. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70532. * @returns a new right Vector3
  70533. */
  70534. static Right(): Vector3;
  70535. /**
  70536. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70537. * @returns a new left Vector3
  70538. */
  70539. static Left(): Vector3;
  70540. /**
  70541. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70542. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70543. * @param vector defines the Vector3 to transform
  70544. * @param transformation defines the transformation matrix
  70545. * @returns the transformed Vector3
  70546. */
  70547. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70548. /**
  70549. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70550. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70551. * @param vector defines the Vector3 to transform
  70552. * @param transformation defines the transformation matrix
  70553. * @param result defines the Vector3 where to store the result
  70554. */
  70555. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70556. /**
  70557. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70558. * This method computes tranformed coordinates only, not transformed direction vectors
  70559. * @param x define the x coordinate of the source vector
  70560. * @param y define the y coordinate of the source vector
  70561. * @param z define the z coordinate of the source vector
  70562. * @param transformation defines the transformation matrix
  70563. * @param result defines the Vector3 where to store the result
  70564. */
  70565. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70566. /**
  70567. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70568. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70569. * @param vector defines the Vector3 to transform
  70570. * @param transformation defines the transformation matrix
  70571. * @returns the new Vector3
  70572. */
  70573. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70574. /**
  70575. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70576. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70577. * @param vector defines the Vector3 to transform
  70578. * @param transformation defines the transformation matrix
  70579. * @param result defines the Vector3 where to store the result
  70580. */
  70581. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70582. /**
  70583. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70584. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70585. * @param x define the x coordinate of the source vector
  70586. * @param y define the y coordinate of the source vector
  70587. * @param z define the z coordinate of the source vector
  70588. * @param transformation defines the transformation matrix
  70589. * @param result defines the Vector3 where to store the result
  70590. */
  70591. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70592. /**
  70593. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70594. * @param value1 defines the first control point
  70595. * @param value2 defines the second control point
  70596. * @param value3 defines the third control point
  70597. * @param value4 defines the fourth control point
  70598. * @param amount defines the amount on the spline to use
  70599. * @returns the new Vector3
  70600. */
  70601. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70602. /**
  70603. * 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"
  70604. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70605. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70606. * @param value defines the current value
  70607. * @param min defines the lower range value
  70608. * @param max defines the upper range value
  70609. * @returns the new Vector3
  70610. */
  70611. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70612. /**
  70613. * 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"
  70614. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70615. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70616. * @param value defines the current value
  70617. * @param min defines the lower range value
  70618. * @param max defines the upper range value
  70619. * @param result defines the Vector3 where to store the result
  70620. */
  70621. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70622. /**
  70623. * Checks if a given vector is inside a specific range
  70624. * @param v defines the vector to test
  70625. * @param min defines the minimum range
  70626. * @param max defines the maximum range
  70627. */
  70628. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70629. /**
  70630. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70631. * @param value1 defines the first control point
  70632. * @param tangent1 defines the first tangent vector
  70633. * @param value2 defines the second control point
  70634. * @param tangent2 defines the second tangent vector
  70635. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70636. * @returns the new Vector3
  70637. */
  70638. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70639. /**
  70640. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70641. * @param start defines the start value
  70642. * @param end defines the end value
  70643. * @param amount max defines amount between both (between 0 and 1)
  70644. * @returns the new Vector3
  70645. */
  70646. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70647. /**
  70648. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70649. * @param start defines the start value
  70650. * @param end defines the end value
  70651. * @param amount max defines amount between both (between 0 and 1)
  70652. * @param result defines the Vector3 where to store the result
  70653. */
  70654. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70655. /**
  70656. * Returns the dot product (float) between the vectors "left" and "right"
  70657. * @param left defines the left operand
  70658. * @param right defines the right operand
  70659. * @returns the dot product
  70660. */
  70661. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70662. /**
  70663. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70664. * The cross product is then orthogonal to both "left" and "right"
  70665. * @param left defines the left operand
  70666. * @param right defines the right operand
  70667. * @returns the cross product
  70668. */
  70669. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70670. /**
  70671. * Sets the given vector "result" with the cross product of "left" and "right"
  70672. * The cross product is then orthogonal to both "left" and "right"
  70673. * @param left defines the left operand
  70674. * @param right defines the right operand
  70675. * @param result defines the Vector3 where to store the result
  70676. */
  70677. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70678. /**
  70679. * Returns a new Vector3 as the normalization of the given vector
  70680. * @param vector defines the Vector3 to normalize
  70681. * @returns the new Vector3
  70682. */
  70683. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70684. /**
  70685. * Sets the given vector "result" with the normalization of the given first vector
  70686. * @param vector defines the Vector3 to normalize
  70687. * @param result defines the Vector3 where to store the result
  70688. */
  70689. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70690. /**
  70691. * Project a Vector3 onto screen space
  70692. * @param vector defines the Vector3 to project
  70693. * @param world defines the world matrix to use
  70694. * @param transform defines the transform (view x projection) matrix to use
  70695. * @param viewport defines the screen viewport to use
  70696. * @returns the new Vector3
  70697. */
  70698. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70699. /** @hidden */
  70700. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70701. /**
  70702. * Unproject from screen space to object space
  70703. * @param source defines the screen space Vector3 to use
  70704. * @param viewportWidth defines the current width of the viewport
  70705. * @param viewportHeight defines the current height of the viewport
  70706. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70707. * @param transform defines the transform (view x projection) matrix to use
  70708. * @returns the new Vector3
  70709. */
  70710. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70711. /**
  70712. * Unproject from screen space to object space
  70713. * @param source defines the screen space Vector3 to use
  70714. * @param viewportWidth defines the current width of the viewport
  70715. * @param viewportHeight defines the current height of the viewport
  70716. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70717. * @param view defines the view matrix to use
  70718. * @param projection defines the projection matrix to use
  70719. * @returns the new Vector3
  70720. */
  70721. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70722. /**
  70723. * Unproject from screen space to object space
  70724. * @param source defines the screen space Vector3 to use
  70725. * @param viewportWidth defines the current width of the viewport
  70726. * @param viewportHeight defines the current height of the viewport
  70727. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70728. * @param view defines the view matrix to use
  70729. * @param projection defines the projection matrix to use
  70730. * @param result defines the Vector3 where to store the result
  70731. */
  70732. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70733. /**
  70734. * Unproject from screen space to object space
  70735. * @param sourceX defines the screen space x coordinate to use
  70736. * @param sourceY defines the screen space y coordinate to use
  70737. * @param sourceZ defines the screen space z coordinate to use
  70738. * @param viewportWidth defines the current width of the viewport
  70739. * @param viewportHeight defines the current height of the viewport
  70740. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70741. * @param view defines the view matrix to use
  70742. * @param projection defines the projection matrix to use
  70743. * @param result defines the Vector3 where to store the result
  70744. */
  70745. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70746. /**
  70747. * Gets the minimal coordinate values between two Vector3
  70748. * @param left defines the first operand
  70749. * @param right defines the second operand
  70750. * @returns the new Vector3
  70751. */
  70752. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70753. /**
  70754. * Gets the maximal coordinate values between two Vector3
  70755. * @param left defines the first operand
  70756. * @param right defines the second operand
  70757. * @returns the new Vector3
  70758. */
  70759. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70760. /**
  70761. * Returns the distance between the vectors "value1" and "value2"
  70762. * @param value1 defines the first operand
  70763. * @param value2 defines the second operand
  70764. * @returns the distance
  70765. */
  70766. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70767. /**
  70768. * Returns the squared distance between the vectors "value1" and "value2"
  70769. * @param value1 defines the first operand
  70770. * @param value2 defines the second operand
  70771. * @returns the squared distance
  70772. */
  70773. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70774. /**
  70775. * Returns a new Vector3 located at the center between "value1" and "value2"
  70776. * @param value1 defines the first operand
  70777. * @param value2 defines the second operand
  70778. * @returns the new Vector3
  70779. */
  70780. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70781. /**
  70782. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70783. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70784. * to something in order to rotate it from its local system to the given target system
  70785. * Note: axis1, axis2 and axis3 are normalized during this operation
  70786. * @param axis1 defines the first axis
  70787. * @param axis2 defines the second axis
  70788. * @param axis3 defines the third axis
  70789. * @returns a new Vector3
  70790. */
  70791. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70792. /**
  70793. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70794. * @param axis1 defines the first axis
  70795. * @param axis2 defines the second axis
  70796. * @param axis3 defines the third axis
  70797. * @param ref defines the Vector3 where to store the result
  70798. */
  70799. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70800. }
  70801. /**
  70802. * Vector4 class created for EulerAngle class conversion to Quaternion
  70803. */
  70804. export class Vector4 {
  70805. /** x value of the vector */
  70806. x: number;
  70807. /** y value of the vector */
  70808. y: number;
  70809. /** z value of the vector */
  70810. z: number;
  70811. /** w value of the vector */
  70812. w: number;
  70813. /**
  70814. * Creates a Vector4 object from the given floats.
  70815. * @param x x value of the vector
  70816. * @param y y value of the vector
  70817. * @param z z value of the vector
  70818. * @param w w value of the vector
  70819. */
  70820. constructor(
  70821. /** x value of the vector */
  70822. x: number,
  70823. /** y value of the vector */
  70824. y: number,
  70825. /** z value of the vector */
  70826. z: number,
  70827. /** w value of the vector */
  70828. w: number);
  70829. /**
  70830. * Returns the string with the Vector4 coordinates.
  70831. * @returns a string containing all the vector values
  70832. */
  70833. toString(): string;
  70834. /**
  70835. * Returns the string "Vector4".
  70836. * @returns "Vector4"
  70837. */
  70838. getClassName(): string;
  70839. /**
  70840. * Returns the Vector4 hash code.
  70841. * @returns a unique hash code
  70842. */
  70843. getHashCode(): number;
  70844. /**
  70845. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70846. * @returns the resulting array
  70847. */
  70848. asArray(): number[];
  70849. /**
  70850. * Populates the given array from the given index with the Vector4 coordinates.
  70851. * @param array array to populate
  70852. * @param index index of the array to start at (default: 0)
  70853. * @returns the Vector4.
  70854. */
  70855. toArray(array: FloatArray, index?: number): Vector4;
  70856. /**
  70857. * Adds the given vector to the current Vector4.
  70858. * @param otherVector the vector to add
  70859. * @returns the updated Vector4.
  70860. */
  70861. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70862. /**
  70863. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70864. * @param otherVector the vector to add
  70865. * @returns the resulting vector
  70866. */
  70867. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70868. /**
  70869. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70870. * @param otherVector the vector to add
  70871. * @param result the vector to store the result
  70872. * @returns the current Vector4.
  70873. */
  70874. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70875. /**
  70876. * Subtract in place the given vector from the current Vector4.
  70877. * @param otherVector the vector to subtract
  70878. * @returns the updated Vector4.
  70879. */
  70880. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70881. /**
  70882. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70883. * @param otherVector the vector to add
  70884. * @returns the new vector with the result
  70885. */
  70886. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70887. /**
  70888. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70889. * @param otherVector the vector to subtract
  70890. * @param result the vector to store the result
  70891. * @returns the current Vector4.
  70892. */
  70893. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70894. /**
  70895. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70896. */
  70897. /**
  70898. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70899. * @param x value to subtract
  70900. * @param y value to subtract
  70901. * @param z value to subtract
  70902. * @param w value to subtract
  70903. * @returns new vector containing the result
  70904. */
  70905. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70906. /**
  70907. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70908. * @param x value to subtract
  70909. * @param y value to subtract
  70910. * @param z value to subtract
  70911. * @param w value to subtract
  70912. * @param result the vector to store the result in
  70913. * @returns the current Vector4.
  70914. */
  70915. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70916. /**
  70917. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70918. * @returns a new vector with the negated values
  70919. */
  70920. negate(): Vector4;
  70921. /**
  70922. * Multiplies the current Vector4 coordinates by scale (float).
  70923. * @param scale the number to scale with
  70924. * @returns the updated Vector4.
  70925. */
  70926. scaleInPlace(scale: number): Vector4;
  70927. /**
  70928. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70929. * @param scale the number to scale with
  70930. * @returns a new vector with the result
  70931. */
  70932. scale(scale: number): Vector4;
  70933. /**
  70934. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70935. * @param scale the number to scale with
  70936. * @param result a vector to store the result in
  70937. * @returns the current Vector4.
  70938. */
  70939. scaleToRef(scale: number, result: Vector4): Vector4;
  70940. /**
  70941. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70942. * @param scale defines the scale factor
  70943. * @param result defines the Vector4 object where to store the result
  70944. * @returns the unmodified current Vector4
  70945. */
  70946. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70947. /**
  70948. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70949. * @param otherVector the vector to compare against
  70950. * @returns true if they are equal
  70951. */
  70952. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70953. /**
  70954. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70955. * @param otherVector vector to compare against
  70956. * @param epsilon (Default: very small number)
  70957. * @returns true if they are equal
  70958. */
  70959. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70960. /**
  70961. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70962. * @param x x value to compare against
  70963. * @param y y value to compare against
  70964. * @param z z value to compare against
  70965. * @param w w value to compare against
  70966. * @returns true if equal
  70967. */
  70968. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70969. /**
  70970. * Multiplies in place the current Vector4 by the given one.
  70971. * @param otherVector vector to multiple with
  70972. * @returns the updated Vector4.
  70973. */
  70974. multiplyInPlace(otherVector: Vector4): Vector4;
  70975. /**
  70976. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70977. * @param otherVector vector to multiple with
  70978. * @returns resulting new vector
  70979. */
  70980. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70981. /**
  70982. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70983. * @param otherVector vector to multiple with
  70984. * @param result vector to store the result
  70985. * @returns the current Vector4.
  70986. */
  70987. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70988. /**
  70989. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70990. * @param x x value multiply with
  70991. * @param y y value multiply with
  70992. * @param z z value multiply with
  70993. * @param w w value multiply with
  70994. * @returns resulting new vector
  70995. */
  70996. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70997. /**
  70998. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70999. * @param otherVector vector to devide with
  71000. * @returns resulting new vector
  71001. */
  71002. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71003. /**
  71004. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71005. * @param otherVector vector to devide with
  71006. * @param result vector to store the result
  71007. * @returns the current Vector4.
  71008. */
  71009. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71010. /**
  71011. * Divides the current Vector3 coordinates by the given ones.
  71012. * @param otherVector vector to devide with
  71013. * @returns the updated Vector3.
  71014. */
  71015. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71016. /**
  71017. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71018. * @param other defines the second operand
  71019. * @returns the current updated Vector4
  71020. */
  71021. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71022. /**
  71023. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71024. * @param other defines the second operand
  71025. * @returns the current updated Vector4
  71026. */
  71027. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71028. /**
  71029. * Gets a new Vector4 from current Vector4 floored values
  71030. * @returns a new Vector4
  71031. */
  71032. floor(): Vector4;
  71033. /**
  71034. * Gets a new Vector4 from current Vector3 floored values
  71035. * @returns a new Vector4
  71036. */
  71037. fract(): Vector4;
  71038. /**
  71039. * Returns the Vector4 length (float).
  71040. * @returns the length
  71041. */
  71042. length(): number;
  71043. /**
  71044. * Returns the Vector4 squared length (float).
  71045. * @returns the length squared
  71046. */
  71047. lengthSquared(): number;
  71048. /**
  71049. * Normalizes in place the Vector4.
  71050. * @returns the updated Vector4.
  71051. */
  71052. normalize(): Vector4;
  71053. /**
  71054. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71055. * @returns this converted to a new vector3
  71056. */
  71057. toVector3(): Vector3;
  71058. /**
  71059. * Returns a new Vector4 copied from the current one.
  71060. * @returns the new cloned vector
  71061. */
  71062. clone(): Vector4;
  71063. /**
  71064. * Updates the current Vector4 with the given one coordinates.
  71065. * @param source the source vector to copy from
  71066. * @returns the updated Vector4.
  71067. */
  71068. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71069. /**
  71070. * Updates the current Vector4 coordinates with the given floats.
  71071. * @param x float to copy from
  71072. * @param y float to copy from
  71073. * @param z float to copy from
  71074. * @param w float to copy from
  71075. * @returns the updated Vector4.
  71076. */
  71077. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71078. /**
  71079. * Updates the current Vector4 coordinates with the given floats.
  71080. * @param x float to set from
  71081. * @param y float to set from
  71082. * @param z float to set from
  71083. * @param w float to set from
  71084. * @returns the updated Vector4.
  71085. */
  71086. set(x: number, y: number, z: number, w: number): Vector4;
  71087. /**
  71088. * Copies the given float to the current Vector3 coordinates
  71089. * @param v defines the x, y, z and w coordinates of the operand
  71090. * @returns the current updated Vector3
  71091. */
  71092. setAll(v: number): Vector4;
  71093. /**
  71094. * Returns a new Vector4 set from the starting index of the given array.
  71095. * @param array the array to pull values from
  71096. * @param offset the offset into the array to start at
  71097. * @returns the new vector
  71098. */
  71099. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71100. /**
  71101. * Updates the given vector "result" from the starting index of the given array.
  71102. * @param array the array to pull values from
  71103. * @param offset the offset into the array to start at
  71104. * @param result the vector to store the result in
  71105. */
  71106. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71107. /**
  71108. * Updates the given vector "result" from the starting index of the given Float32Array.
  71109. * @param array the array to pull values from
  71110. * @param offset the offset into the array to start at
  71111. * @param result the vector to store the result in
  71112. */
  71113. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71114. /**
  71115. * Updates the given vector "result" coordinates from the given floats.
  71116. * @param x float to set from
  71117. * @param y float to set from
  71118. * @param z float to set from
  71119. * @param w float to set from
  71120. * @param result the vector to the floats in
  71121. */
  71122. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71123. /**
  71124. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71125. * @returns the new vector
  71126. */
  71127. static Zero(): Vector4;
  71128. /**
  71129. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71130. * @returns the new vector
  71131. */
  71132. static One(): Vector4;
  71133. /**
  71134. * Returns a new normalized Vector4 from the given one.
  71135. * @param vector the vector to normalize
  71136. * @returns the vector
  71137. */
  71138. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71139. /**
  71140. * Updates the given vector "result" from the normalization of the given one.
  71141. * @param vector the vector to normalize
  71142. * @param result the vector to store the result in
  71143. */
  71144. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71145. /**
  71146. * Returns a vector with the minimum values from the left and right vectors
  71147. * @param left left vector to minimize
  71148. * @param right right vector to minimize
  71149. * @returns a new vector with the minimum of the left and right vector values
  71150. */
  71151. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71152. /**
  71153. * Returns a vector with the maximum values from the left and right vectors
  71154. * @param left left vector to maximize
  71155. * @param right right vector to maximize
  71156. * @returns a new vector with the maximum of the left and right vector values
  71157. */
  71158. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71159. /**
  71160. * Returns the distance (float) between the vectors "value1" and "value2".
  71161. * @param value1 value to calulate the distance between
  71162. * @param value2 value to calulate the distance between
  71163. * @return the distance between the two vectors
  71164. */
  71165. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71166. /**
  71167. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71168. * @param value1 value to calulate the distance between
  71169. * @param value2 value to calulate the distance between
  71170. * @return the distance between the two vectors squared
  71171. */
  71172. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71173. /**
  71174. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71175. * @param value1 value to calulate the center between
  71176. * @param value2 value to calulate the center between
  71177. * @return the center between the two vectors
  71178. */
  71179. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71180. /**
  71181. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71182. * This methods computes transformed normalized direction vectors only.
  71183. * @param vector the vector to transform
  71184. * @param transformation the transformation matrix to apply
  71185. * @returns the new vector
  71186. */
  71187. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71188. /**
  71189. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71190. * This methods computes transformed normalized direction vectors only.
  71191. * @param vector the vector to transform
  71192. * @param transformation the transformation matrix to apply
  71193. * @param result the vector to store the result in
  71194. */
  71195. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71196. /**
  71197. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71198. * This methods computes transformed normalized direction vectors only.
  71199. * @param x value to transform
  71200. * @param y value to transform
  71201. * @param z value to transform
  71202. * @param w value to transform
  71203. * @param transformation the transformation matrix to apply
  71204. * @param result the vector to store the results in
  71205. */
  71206. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71207. /**
  71208. * Creates a new Vector4 from a Vector3
  71209. * @param source defines the source data
  71210. * @param w defines the 4th component (default is 0)
  71211. * @returns a new Vector4
  71212. */
  71213. static FromVector3(source: Vector3, w?: number): Vector4;
  71214. }
  71215. /**
  71216. * Class used to store quaternion data
  71217. * @see https://en.wikipedia.org/wiki/Quaternion
  71218. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71219. */
  71220. export class Quaternion {
  71221. /** defines the first component (0 by default) */
  71222. x: number;
  71223. /** defines the second component (0 by default) */
  71224. y: number;
  71225. /** defines the third component (0 by default) */
  71226. z: number;
  71227. /** defines the fourth component (1.0 by default) */
  71228. w: number;
  71229. /**
  71230. * Creates a new Quaternion from the given floats
  71231. * @param x defines the first component (0 by default)
  71232. * @param y defines the second component (0 by default)
  71233. * @param z defines the third component (0 by default)
  71234. * @param w defines the fourth component (1.0 by default)
  71235. */
  71236. constructor(
  71237. /** defines the first component (0 by default) */
  71238. x?: number,
  71239. /** defines the second component (0 by default) */
  71240. y?: number,
  71241. /** defines the third component (0 by default) */
  71242. z?: number,
  71243. /** defines the fourth component (1.0 by default) */
  71244. w?: number);
  71245. /**
  71246. * Gets a string representation for the current quaternion
  71247. * @returns a string with the Quaternion coordinates
  71248. */
  71249. toString(): string;
  71250. /**
  71251. * Gets the class name of the quaternion
  71252. * @returns the string "Quaternion"
  71253. */
  71254. getClassName(): string;
  71255. /**
  71256. * Gets a hash code for this quaternion
  71257. * @returns the quaternion hash code
  71258. */
  71259. getHashCode(): number;
  71260. /**
  71261. * Copy the quaternion to an array
  71262. * @returns a new array populated with 4 elements from the quaternion coordinates
  71263. */
  71264. asArray(): number[];
  71265. /**
  71266. * Check if two quaternions are equals
  71267. * @param otherQuaternion defines the second operand
  71268. * @return true if the current quaternion and the given one coordinates are strictly equals
  71269. */
  71270. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71271. /**
  71272. * Clone the current quaternion
  71273. * @returns a new quaternion copied from the current one
  71274. */
  71275. clone(): Quaternion;
  71276. /**
  71277. * Copy a quaternion to the current one
  71278. * @param other defines the other quaternion
  71279. * @returns the updated current quaternion
  71280. */
  71281. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71282. /**
  71283. * Updates the current quaternion with the given float coordinates
  71284. * @param x defines the x coordinate
  71285. * @param y defines the y coordinate
  71286. * @param z defines the z coordinate
  71287. * @param w defines the w coordinate
  71288. * @returns the updated current quaternion
  71289. */
  71290. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71291. /**
  71292. * Updates the current quaternion from the given float coordinates
  71293. * @param x defines the x coordinate
  71294. * @param y defines the y coordinate
  71295. * @param z defines the z coordinate
  71296. * @param w defines the w coordinate
  71297. * @returns the updated current quaternion
  71298. */
  71299. set(x: number, y: number, z: number, w: number): Quaternion;
  71300. /**
  71301. * Adds two quaternions
  71302. * @param other defines the second operand
  71303. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71304. */
  71305. add(other: DeepImmutable<Quaternion>): Quaternion;
  71306. /**
  71307. * Add a quaternion to the current one
  71308. * @param other defines the quaternion to add
  71309. * @returns the current quaternion
  71310. */
  71311. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71312. /**
  71313. * Subtract two quaternions
  71314. * @param other defines the second operand
  71315. * @returns a new quaternion as the subtraction result of the given one from the current one
  71316. */
  71317. subtract(other: Quaternion): Quaternion;
  71318. /**
  71319. * Multiplies the current quaternion by a scale factor
  71320. * @param value defines the scale factor
  71321. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71322. */
  71323. scale(value: number): Quaternion;
  71324. /**
  71325. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71326. * @param scale defines the scale factor
  71327. * @param result defines the Quaternion object where to store the result
  71328. * @returns the unmodified current quaternion
  71329. */
  71330. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71331. /**
  71332. * Multiplies in place the current quaternion by a scale factor
  71333. * @param value defines the scale factor
  71334. * @returns the current modified quaternion
  71335. */
  71336. scaleInPlace(value: number): Quaternion;
  71337. /**
  71338. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71339. * @param scale defines the scale factor
  71340. * @param result defines the Quaternion object where to store the result
  71341. * @returns the unmodified current quaternion
  71342. */
  71343. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71344. /**
  71345. * Multiplies two quaternions
  71346. * @param q1 defines the second operand
  71347. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71348. */
  71349. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71350. /**
  71351. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71352. * @param q1 defines the second operand
  71353. * @param result defines the target quaternion
  71354. * @returns the current quaternion
  71355. */
  71356. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71357. /**
  71358. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71359. * @param q1 defines the second operand
  71360. * @returns the currentupdated quaternion
  71361. */
  71362. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71363. /**
  71364. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71365. * @param ref defines the target quaternion
  71366. * @returns the current quaternion
  71367. */
  71368. conjugateToRef(ref: Quaternion): Quaternion;
  71369. /**
  71370. * Conjugates in place (1-q) the current quaternion
  71371. * @returns the current updated quaternion
  71372. */
  71373. conjugateInPlace(): Quaternion;
  71374. /**
  71375. * Conjugates in place (1-q) the current quaternion
  71376. * @returns a new quaternion
  71377. */
  71378. conjugate(): Quaternion;
  71379. /**
  71380. * Gets length of current quaternion
  71381. * @returns the quaternion length (float)
  71382. */
  71383. length(): number;
  71384. /**
  71385. * Normalize in place the current quaternion
  71386. * @returns the current updated quaternion
  71387. */
  71388. normalize(): Quaternion;
  71389. /**
  71390. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71391. * @param order is a reserved parameter and is ignore for now
  71392. * @returns a new Vector3 containing the Euler angles
  71393. */
  71394. toEulerAngles(order?: string): Vector3;
  71395. /**
  71396. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71397. * @param result defines the vector which will be filled with the Euler angles
  71398. * @param order is a reserved parameter and is ignore for now
  71399. * @returns the current unchanged quaternion
  71400. */
  71401. toEulerAnglesToRef(result: Vector3): Quaternion;
  71402. /**
  71403. * Updates the given rotation matrix with the current quaternion values
  71404. * @param result defines the target matrix
  71405. * @returns the current unchanged quaternion
  71406. */
  71407. toRotationMatrix(result: Matrix): Quaternion;
  71408. /**
  71409. * Updates the current quaternion from the given rotation matrix values
  71410. * @param matrix defines the source matrix
  71411. * @returns the current updated quaternion
  71412. */
  71413. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71414. /**
  71415. * Creates a new quaternion from a rotation matrix
  71416. * @param matrix defines the source matrix
  71417. * @returns a new quaternion created from the given rotation matrix values
  71418. */
  71419. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71420. /**
  71421. * Updates the given quaternion with the given rotation matrix values
  71422. * @param matrix defines the source matrix
  71423. * @param result defines the target quaternion
  71424. */
  71425. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71426. /**
  71427. * Returns the dot product (float) between the quaternions "left" and "right"
  71428. * @param left defines the left operand
  71429. * @param right defines the right operand
  71430. * @returns the dot product
  71431. */
  71432. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71433. /**
  71434. * Checks if the two quaternions are close to each other
  71435. * @param quat0 defines the first quaternion to check
  71436. * @param quat1 defines the second quaternion to check
  71437. * @returns true if the two quaternions are close to each other
  71438. */
  71439. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71440. /**
  71441. * Creates an empty quaternion
  71442. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71443. */
  71444. static Zero(): Quaternion;
  71445. /**
  71446. * Inverse a given quaternion
  71447. * @param q defines the source quaternion
  71448. * @returns a new quaternion as the inverted current quaternion
  71449. */
  71450. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71451. /**
  71452. * Inverse a given quaternion
  71453. * @param q defines the source quaternion
  71454. * @param result the quaternion the result will be stored in
  71455. * @returns the result quaternion
  71456. */
  71457. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71458. /**
  71459. * Creates an identity quaternion
  71460. * @returns the identity quaternion
  71461. */
  71462. static Identity(): Quaternion;
  71463. /**
  71464. * Gets a boolean indicating if the given quaternion is identity
  71465. * @param quaternion defines the quaternion to check
  71466. * @returns true if the quaternion is identity
  71467. */
  71468. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71469. /**
  71470. * Creates a quaternion from a rotation around an axis
  71471. * @param axis defines the axis to use
  71472. * @param angle defines the angle to use
  71473. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71474. */
  71475. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71476. /**
  71477. * Creates a rotation around an axis and stores it into the given quaternion
  71478. * @param axis defines the axis to use
  71479. * @param angle defines the angle to use
  71480. * @param result defines the target quaternion
  71481. * @returns the target quaternion
  71482. */
  71483. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71484. /**
  71485. * Creates a new quaternion from data stored into an array
  71486. * @param array defines the data source
  71487. * @param offset defines the offset in the source array where the data starts
  71488. * @returns a new quaternion
  71489. */
  71490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71491. /**
  71492. * Create a quaternion from Euler rotation angles
  71493. * @param x Pitch
  71494. * @param y Yaw
  71495. * @param z Roll
  71496. * @returns the new Quaternion
  71497. */
  71498. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71499. /**
  71500. * Updates a quaternion from Euler rotation angles
  71501. * @param x Pitch
  71502. * @param y Yaw
  71503. * @param z Roll
  71504. * @param result the quaternion to store the result
  71505. * @returns the updated quaternion
  71506. */
  71507. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71508. /**
  71509. * Create a quaternion from Euler rotation vector
  71510. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71511. * @returns the new Quaternion
  71512. */
  71513. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71514. /**
  71515. * Updates a quaternion from Euler rotation vector
  71516. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71517. * @param result the quaternion to store the result
  71518. * @returns the updated quaternion
  71519. */
  71520. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71521. /**
  71522. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71523. * @param yaw defines the rotation around Y axis
  71524. * @param pitch defines the rotation around X axis
  71525. * @param roll defines the rotation around Z axis
  71526. * @returns the new quaternion
  71527. */
  71528. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71529. /**
  71530. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71531. * @param yaw defines the rotation around Y axis
  71532. * @param pitch defines the rotation around X axis
  71533. * @param roll defines the rotation around Z axis
  71534. * @param result defines the target quaternion
  71535. */
  71536. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71537. /**
  71538. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71539. * @param alpha defines the rotation around first axis
  71540. * @param beta defines the rotation around second axis
  71541. * @param gamma defines the rotation around third axis
  71542. * @returns the new quaternion
  71543. */
  71544. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71545. /**
  71546. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71547. * @param alpha defines the rotation around first axis
  71548. * @param beta defines the rotation around second axis
  71549. * @param gamma defines the rotation around third axis
  71550. * @param result defines the target quaternion
  71551. */
  71552. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71553. /**
  71554. * 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)
  71555. * @param axis1 defines the first axis
  71556. * @param axis2 defines the second axis
  71557. * @param axis3 defines the third axis
  71558. * @returns the new quaternion
  71559. */
  71560. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71561. /**
  71562. * 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
  71563. * @param axis1 defines the first axis
  71564. * @param axis2 defines the second axis
  71565. * @param axis3 defines the third axis
  71566. * @param ref defines the target quaternion
  71567. */
  71568. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71569. /**
  71570. * Interpolates between two quaternions
  71571. * @param left defines first quaternion
  71572. * @param right defines second quaternion
  71573. * @param amount defines the gradient to use
  71574. * @returns the new interpolated quaternion
  71575. */
  71576. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71577. /**
  71578. * Interpolates between two quaternions and stores it into a target quaternion
  71579. * @param left defines first quaternion
  71580. * @param right defines second quaternion
  71581. * @param amount defines the gradient to use
  71582. * @param result defines the target quaternion
  71583. */
  71584. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71585. /**
  71586. * Interpolate between two quaternions using Hermite interpolation
  71587. * @param value1 defines first quaternion
  71588. * @param tangent1 defines the incoming tangent
  71589. * @param value2 defines second quaternion
  71590. * @param tangent2 defines the outgoing tangent
  71591. * @param amount defines the target quaternion
  71592. * @returns the new interpolated quaternion
  71593. */
  71594. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71595. }
  71596. /**
  71597. * Class used to store matrix data (4x4)
  71598. */
  71599. export class Matrix {
  71600. private static _updateFlagSeed;
  71601. private static _identityReadOnly;
  71602. private _isIdentity;
  71603. private _isIdentityDirty;
  71604. private _isIdentity3x2;
  71605. private _isIdentity3x2Dirty;
  71606. /**
  71607. * Gets the update flag of the matrix which is an unique number for the matrix.
  71608. * It will be incremented every time the matrix data change.
  71609. * You can use it to speed the comparison between two versions of the same matrix.
  71610. */
  71611. updateFlag: number;
  71612. private readonly _m;
  71613. /**
  71614. * Gets the internal data of the matrix
  71615. */
  71616. readonly m: DeepImmutable<Float32Array>;
  71617. /** @hidden */
  71618. _markAsUpdated(): void;
  71619. /** @hidden */
  71620. private _updateIdentityStatus;
  71621. /**
  71622. * Creates an empty matrix (filled with zeros)
  71623. */
  71624. constructor();
  71625. /**
  71626. * Check if the current matrix is identity
  71627. * @returns true is the matrix is the identity matrix
  71628. */
  71629. isIdentity(): boolean;
  71630. /**
  71631. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71632. * @returns true is the matrix is the identity matrix
  71633. */
  71634. isIdentityAs3x2(): boolean;
  71635. /**
  71636. * Gets the determinant of the matrix
  71637. * @returns the matrix determinant
  71638. */
  71639. determinant(): number;
  71640. /**
  71641. * Returns the matrix as a Float32Array
  71642. * @returns the matrix underlying array
  71643. */
  71644. toArray(): DeepImmutable<Float32Array>;
  71645. /**
  71646. * Returns the matrix as a Float32Array
  71647. * @returns the matrix underlying array.
  71648. */
  71649. asArray(): DeepImmutable<Float32Array>;
  71650. /**
  71651. * Inverts the current matrix in place
  71652. * @returns the current inverted matrix
  71653. */
  71654. invert(): Matrix;
  71655. /**
  71656. * Sets all the matrix elements to zero
  71657. * @returns the current matrix
  71658. */
  71659. reset(): Matrix;
  71660. /**
  71661. * Adds the current matrix with a second one
  71662. * @param other defines the matrix to add
  71663. * @returns a new matrix as the addition of the current matrix and the given one
  71664. */
  71665. add(other: DeepImmutable<Matrix>): Matrix;
  71666. /**
  71667. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71668. * @param other defines the matrix to add
  71669. * @param result defines the target matrix
  71670. * @returns the current matrix
  71671. */
  71672. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71673. /**
  71674. * Adds in place the given matrix to the current matrix
  71675. * @param other defines the second operand
  71676. * @returns the current updated matrix
  71677. */
  71678. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71679. /**
  71680. * Sets the given matrix to the current inverted Matrix
  71681. * @param other defines the target matrix
  71682. * @returns the unmodified current matrix
  71683. */
  71684. invertToRef(other: Matrix): Matrix;
  71685. /**
  71686. * add a value at the specified position in the current Matrix
  71687. * @param index the index of the value within the matrix. between 0 and 15.
  71688. * @param value the value to be added
  71689. * @returns the current updated matrix
  71690. */
  71691. addAtIndex(index: number, value: number): Matrix;
  71692. /**
  71693. * mutiply the specified position in the current Matrix by a value
  71694. * @param index the index of the value within the matrix. between 0 and 15.
  71695. * @param value the value to be added
  71696. * @returns the current updated matrix
  71697. */
  71698. multiplyAtIndex(index: number, value: number): Matrix;
  71699. /**
  71700. * Inserts the translation vector (using 3 floats) in the current matrix
  71701. * @param x defines the 1st component of the translation
  71702. * @param y defines the 2nd component of the translation
  71703. * @param z defines the 3rd component of the translation
  71704. * @returns the current updated matrix
  71705. */
  71706. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71707. /**
  71708. * Adds the translation vector (using 3 floats) in the current matrix
  71709. * @param x defines the 1st component of the translation
  71710. * @param y defines the 2nd component of the translation
  71711. * @param z defines the 3rd component of the translation
  71712. * @returns the current updated matrix
  71713. */
  71714. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71715. /**
  71716. * Inserts the translation vector in the current matrix
  71717. * @param vector3 defines the translation to insert
  71718. * @returns the current updated matrix
  71719. */
  71720. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71721. /**
  71722. * Gets the translation value of the current matrix
  71723. * @returns a new Vector3 as the extracted translation from the matrix
  71724. */
  71725. getTranslation(): Vector3;
  71726. /**
  71727. * Fill a Vector3 with the extracted translation from the matrix
  71728. * @param result defines the Vector3 where to store the translation
  71729. * @returns the current matrix
  71730. */
  71731. getTranslationToRef(result: Vector3): Matrix;
  71732. /**
  71733. * Remove rotation and scaling part from the matrix
  71734. * @returns the updated matrix
  71735. */
  71736. removeRotationAndScaling(): Matrix;
  71737. /**
  71738. * Multiply two matrices
  71739. * @param other defines the second operand
  71740. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71741. */
  71742. multiply(other: DeepImmutable<Matrix>): Matrix;
  71743. /**
  71744. * Copy the current matrix from the given one
  71745. * @param other defines the source matrix
  71746. * @returns the current updated matrix
  71747. */
  71748. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71749. /**
  71750. * Populates the given array from the starting index with the current matrix values
  71751. * @param array defines the target array
  71752. * @param offset defines the offset in the target array where to start storing values
  71753. * @returns the current matrix
  71754. */
  71755. copyToArray(array: Float32Array, offset?: number): Matrix;
  71756. /**
  71757. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71758. * @param other defines the second operand
  71759. * @param result defines the matrix where to store the multiplication
  71760. * @returns the current matrix
  71761. */
  71762. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71763. /**
  71764. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71765. * @param other defines the second operand
  71766. * @param result defines the array where to store the multiplication
  71767. * @param offset defines the offset in the target array where to start storing values
  71768. * @returns the current matrix
  71769. */
  71770. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71771. /**
  71772. * Check equality between this matrix and a second one
  71773. * @param value defines the second matrix to compare
  71774. * @returns true is the current matrix and the given one values are strictly equal
  71775. */
  71776. equals(value: DeepImmutable<Matrix>): boolean;
  71777. /**
  71778. * Clone the current matrix
  71779. * @returns a new matrix from the current matrix
  71780. */
  71781. clone(): Matrix;
  71782. /**
  71783. * Returns the name of the current matrix class
  71784. * @returns the string "Matrix"
  71785. */
  71786. getClassName(): string;
  71787. /**
  71788. * Gets the hash code of the current matrix
  71789. * @returns the hash code
  71790. */
  71791. getHashCode(): number;
  71792. /**
  71793. * Decomposes the current Matrix into a translation, rotation and scaling components
  71794. * @param scale defines the scale vector3 given as a reference to update
  71795. * @param rotation defines the rotation quaternion given as a reference to update
  71796. * @param translation defines the translation vector3 given as a reference to update
  71797. * @returns true if operation was successful
  71798. */
  71799. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71800. /**
  71801. * Gets specific row of the matrix
  71802. * @param index defines the number of the row to get
  71803. * @returns the index-th row of the current matrix as a new Vector4
  71804. */
  71805. getRow(index: number): Nullable<Vector4>;
  71806. /**
  71807. * Sets the index-th row of the current matrix to the vector4 values
  71808. * @param index defines the number of the row to set
  71809. * @param row defines the target vector4
  71810. * @returns the updated current matrix
  71811. */
  71812. setRow(index: number, row: Vector4): Matrix;
  71813. /**
  71814. * Compute the transpose of the matrix
  71815. * @returns the new transposed matrix
  71816. */
  71817. transpose(): Matrix;
  71818. /**
  71819. * Compute the transpose of the matrix and store it in a given matrix
  71820. * @param result defines the target matrix
  71821. * @returns the current matrix
  71822. */
  71823. transposeToRef(result: Matrix): Matrix;
  71824. /**
  71825. * Sets the index-th row of the current matrix with the given 4 x float values
  71826. * @param index defines the row index
  71827. * @param x defines the x component to set
  71828. * @param y defines the y component to set
  71829. * @param z defines the z component to set
  71830. * @param w defines the w component to set
  71831. * @returns the updated current matrix
  71832. */
  71833. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71834. /**
  71835. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71836. * @param scale defines the scale factor
  71837. * @returns a new matrix
  71838. */
  71839. scale(scale: number): Matrix;
  71840. /**
  71841. * Scale the current matrix values by a factor to a given result matrix
  71842. * @param scale defines the scale factor
  71843. * @param result defines the matrix to store the result
  71844. * @returns the current matrix
  71845. */
  71846. scaleToRef(scale: number, result: Matrix): Matrix;
  71847. /**
  71848. * Scale the current matrix values by a factor and add the result to a given matrix
  71849. * @param scale defines the scale factor
  71850. * @param result defines the Matrix to store the result
  71851. * @returns the current matrix
  71852. */
  71853. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71854. /**
  71855. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71856. * @param ref matrix to store the result
  71857. */
  71858. toNormalMatrix(ref: Matrix): void;
  71859. /**
  71860. * Gets only rotation part of the current matrix
  71861. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71862. */
  71863. getRotationMatrix(): Matrix;
  71864. /**
  71865. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71866. * @param result defines the target matrix to store data to
  71867. * @returns the current matrix
  71868. */
  71869. getRotationMatrixToRef(result: Matrix): Matrix;
  71870. /**
  71871. * Toggles model matrix from being right handed to left handed in place and vice versa
  71872. */
  71873. toggleModelMatrixHandInPlace(): void;
  71874. /**
  71875. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71876. */
  71877. toggleProjectionMatrixHandInPlace(): void;
  71878. /**
  71879. * Creates a matrix from an array
  71880. * @param array defines the source array
  71881. * @param offset defines an offset in the source array
  71882. * @returns a new Matrix set from the starting index of the given array
  71883. */
  71884. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71885. /**
  71886. * Copy the content of an array into a given matrix
  71887. * @param array defines the source array
  71888. * @param offset defines an offset in the source array
  71889. * @param result defines the target matrix
  71890. */
  71891. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71892. /**
  71893. * Stores an array into a matrix after having multiplied each component by a given factor
  71894. * @param array defines the source array
  71895. * @param offset defines the offset in the source array
  71896. * @param scale defines the scaling factor
  71897. * @param result defines the target matrix
  71898. */
  71899. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71900. /**
  71901. * Gets an identity matrix that must not be updated
  71902. */
  71903. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71904. /**
  71905. * Stores a list of values (16) inside a given matrix
  71906. * @param initialM11 defines 1st value of 1st row
  71907. * @param initialM12 defines 2nd value of 1st row
  71908. * @param initialM13 defines 3rd value of 1st row
  71909. * @param initialM14 defines 4th value of 1st row
  71910. * @param initialM21 defines 1st value of 2nd row
  71911. * @param initialM22 defines 2nd value of 2nd row
  71912. * @param initialM23 defines 3rd value of 2nd row
  71913. * @param initialM24 defines 4th value of 2nd row
  71914. * @param initialM31 defines 1st value of 3rd row
  71915. * @param initialM32 defines 2nd value of 3rd row
  71916. * @param initialM33 defines 3rd value of 3rd row
  71917. * @param initialM34 defines 4th value of 3rd row
  71918. * @param initialM41 defines 1st value of 4th row
  71919. * @param initialM42 defines 2nd value of 4th row
  71920. * @param initialM43 defines 3rd value of 4th row
  71921. * @param initialM44 defines 4th value of 4th row
  71922. * @param result defines the target matrix
  71923. */
  71924. 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;
  71925. /**
  71926. * Creates new matrix from a list of values (16)
  71927. * @param initialM11 defines 1st value of 1st row
  71928. * @param initialM12 defines 2nd value of 1st row
  71929. * @param initialM13 defines 3rd value of 1st row
  71930. * @param initialM14 defines 4th value of 1st row
  71931. * @param initialM21 defines 1st value of 2nd row
  71932. * @param initialM22 defines 2nd value of 2nd row
  71933. * @param initialM23 defines 3rd value of 2nd row
  71934. * @param initialM24 defines 4th value of 2nd row
  71935. * @param initialM31 defines 1st value of 3rd row
  71936. * @param initialM32 defines 2nd value of 3rd row
  71937. * @param initialM33 defines 3rd value of 3rd row
  71938. * @param initialM34 defines 4th value of 3rd row
  71939. * @param initialM41 defines 1st value of 4th row
  71940. * @param initialM42 defines 2nd value of 4th row
  71941. * @param initialM43 defines 3rd value of 4th row
  71942. * @param initialM44 defines 4th value of 4th row
  71943. * @returns the new matrix
  71944. */
  71945. 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;
  71946. /**
  71947. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71948. * @param scale defines the scale vector3
  71949. * @param rotation defines the rotation quaternion
  71950. * @param translation defines the translation vector3
  71951. * @returns a new matrix
  71952. */
  71953. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71954. /**
  71955. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71956. * @param scale defines the scale vector3
  71957. * @param rotation defines the rotation quaternion
  71958. * @param translation defines the translation vector3
  71959. * @param result defines the target matrix
  71960. */
  71961. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71962. /**
  71963. * Creates a new identity matrix
  71964. * @returns a new identity matrix
  71965. */
  71966. static Identity(): Matrix;
  71967. /**
  71968. * Creates a new identity matrix and stores the result in a given matrix
  71969. * @param result defines the target matrix
  71970. */
  71971. static IdentityToRef(result: Matrix): void;
  71972. /**
  71973. * Creates a new zero matrix
  71974. * @returns a new zero matrix
  71975. */
  71976. static Zero(): Matrix;
  71977. /**
  71978. * Creates a new rotation matrix for "angle" radians around the X axis
  71979. * @param angle defines the angle (in radians) to use
  71980. * @return the new matrix
  71981. */
  71982. static RotationX(angle: number): Matrix;
  71983. /**
  71984. * Creates a new matrix as the invert of a given matrix
  71985. * @param source defines the source matrix
  71986. * @returns the new matrix
  71987. */
  71988. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71989. /**
  71990. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71991. * @param angle defines the angle (in radians) to use
  71992. * @param result defines the target matrix
  71993. */
  71994. static RotationXToRef(angle: number, result: Matrix): void;
  71995. /**
  71996. * Creates a new rotation matrix for "angle" radians around the Y axis
  71997. * @param angle defines the angle (in radians) to use
  71998. * @return the new matrix
  71999. */
  72000. static RotationY(angle: number): Matrix;
  72001. /**
  72002. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72003. * @param angle defines the angle (in radians) to use
  72004. * @param result defines the target matrix
  72005. */
  72006. static RotationYToRef(angle: number, result: Matrix): void;
  72007. /**
  72008. * Creates a new rotation matrix for "angle" radians around the Z axis
  72009. * @param angle defines the angle (in radians) to use
  72010. * @return the new matrix
  72011. */
  72012. static RotationZ(angle: number): Matrix;
  72013. /**
  72014. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72015. * @param angle defines the angle (in radians) to use
  72016. * @param result defines the target matrix
  72017. */
  72018. static RotationZToRef(angle: number, result: Matrix): void;
  72019. /**
  72020. * Creates a new rotation matrix for "angle" radians around the given axis
  72021. * @param axis defines the axis to use
  72022. * @param angle defines the angle (in radians) to use
  72023. * @return the new matrix
  72024. */
  72025. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72026. /**
  72027. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72028. * @param axis defines the axis to use
  72029. * @param angle defines the angle (in radians) to use
  72030. * @param result defines the target matrix
  72031. */
  72032. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72033. /**
  72034. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72035. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72036. * @param from defines the vector to align
  72037. * @param to defines the vector to align to
  72038. * @param result defines the target matrix
  72039. */
  72040. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72041. /**
  72042. * Creates a rotation matrix
  72043. * @param yaw defines the yaw angle in radians (Y axis)
  72044. * @param pitch defines the pitch angle in radians (X axis)
  72045. * @param roll defines the roll angle in radians (X axis)
  72046. * @returns the new rotation matrix
  72047. */
  72048. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72049. /**
  72050. * Creates a rotation matrix and stores it in a given matrix
  72051. * @param yaw defines the yaw angle in radians (Y axis)
  72052. * @param pitch defines the pitch angle in radians (X axis)
  72053. * @param roll defines the roll angle in radians (X axis)
  72054. * @param result defines the target matrix
  72055. */
  72056. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72057. /**
  72058. * Creates a scaling matrix
  72059. * @param x defines the scale factor on X axis
  72060. * @param y defines the scale factor on Y axis
  72061. * @param z defines the scale factor on Z axis
  72062. * @returns the new matrix
  72063. */
  72064. static Scaling(x: number, y: number, z: number): Matrix;
  72065. /**
  72066. * Creates a scaling matrix and stores it in a given matrix
  72067. * @param x defines the scale factor on X axis
  72068. * @param y defines the scale factor on Y axis
  72069. * @param z defines the scale factor on Z axis
  72070. * @param result defines the target matrix
  72071. */
  72072. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72073. /**
  72074. * Creates a translation matrix
  72075. * @param x defines the translation on X axis
  72076. * @param y defines the translation on Y axis
  72077. * @param z defines the translationon Z axis
  72078. * @returns the new matrix
  72079. */
  72080. static Translation(x: number, y: number, z: number): Matrix;
  72081. /**
  72082. * Creates a translation matrix and stores it in a given matrix
  72083. * @param x defines the translation on X axis
  72084. * @param y defines the translation on Y axis
  72085. * @param z defines the translationon Z axis
  72086. * @param result defines the target matrix
  72087. */
  72088. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72089. /**
  72090. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72091. * @param startValue defines the start value
  72092. * @param endValue defines the end value
  72093. * @param gradient defines the gradient factor
  72094. * @returns the new matrix
  72095. */
  72096. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72097. /**
  72098. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72099. * @param startValue defines the start value
  72100. * @param endValue defines the end value
  72101. * @param gradient defines the gradient factor
  72102. * @param result defines the Matrix object where to store data
  72103. */
  72104. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72105. /**
  72106. * Builds a new matrix whose values are computed by:
  72107. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72108. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72109. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72110. * @param startValue defines the first matrix
  72111. * @param endValue defines the second matrix
  72112. * @param gradient defines the gradient between the two matrices
  72113. * @returns the new matrix
  72114. */
  72115. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72116. /**
  72117. * Update a matrix to values which are computed by:
  72118. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72119. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72120. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72121. * @param startValue defines the first matrix
  72122. * @param endValue defines the second matrix
  72123. * @param gradient defines the gradient between the two matrices
  72124. * @param result defines the target matrix
  72125. */
  72126. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72127. /**
  72128. * 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"
  72129. * This function works in left handed mode
  72130. * @param eye defines the final position of the entity
  72131. * @param target defines where the entity should look at
  72132. * @param up defines the up vector for the entity
  72133. * @returns the new matrix
  72134. */
  72135. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72136. /**
  72137. * 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".
  72138. * This function works in left handed mode
  72139. * @param eye defines the final position of the entity
  72140. * @param target defines where the entity should look at
  72141. * @param up defines the up vector for the entity
  72142. * @param result defines the target matrix
  72143. */
  72144. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72145. /**
  72146. * 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"
  72147. * This function works in right handed mode
  72148. * @param eye defines the final position of the entity
  72149. * @param target defines where the entity should look at
  72150. * @param up defines the up vector for the entity
  72151. * @returns the new matrix
  72152. */
  72153. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72154. /**
  72155. * 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".
  72156. * This function works in right handed mode
  72157. * @param eye defines the final position of the entity
  72158. * @param target defines where the entity should look at
  72159. * @param up defines the up vector for the entity
  72160. * @param result defines the target matrix
  72161. */
  72162. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72163. /**
  72164. * Create a left-handed orthographic projection matrix
  72165. * @param width defines the viewport width
  72166. * @param height defines the viewport height
  72167. * @param znear defines the near clip plane
  72168. * @param zfar defines the far clip plane
  72169. * @returns a new matrix as a left-handed orthographic projection matrix
  72170. */
  72171. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72172. /**
  72173. * Store a left-handed orthographic projection to a given matrix
  72174. * @param width defines the viewport width
  72175. * @param height defines the viewport height
  72176. * @param znear defines the near clip plane
  72177. * @param zfar defines the far clip plane
  72178. * @param result defines the target matrix
  72179. */
  72180. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72181. /**
  72182. * Create a left-handed orthographic projection matrix
  72183. * @param left defines the viewport left coordinate
  72184. * @param right defines the viewport right coordinate
  72185. * @param bottom defines the viewport bottom coordinate
  72186. * @param top defines the viewport top coordinate
  72187. * @param znear defines the near clip plane
  72188. * @param zfar defines the far clip plane
  72189. * @returns a new matrix as a left-handed orthographic projection matrix
  72190. */
  72191. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72192. /**
  72193. * Stores a left-handed orthographic projection into a given matrix
  72194. * @param left defines the viewport left coordinate
  72195. * @param right defines the viewport right coordinate
  72196. * @param bottom defines the viewport bottom coordinate
  72197. * @param top defines the viewport top coordinate
  72198. * @param znear defines the near clip plane
  72199. * @param zfar defines the far clip plane
  72200. * @param result defines the target matrix
  72201. */
  72202. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72203. /**
  72204. * Creates a right-handed orthographic projection matrix
  72205. * @param left defines the viewport left coordinate
  72206. * @param right defines the viewport right coordinate
  72207. * @param bottom defines the viewport bottom coordinate
  72208. * @param top defines the viewport top coordinate
  72209. * @param znear defines the near clip plane
  72210. * @param zfar defines the far clip plane
  72211. * @returns a new matrix as a right-handed orthographic projection matrix
  72212. */
  72213. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72214. /**
  72215. * Stores a right-handed orthographic projection into a given matrix
  72216. * @param left defines the viewport left coordinate
  72217. * @param right defines the viewport right coordinate
  72218. * @param bottom defines the viewport bottom coordinate
  72219. * @param top defines the viewport top coordinate
  72220. * @param znear defines the near clip plane
  72221. * @param zfar defines the far clip plane
  72222. * @param result defines the target matrix
  72223. */
  72224. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72225. /**
  72226. * Creates a left-handed perspective projection matrix
  72227. * @param width defines the viewport width
  72228. * @param height defines the viewport height
  72229. * @param znear defines the near clip plane
  72230. * @param zfar defines the far clip plane
  72231. * @returns a new matrix as a left-handed perspective projection matrix
  72232. */
  72233. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72234. /**
  72235. * Creates a left-handed perspective projection matrix
  72236. * @param fov defines the horizontal field of view
  72237. * @param aspect defines the aspect ratio
  72238. * @param znear defines the near clip plane
  72239. * @param zfar defines the far clip plane
  72240. * @returns a new matrix as a left-handed perspective projection matrix
  72241. */
  72242. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72243. /**
  72244. * Stores a left-handed perspective projection into a given matrix
  72245. * @param fov defines the horizontal field of view
  72246. * @param aspect defines the aspect ratio
  72247. * @param znear defines the near clip plane
  72248. * @param zfar defines the far clip plane
  72249. * @param result defines the target matrix
  72250. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72251. */
  72252. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72253. /**
  72254. * Creates a right-handed perspective projection matrix
  72255. * @param fov defines the horizontal field of view
  72256. * @param aspect defines the aspect ratio
  72257. * @param znear defines the near clip plane
  72258. * @param zfar defines the far clip plane
  72259. * @returns a new matrix as a right-handed perspective projection matrix
  72260. */
  72261. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72262. /**
  72263. * Stores a right-handed perspective projection into a given matrix
  72264. * @param fov defines the horizontal field of view
  72265. * @param aspect defines the aspect ratio
  72266. * @param znear defines the near clip plane
  72267. * @param zfar defines the far clip plane
  72268. * @param result defines the target matrix
  72269. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72270. */
  72271. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72272. /**
  72273. * Stores a perspective projection for WebVR info a given matrix
  72274. * @param fov defines the field of view
  72275. * @param znear defines the near clip plane
  72276. * @param zfar defines the far clip plane
  72277. * @param result defines the target matrix
  72278. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72279. */
  72280. static PerspectiveFovWebVRToRef(fov: {
  72281. upDegrees: number;
  72282. downDegrees: number;
  72283. leftDegrees: number;
  72284. rightDegrees: number;
  72285. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72286. /**
  72287. * Computes a complete transformation matrix
  72288. * @param viewport defines the viewport to use
  72289. * @param world defines the world matrix
  72290. * @param view defines the view matrix
  72291. * @param projection defines the projection matrix
  72292. * @param zmin defines the near clip plane
  72293. * @param zmax defines the far clip plane
  72294. * @returns the transformation matrix
  72295. */
  72296. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72297. /**
  72298. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72299. * @param matrix defines the matrix to use
  72300. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72301. */
  72302. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72303. /**
  72304. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72305. * @param matrix defines the matrix to use
  72306. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72307. */
  72308. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72309. /**
  72310. * Compute the transpose of a given matrix
  72311. * @param matrix defines the matrix to transpose
  72312. * @returns the new matrix
  72313. */
  72314. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72315. /**
  72316. * Compute the transpose of a matrix and store it in a target matrix
  72317. * @param matrix defines the matrix to transpose
  72318. * @param result defines the target matrix
  72319. */
  72320. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72321. /**
  72322. * Computes a reflection matrix from a plane
  72323. * @param plane defines the reflection plane
  72324. * @returns a new matrix
  72325. */
  72326. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72327. /**
  72328. * Computes a reflection matrix from a plane
  72329. * @param plane defines the reflection plane
  72330. * @param result defines the target matrix
  72331. */
  72332. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72333. /**
  72334. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72335. * @param xaxis defines the value of the 1st axis
  72336. * @param yaxis defines the value of the 2nd axis
  72337. * @param zaxis defines the value of the 3rd axis
  72338. * @param result defines the target matrix
  72339. */
  72340. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72341. /**
  72342. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72343. * @param quat defines the quaternion to use
  72344. * @param result defines the target matrix
  72345. */
  72346. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72347. }
  72348. /**
  72349. * @hidden
  72350. */
  72351. export class TmpVectors {
  72352. static Vector2: Vector2[];
  72353. static Vector3: Vector3[];
  72354. static Vector4: Vector4[];
  72355. static Quaternion: Quaternion[];
  72356. static Matrix: Matrix[];
  72357. }
  72358. }
  72359. declare module BABYLON {
  72360. /**
  72361. * Defines potential orientation for back face culling
  72362. */
  72363. export enum Orientation {
  72364. /**
  72365. * Clockwise
  72366. */
  72367. CW = 0,
  72368. /** Counter clockwise */
  72369. CCW = 1
  72370. }
  72371. /** Class used to represent a Bezier curve */
  72372. export class BezierCurve {
  72373. /**
  72374. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72375. * @param t defines the time
  72376. * @param x1 defines the left coordinate on X axis
  72377. * @param y1 defines the left coordinate on Y axis
  72378. * @param x2 defines the right coordinate on X axis
  72379. * @param y2 defines the right coordinate on Y axis
  72380. * @returns the interpolated value
  72381. */
  72382. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72383. }
  72384. /**
  72385. * Defines angle representation
  72386. */
  72387. export class Angle {
  72388. private _radians;
  72389. /**
  72390. * Creates an Angle object of "radians" radians (float).
  72391. * @param radians the angle in radians
  72392. */
  72393. constructor(radians: number);
  72394. /**
  72395. * Get value in degrees
  72396. * @returns the Angle value in degrees (float)
  72397. */
  72398. degrees(): number;
  72399. /**
  72400. * Get value in radians
  72401. * @returns the Angle value in radians (float)
  72402. */
  72403. radians(): number;
  72404. /**
  72405. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72406. * @param a defines first vector
  72407. * @param b defines second vector
  72408. * @returns a new Angle
  72409. */
  72410. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72411. /**
  72412. * Gets a new Angle object from the given float in radians
  72413. * @param radians defines the angle value in radians
  72414. * @returns a new Angle
  72415. */
  72416. static FromRadians(radians: number): Angle;
  72417. /**
  72418. * Gets a new Angle object from the given float in degrees
  72419. * @param degrees defines the angle value in degrees
  72420. * @returns a new Angle
  72421. */
  72422. static FromDegrees(degrees: number): Angle;
  72423. }
  72424. /**
  72425. * This represents an arc in a 2d space.
  72426. */
  72427. export class Arc2 {
  72428. /** Defines the start point of the arc */
  72429. startPoint: Vector2;
  72430. /** Defines the mid point of the arc */
  72431. midPoint: Vector2;
  72432. /** Defines the end point of the arc */
  72433. endPoint: Vector2;
  72434. /**
  72435. * Defines the center point of the arc.
  72436. */
  72437. centerPoint: Vector2;
  72438. /**
  72439. * Defines the radius of the arc.
  72440. */
  72441. radius: number;
  72442. /**
  72443. * Defines the angle of the arc (from mid point to end point).
  72444. */
  72445. angle: Angle;
  72446. /**
  72447. * Defines the start angle of the arc (from start point to middle point).
  72448. */
  72449. startAngle: Angle;
  72450. /**
  72451. * Defines the orientation of the arc (clock wise/counter clock wise).
  72452. */
  72453. orientation: Orientation;
  72454. /**
  72455. * Creates an Arc object from the three given points : start, middle and end.
  72456. * @param startPoint Defines the start point of the arc
  72457. * @param midPoint Defines the midlle point of the arc
  72458. * @param endPoint Defines the end point of the arc
  72459. */
  72460. constructor(
  72461. /** Defines the start point of the arc */
  72462. startPoint: Vector2,
  72463. /** Defines the mid point of the arc */
  72464. midPoint: Vector2,
  72465. /** Defines the end point of the arc */
  72466. endPoint: Vector2);
  72467. }
  72468. /**
  72469. * Represents a 2D path made up of multiple 2D points
  72470. */
  72471. export class Path2 {
  72472. private _points;
  72473. private _length;
  72474. /**
  72475. * If the path start and end point are the same
  72476. */
  72477. closed: boolean;
  72478. /**
  72479. * Creates a Path2 object from the starting 2D coordinates x and y.
  72480. * @param x the starting points x value
  72481. * @param y the starting points y value
  72482. */
  72483. constructor(x: number, y: number);
  72484. /**
  72485. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72486. * @param x the added points x value
  72487. * @param y the added points y value
  72488. * @returns the updated Path2.
  72489. */
  72490. addLineTo(x: number, y: number): Path2;
  72491. /**
  72492. * 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.
  72493. * @param midX middle point x value
  72494. * @param midY middle point y value
  72495. * @param endX end point x value
  72496. * @param endY end point y value
  72497. * @param numberOfSegments (default: 36)
  72498. * @returns the updated Path2.
  72499. */
  72500. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72501. /**
  72502. * Closes the Path2.
  72503. * @returns the Path2.
  72504. */
  72505. close(): Path2;
  72506. /**
  72507. * Gets the sum of the distance between each sequential point in the path
  72508. * @returns the Path2 total length (float).
  72509. */
  72510. length(): number;
  72511. /**
  72512. * Gets the points which construct the path
  72513. * @returns the Path2 internal array of points.
  72514. */
  72515. getPoints(): Vector2[];
  72516. /**
  72517. * Retreives the point at the distance aways from the starting point
  72518. * @param normalizedLengthPosition the length along the path to retreive the point from
  72519. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72520. */
  72521. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72522. /**
  72523. * Creates a new path starting from an x and y position
  72524. * @param x starting x value
  72525. * @param y starting y value
  72526. * @returns a new Path2 starting at the coordinates (x, y).
  72527. */
  72528. static StartingAt(x: number, y: number): Path2;
  72529. }
  72530. /**
  72531. * Represents a 3D path made up of multiple 3D points
  72532. */
  72533. export class Path3D {
  72534. /**
  72535. * an array of Vector3, the curve axis of the Path3D
  72536. */
  72537. path: Vector3[];
  72538. private _curve;
  72539. private _distances;
  72540. private _tangents;
  72541. private _normals;
  72542. private _binormals;
  72543. private _raw;
  72544. /**
  72545. * new Path3D(path, normal, raw)
  72546. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72547. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72548. * @param path an array of Vector3, the curve axis of the Path3D
  72549. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72550. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72551. */
  72552. constructor(
  72553. /**
  72554. * an array of Vector3, the curve axis of the Path3D
  72555. */
  72556. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72557. /**
  72558. * Returns the Path3D array of successive Vector3 designing its curve.
  72559. * @returns the Path3D array of successive Vector3 designing its curve.
  72560. */
  72561. getCurve(): Vector3[];
  72562. /**
  72563. * Returns an array populated with tangent vectors on each Path3D curve point.
  72564. * @returns an array populated with tangent vectors on each Path3D curve point.
  72565. */
  72566. getTangents(): Vector3[];
  72567. /**
  72568. * Returns an array populated with normal vectors on each Path3D curve point.
  72569. * @returns an array populated with normal vectors on each Path3D curve point.
  72570. */
  72571. getNormals(): Vector3[];
  72572. /**
  72573. * Returns an array populated with binormal vectors on each Path3D curve point.
  72574. * @returns an array populated with binormal vectors on each Path3D curve point.
  72575. */
  72576. getBinormals(): Vector3[];
  72577. /**
  72578. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72579. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72580. */
  72581. getDistances(): number[];
  72582. /**
  72583. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72584. * @param path path which all values are copied into the curves points
  72585. * @param firstNormal which should be projected onto the curve
  72586. * @returns the same object updated.
  72587. */
  72588. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72589. private _compute;
  72590. private _getFirstNonNullVector;
  72591. private _getLastNonNullVector;
  72592. private _normalVector;
  72593. }
  72594. /**
  72595. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72596. * A Curve3 is designed from a series of successive Vector3.
  72597. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72598. */
  72599. export class Curve3 {
  72600. private _points;
  72601. private _length;
  72602. /**
  72603. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72604. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72605. * @param v1 (Vector3) the control point
  72606. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72607. * @param nbPoints (integer) the wanted number of points in the curve
  72608. * @returns the created Curve3
  72609. */
  72610. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72611. /**
  72612. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72613. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72614. * @param v1 (Vector3) the first control point
  72615. * @param v2 (Vector3) the second control point
  72616. * @param v3 (Vector3) the end point of the Cubic Bezier
  72617. * @param nbPoints (integer) the wanted number of points in the curve
  72618. * @returns the created Curve3
  72619. */
  72620. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72621. /**
  72622. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72623. * @param p1 (Vector3) the origin point of the Hermite Spline
  72624. * @param t1 (Vector3) the tangent vector at the origin point
  72625. * @param p2 (Vector3) the end point of the Hermite Spline
  72626. * @param t2 (Vector3) the tangent vector at the end point
  72627. * @param nbPoints (integer) the wanted number of points in the curve
  72628. * @returns the created Curve3
  72629. */
  72630. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72631. /**
  72632. * Returns a Curve3 object along a CatmullRom Spline curve :
  72633. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72634. * @param nbPoints (integer) the wanted number of points between each curve control points
  72635. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72636. * @returns the created Curve3
  72637. */
  72638. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72639. /**
  72640. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72641. * A Curve3 is designed from a series of successive Vector3.
  72642. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72643. * @param points points which make up the curve
  72644. */
  72645. constructor(points: Vector3[]);
  72646. /**
  72647. * @returns the Curve3 stored array of successive Vector3
  72648. */
  72649. getPoints(): Vector3[];
  72650. /**
  72651. * @returns the computed length (float) of the curve.
  72652. */
  72653. length(): number;
  72654. /**
  72655. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72656. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72657. * curveA and curveB keep unchanged.
  72658. * @param curve the curve to continue from this curve
  72659. * @returns the newly constructed curve
  72660. */
  72661. continue(curve: DeepImmutable<Curve3>): Curve3;
  72662. private _computeLength;
  72663. }
  72664. }
  72665. declare module BABYLON {
  72666. /**
  72667. * This represents the main contract an easing function should follow.
  72668. * Easing functions are used throughout the animation system.
  72669. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72670. */
  72671. export interface IEasingFunction {
  72672. /**
  72673. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72674. * of the easing function.
  72675. * The link below provides some of the most common examples of easing functions.
  72676. * @see https://easings.net/
  72677. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72678. * @returns the corresponding value on the curve defined by the easing function
  72679. */
  72680. ease(gradient: number): number;
  72681. }
  72682. /**
  72683. * Base class used for every default easing function.
  72684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72685. */
  72686. export class EasingFunction implements IEasingFunction {
  72687. /**
  72688. * Interpolation follows the mathematical formula associated with the easing function.
  72689. */
  72690. static readonly EASINGMODE_EASEIN: number;
  72691. /**
  72692. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72693. */
  72694. static readonly EASINGMODE_EASEOUT: number;
  72695. /**
  72696. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72697. */
  72698. static readonly EASINGMODE_EASEINOUT: number;
  72699. private _easingMode;
  72700. /**
  72701. * Sets the easing mode of the current function.
  72702. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72703. */
  72704. setEasingMode(easingMode: number): void;
  72705. /**
  72706. * Gets the current easing mode.
  72707. * @returns the easing mode
  72708. */
  72709. getEasingMode(): number;
  72710. /**
  72711. * @hidden
  72712. */
  72713. easeInCore(gradient: number): number;
  72714. /**
  72715. * Given an input gradient between 0 and 1, this returns the corresponding value
  72716. * of the easing function.
  72717. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72718. * @returns the corresponding value on the curve defined by the easing function
  72719. */
  72720. ease(gradient: number): number;
  72721. }
  72722. /**
  72723. * Easing function with a circle shape (see link below).
  72724. * @see https://easings.net/#easeInCirc
  72725. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72726. */
  72727. export class CircleEase extends EasingFunction implements IEasingFunction {
  72728. /** @hidden */
  72729. easeInCore(gradient: number): number;
  72730. }
  72731. /**
  72732. * Easing function with a ease back shape (see link below).
  72733. * @see https://easings.net/#easeInBack
  72734. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72735. */
  72736. export class BackEase extends EasingFunction implements IEasingFunction {
  72737. /** Defines the amplitude of the function */
  72738. amplitude: number;
  72739. /**
  72740. * Instantiates a back ease easing
  72741. * @see https://easings.net/#easeInBack
  72742. * @param amplitude Defines the amplitude of the function
  72743. */
  72744. constructor(
  72745. /** Defines the amplitude of the function */
  72746. amplitude?: number);
  72747. /** @hidden */
  72748. easeInCore(gradient: number): number;
  72749. }
  72750. /**
  72751. * Easing function with a bouncing shape (see link below).
  72752. * @see https://easings.net/#easeInBounce
  72753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72754. */
  72755. export class BounceEase extends EasingFunction implements IEasingFunction {
  72756. /** Defines the number of bounces */
  72757. bounces: number;
  72758. /** Defines the amplitude of the bounce */
  72759. bounciness: number;
  72760. /**
  72761. * Instantiates a bounce easing
  72762. * @see https://easings.net/#easeInBounce
  72763. * @param bounces Defines the number of bounces
  72764. * @param bounciness Defines the amplitude of the bounce
  72765. */
  72766. constructor(
  72767. /** Defines the number of bounces */
  72768. bounces?: number,
  72769. /** Defines the amplitude of the bounce */
  72770. bounciness?: number);
  72771. /** @hidden */
  72772. easeInCore(gradient: number): number;
  72773. }
  72774. /**
  72775. * Easing function with a power of 3 shape (see link below).
  72776. * @see https://easings.net/#easeInCubic
  72777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72778. */
  72779. export class CubicEase extends EasingFunction implements IEasingFunction {
  72780. /** @hidden */
  72781. easeInCore(gradient: number): number;
  72782. }
  72783. /**
  72784. * Easing function with an elastic shape (see link below).
  72785. * @see https://easings.net/#easeInElastic
  72786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72787. */
  72788. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72789. /** Defines the number of oscillations*/
  72790. oscillations: number;
  72791. /** Defines the amplitude of the oscillations*/
  72792. springiness: number;
  72793. /**
  72794. * Instantiates an elastic easing function
  72795. * @see https://easings.net/#easeInElastic
  72796. * @param oscillations Defines the number of oscillations
  72797. * @param springiness Defines the amplitude of the oscillations
  72798. */
  72799. constructor(
  72800. /** Defines the number of oscillations*/
  72801. oscillations?: number,
  72802. /** Defines the amplitude of the oscillations*/
  72803. springiness?: number);
  72804. /** @hidden */
  72805. easeInCore(gradient: number): number;
  72806. }
  72807. /**
  72808. * Easing function with an exponential shape (see link below).
  72809. * @see https://easings.net/#easeInExpo
  72810. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72811. */
  72812. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72813. /** Defines the exponent of the function */
  72814. exponent: number;
  72815. /**
  72816. * Instantiates an exponential easing function
  72817. * @see https://easings.net/#easeInExpo
  72818. * @param exponent Defines the exponent of the function
  72819. */
  72820. constructor(
  72821. /** Defines the exponent of the function */
  72822. exponent?: number);
  72823. /** @hidden */
  72824. easeInCore(gradient: number): number;
  72825. }
  72826. /**
  72827. * Easing function with a power shape (see link below).
  72828. * @see https://easings.net/#easeInQuad
  72829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72830. */
  72831. export class PowerEase extends EasingFunction implements IEasingFunction {
  72832. /** Defines the power of the function */
  72833. power: number;
  72834. /**
  72835. * Instantiates an power base easing function
  72836. * @see https://easings.net/#easeInQuad
  72837. * @param power Defines the power of the function
  72838. */
  72839. constructor(
  72840. /** Defines the power of the function */
  72841. power?: number);
  72842. /** @hidden */
  72843. easeInCore(gradient: number): number;
  72844. }
  72845. /**
  72846. * Easing function with a power of 2 shape (see link below).
  72847. * @see https://easings.net/#easeInQuad
  72848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72849. */
  72850. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72851. /** @hidden */
  72852. easeInCore(gradient: number): number;
  72853. }
  72854. /**
  72855. * Easing function with a power of 4 shape (see link below).
  72856. * @see https://easings.net/#easeInQuart
  72857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72858. */
  72859. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72860. /** @hidden */
  72861. easeInCore(gradient: number): number;
  72862. }
  72863. /**
  72864. * Easing function with a power of 5 shape (see link below).
  72865. * @see https://easings.net/#easeInQuint
  72866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72867. */
  72868. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72869. /** @hidden */
  72870. easeInCore(gradient: number): number;
  72871. }
  72872. /**
  72873. * Easing function with a sin shape (see link below).
  72874. * @see https://easings.net/#easeInSine
  72875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72876. */
  72877. export class SineEase extends EasingFunction implements IEasingFunction {
  72878. /** @hidden */
  72879. easeInCore(gradient: number): number;
  72880. }
  72881. /**
  72882. * Easing function with a bezier shape (see link below).
  72883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72885. */
  72886. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72887. /** Defines the x component of the start tangent in the bezier curve */
  72888. x1: number;
  72889. /** Defines the y component of the start tangent in the bezier curve */
  72890. y1: number;
  72891. /** Defines the x component of the end tangent in the bezier curve */
  72892. x2: number;
  72893. /** Defines the y component of the end tangent in the bezier curve */
  72894. y2: number;
  72895. /**
  72896. * Instantiates a bezier function
  72897. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72898. * @param x1 Defines the x component of the start tangent in the bezier curve
  72899. * @param y1 Defines the y component of the start tangent in the bezier curve
  72900. * @param x2 Defines the x component of the end tangent in the bezier curve
  72901. * @param y2 Defines the y component of the end tangent in the bezier curve
  72902. */
  72903. constructor(
  72904. /** Defines the x component of the start tangent in the bezier curve */
  72905. x1?: number,
  72906. /** Defines the y component of the start tangent in the bezier curve */
  72907. y1?: number,
  72908. /** Defines the x component of the end tangent in the bezier curve */
  72909. x2?: number,
  72910. /** Defines the y component of the end tangent in the bezier curve */
  72911. y2?: number);
  72912. /** @hidden */
  72913. easeInCore(gradient: number): number;
  72914. }
  72915. }
  72916. declare module BABYLON {
  72917. /**
  72918. * Class used to hold a RBG color
  72919. */
  72920. export class Color3 {
  72921. /**
  72922. * Defines the red component (between 0 and 1, default is 0)
  72923. */
  72924. r: number;
  72925. /**
  72926. * Defines the green component (between 0 and 1, default is 0)
  72927. */
  72928. g: number;
  72929. /**
  72930. * Defines the blue component (between 0 and 1, default is 0)
  72931. */
  72932. b: number;
  72933. /**
  72934. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72935. * @param r defines the red component (between 0 and 1, default is 0)
  72936. * @param g defines the green component (between 0 and 1, default is 0)
  72937. * @param b defines the blue component (between 0 and 1, default is 0)
  72938. */
  72939. constructor(
  72940. /**
  72941. * Defines the red component (between 0 and 1, default is 0)
  72942. */
  72943. r?: number,
  72944. /**
  72945. * Defines the green component (between 0 and 1, default is 0)
  72946. */
  72947. g?: number,
  72948. /**
  72949. * Defines the blue component (between 0 and 1, default is 0)
  72950. */
  72951. b?: number);
  72952. /**
  72953. * Creates a string with the Color3 current values
  72954. * @returns the string representation of the Color3 object
  72955. */
  72956. toString(): string;
  72957. /**
  72958. * Returns the string "Color3"
  72959. * @returns "Color3"
  72960. */
  72961. getClassName(): string;
  72962. /**
  72963. * Compute the Color3 hash code
  72964. * @returns an unique number that can be used to hash Color3 objects
  72965. */
  72966. getHashCode(): number;
  72967. /**
  72968. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72969. * @param array defines the array where to store the r,g,b components
  72970. * @param index defines an optional index in the target array to define where to start storing values
  72971. * @returns the current Color3 object
  72972. */
  72973. toArray(array: FloatArray, index?: number): Color3;
  72974. /**
  72975. * Returns a new Color4 object from the current Color3 and the given alpha
  72976. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72977. * @returns a new Color4 object
  72978. */
  72979. toColor4(alpha?: number): Color4;
  72980. /**
  72981. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72982. * @returns the new array
  72983. */
  72984. asArray(): number[];
  72985. /**
  72986. * Returns the luminance value
  72987. * @returns a float value
  72988. */
  72989. toLuminance(): number;
  72990. /**
  72991. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72992. * @param otherColor defines the second operand
  72993. * @returns the new Color3 object
  72994. */
  72995. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72996. /**
  72997. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72998. * @param otherColor defines the second operand
  72999. * @param result defines the Color3 object where to store the result
  73000. * @returns the current Color3
  73001. */
  73002. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73003. /**
  73004. * Determines equality between Color3 objects
  73005. * @param otherColor defines the second operand
  73006. * @returns true if the rgb values are equal to the given ones
  73007. */
  73008. equals(otherColor: DeepImmutable<Color3>): boolean;
  73009. /**
  73010. * Determines equality between the current Color3 object and a set of r,b,g values
  73011. * @param r defines the red component to check
  73012. * @param g defines the green component to check
  73013. * @param b defines the blue component to check
  73014. * @returns true if the rgb values are equal to the given ones
  73015. */
  73016. equalsFloats(r: number, g: number, b: number): boolean;
  73017. /**
  73018. * Multiplies in place each rgb value by scale
  73019. * @param scale defines the scaling factor
  73020. * @returns the updated Color3
  73021. */
  73022. scale(scale: number): Color3;
  73023. /**
  73024. * Multiplies the rgb values by scale and stores the result into "result"
  73025. * @param scale defines the scaling factor
  73026. * @param result defines the Color3 object where to store the result
  73027. * @returns the unmodified current Color3
  73028. */
  73029. scaleToRef(scale: number, result: Color3): Color3;
  73030. /**
  73031. * Scale the current Color3 values by a factor and add the result to a given Color3
  73032. * @param scale defines the scale factor
  73033. * @param result defines color to store the result into
  73034. * @returns the unmodified current Color3
  73035. */
  73036. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73037. /**
  73038. * Clamps the rgb values by the min and max values and stores the result into "result"
  73039. * @param min defines minimum clamping value (default is 0)
  73040. * @param max defines maximum clamping value (default is 1)
  73041. * @param result defines color to store the result into
  73042. * @returns the original Color3
  73043. */
  73044. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73045. /**
  73046. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73047. * @param otherColor defines the second operand
  73048. * @returns the new Color3
  73049. */
  73050. add(otherColor: DeepImmutable<Color3>): Color3;
  73051. /**
  73052. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73053. * @param otherColor defines the second operand
  73054. * @param result defines Color3 object to store the result into
  73055. * @returns the unmodified current Color3
  73056. */
  73057. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73058. /**
  73059. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73060. * @param otherColor defines the second operand
  73061. * @returns the new Color3
  73062. */
  73063. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73064. /**
  73065. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73066. * @param otherColor defines the second operand
  73067. * @param result defines Color3 object to store the result into
  73068. * @returns the unmodified current Color3
  73069. */
  73070. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73071. /**
  73072. * Copy the current object
  73073. * @returns a new Color3 copied the current one
  73074. */
  73075. clone(): Color3;
  73076. /**
  73077. * Copies the rgb values from the source in the current Color3
  73078. * @param source defines the source Color3 object
  73079. * @returns the updated Color3 object
  73080. */
  73081. copyFrom(source: DeepImmutable<Color3>): Color3;
  73082. /**
  73083. * Updates the Color3 rgb values from the given floats
  73084. * @param r defines the red component to read from
  73085. * @param g defines the green component to read from
  73086. * @param b defines the blue component to read from
  73087. * @returns the current Color3 object
  73088. */
  73089. copyFromFloats(r: number, g: number, b: number): Color3;
  73090. /**
  73091. * Updates the Color3 rgb values from the given floats
  73092. * @param r defines the red component to read from
  73093. * @param g defines the green component to read from
  73094. * @param b defines the blue component to read from
  73095. * @returns the current Color3 object
  73096. */
  73097. set(r: number, g: number, b: number): Color3;
  73098. /**
  73099. * Compute the Color3 hexadecimal code as a string
  73100. * @returns a string containing the hexadecimal representation of the Color3 object
  73101. */
  73102. toHexString(): string;
  73103. /**
  73104. * Computes a new Color3 converted from the current one to linear space
  73105. * @returns a new Color3 object
  73106. */
  73107. toLinearSpace(): Color3;
  73108. /**
  73109. * Converts current color in rgb space to HSV values
  73110. * @returns a new color3 representing the HSV values
  73111. */
  73112. toHSV(): Color3;
  73113. /**
  73114. * Converts current color in rgb space to HSV values
  73115. * @param result defines the Color3 where to store the HSV values
  73116. */
  73117. toHSVToRef(result: Color3): void;
  73118. /**
  73119. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73120. * @param convertedColor defines the Color3 object where to store the linear space version
  73121. * @returns the unmodified Color3
  73122. */
  73123. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73124. /**
  73125. * Computes a new Color3 converted from the current one to gamma space
  73126. * @returns a new Color3 object
  73127. */
  73128. toGammaSpace(): Color3;
  73129. /**
  73130. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73131. * @param convertedColor defines the Color3 object where to store the gamma space version
  73132. * @returns the unmodified Color3
  73133. */
  73134. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73135. private static _BlackReadOnly;
  73136. /**
  73137. * Convert Hue, saturation and value to a Color3 (RGB)
  73138. * @param hue defines the hue
  73139. * @param saturation defines the saturation
  73140. * @param value defines the value
  73141. * @param result defines the Color3 where to store the RGB values
  73142. */
  73143. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73144. /**
  73145. * Creates a new Color3 from the string containing valid hexadecimal values
  73146. * @param hex defines a string containing valid hexadecimal values
  73147. * @returns a new Color3 object
  73148. */
  73149. static FromHexString(hex: string): Color3;
  73150. /**
  73151. * Creates a new Color3 from the starting index of the given array
  73152. * @param array defines the source array
  73153. * @param offset defines an offset in the source array
  73154. * @returns a new Color3 object
  73155. */
  73156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73157. /**
  73158. * Creates a new Color3 from integer values (< 256)
  73159. * @param r defines the red component to read from (value between 0 and 255)
  73160. * @param g defines the green component to read from (value between 0 and 255)
  73161. * @param b defines the blue component to read from (value between 0 and 255)
  73162. * @returns a new Color3 object
  73163. */
  73164. static FromInts(r: number, g: number, b: number): Color3;
  73165. /**
  73166. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73167. * @param start defines the start Color3 value
  73168. * @param end defines the end Color3 value
  73169. * @param amount defines the gradient value between start and end
  73170. * @returns a new Color3 object
  73171. */
  73172. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73173. /**
  73174. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73175. * @param left defines the start value
  73176. * @param right defines the end value
  73177. * @param amount defines the gradient factor
  73178. * @param result defines the Color3 object where to store the result
  73179. */
  73180. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73181. /**
  73182. * Returns a Color3 value containing a red color
  73183. * @returns a new Color3 object
  73184. */
  73185. static Red(): Color3;
  73186. /**
  73187. * Returns a Color3 value containing a green color
  73188. * @returns a new Color3 object
  73189. */
  73190. static Green(): Color3;
  73191. /**
  73192. * Returns a Color3 value containing a blue color
  73193. * @returns a new Color3 object
  73194. */
  73195. static Blue(): Color3;
  73196. /**
  73197. * Returns a Color3 value containing a black color
  73198. * @returns a new Color3 object
  73199. */
  73200. static Black(): Color3;
  73201. /**
  73202. * Gets a Color3 value containing a black color that must not be updated
  73203. */
  73204. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73205. /**
  73206. * Returns a Color3 value containing a white color
  73207. * @returns a new Color3 object
  73208. */
  73209. static White(): Color3;
  73210. /**
  73211. * Returns a Color3 value containing a purple color
  73212. * @returns a new Color3 object
  73213. */
  73214. static Purple(): Color3;
  73215. /**
  73216. * Returns a Color3 value containing a magenta color
  73217. * @returns a new Color3 object
  73218. */
  73219. static Magenta(): Color3;
  73220. /**
  73221. * Returns a Color3 value containing a yellow color
  73222. * @returns a new Color3 object
  73223. */
  73224. static Yellow(): Color3;
  73225. /**
  73226. * Returns a Color3 value containing a gray color
  73227. * @returns a new Color3 object
  73228. */
  73229. static Gray(): Color3;
  73230. /**
  73231. * Returns a Color3 value containing a teal color
  73232. * @returns a new Color3 object
  73233. */
  73234. static Teal(): Color3;
  73235. /**
  73236. * Returns a Color3 value containing a random color
  73237. * @returns a new Color3 object
  73238. */
  73239. static Random(): Color3;
  73240. }
  73241. /**
  73242. * Class used to hold a RBGA color
  73243. */
  73244. export class Color4 {
  73245. /**
  73246. * Defines the red component (between 0 and 1, default is 0)
  73247. */
  73248. r: number;
  73249. /**
  73250. * Defines the green component (between 0 and 1, default is 0)
  73251. */
  73252. g: number;
  73253. /**
  73254. * Defines the blue component (between 0 and 1, default is 0)
  73255. */
  73256. b: number;
  73257. /**
  73258. * Defines the alpha component (between 0 and 1, default is 1)
  73259. */
  73260. a: number;
  73261. /**
  73262. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73263. * @param r defines the red component (between 0 and 1, default is 0)
  73264. * @param g defines the green component (between 0 and 1, default is 0)
  73265. * @param b defines the blue component (between 0 and 1, default is 0)
  73266. * @param a defines the alpha component (between 0 and 1, default is 1)
  73267. */
  73268. constructor(
  73269. /**
  73270. * Defines the red component (between 0 and 1, default is 0)
  73271. */
  73272. r?: number,
  73273. /**
  73274. * Defines the green component (between 0 and 1, default is 0)
  73275. */
  73276. g?: number,
  73277. /**
  73278. * Defines the blue component (between 0 and 1, default is 0)
  73279. */
  73280. b?: number,
  73281. /**
  73282. * Defines the alpha component (between 0 and 1, default is 1)
  73283. */
  73284. a?: number);
  73285. /**
  73286. * Adds in place the given Color4 values to the current Color4 object
  73287. * @param right defines the second operand
  73288. * @returns the current updated Color4 object
  73289. */
  73290. addInPlace(right: DeepImmutable<Color4>): Color4;
  73291. /**
  73292. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73293. * @returns the new array
  73294. */
  73295. asArray(): number[];
  73296. /**
  73297. * Stores from the starting index in the given array the Color4 successive values
  73298. * @param array defines the array where to store the r,g,b components
  73299. * @param index defines an optional index in the target array to define where to start storing values
  73300. * @returns the current Color4 object
  73301. */
  73302. toArray(array: number[], index?: number): Color4;
  73303. /**
  73304. * Determines equality between Color4 objects
  73305. * @param otherColor defines the second operand
  73306. * @returns true if the rgba values are equal to the given ones
  73307. */
  73308. equals(otherColor: DeepImmutable<Color4>): boolean;
  73309. /**
  73310. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73311. * @param right defines the second operand
  73312. * @returns a new Color4 object
  73313. */
  73314. add(right: DeepImmutable<Color4>): Color4;
  73315. /**
  73316. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73317. * @param right defines the second operand
  73318. * @returns a new Color4 object
  73319. */
  73320. subtract(right: DeepImmutable<Color4>): Color4;
  73321. /**
  73322. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73323. * @param right defines the second operand
  73324. * @param result defines the Color4 object where to store the result
  73325. * @returns the current Color4 object
  73326. */
  73327. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73328. /**
  73329. * Creates a new Color4 with the current Color4 values multiplied by scale
  73330. * @param scale defines the scaling factor to apply
  73331. * @returns a new Color4 object
  73332. */
  73333. scale(scale: number): Color4;
  73334. /**
  73335. * Multiplies the current Color4 values by scale and stores the result in "result"
  73336. * @param scale defines the scaling factor to apply
  73337. * @param result defines the Color4 object where to store the result
  73338. * @returns the current unmodified Color4
  73339. */
  73340. scaleToRef(scale: number, result: Color4): Color4;
  73341. /**
  73342. * Scale the current Color4 values by a factor and add the result to a given Color4
  73343. * @param scale defines the scale factor
  73344. * @param result defines the Color4 object where to store the result
  73345. * @returns the unmodified current Color4
  73346. */
  73347. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73348. /**
  73349. * Clamps the rgb values by the min and max values and stores the result into "result"
  73350. * @param min defines minimum clamping value (default is 0)
  73351. * @param max defines maximum clamping value (default is 1)
  73352. * @param result defines color to store the result into.
  73353. * @returns the cuurent Color4
  73354. */
  73355. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73356. /**
  73357. * Multipy an Color4 value by another and return a new Color4 object
  73358. * @param color defines the Color4 value to multiply by
  73359. * @returns a new Color4 object
  73360. */
  73361. multiply(color: Color4): Color4;
  73362. /**
  73363. * Multipy a Color4 value by another and push the result in a reference value
  73364. * @param color defines the Color4 value to multiply by
  73365. * @param result defines the Color4 to fill the result in
  73366. * @returns the result Color4
  73367. */
  73368. multiplyToRef(color: Color4, result: Color4): Color4;
  73369. /**
  73370. * Creates a string with the Color4 current values
  73371. * @returns the string representation of the Color4 object
  73372. */
  73373. toString(): string;
  73374. /**
  73375. * Returns the string "Color4"
  73376. * @returns "Color4"
  73377. */
  73378. getClassName(): string;
  73379. /**
  73380. * Compute the Color4 hash code
  73381. * @returns an unique number that can be used to hash Color4 objects
  73382. */
  73383. getHashCode(): number;
  73384. /**
  73385. * Creates a new Color4 copied from the current one
  73386. * @returns a new Color4 object
  73387. */
  73388. clone(): Color4;
  73389. /**
  73390. * Copies the given Color4 values into the current one
  73391. * @param source defines the source Color4 object
  73392. * @returns the current updated Color4 object
  73393. */
  73394. copyFrom(source: Color4): Color4;
  73395. /**
  73396. * Copies the given float values into the current one
  73397. * @param r defines the red component to read from
  73398. * @param g defines the green component to read from
  73399. * @param b defines the blue component to read from
  73400. * @param a defines the alpha component to read from
  73401. * @returns the current updated Color4 object
  73402. */
  73403. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73404. /**
  73405. * Copies the given float values into the current one
  73406. * @param r defines the red component to read from
  73407. * @param g defines the green component to read from
  73408. * @param b defines the blue component to read from
  73409. * @param a defines the alpha component to read from
  73410. * @returns the current updated Color4 object
  73411. */
  73412. set(r: number, g: number, b: number, a: number): Color4;
  73413. /**
  73414. * Compute the Color4 hexadecimal code as a string
  73415. * @returns a string containing the hexadecimal representation of the Color4 object
  73416. */
  73417. toHexString(): string;
  73418. /**
  73419. * Computes a new Color4 converted from the current one to linear space
  73420. * @returns a new Color4 object
  73421. */
  73422. toLinearSpace(): Color4;
  73423. /**
  73424. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73425. * @param convertedColor defines the Color4 object where to store the linear space version
  73426. * @returns the unmodified Color4
  73427. */
  73428. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73429. /**
  73430. * Computes a new Color4 converted from the current one to gamma space
  73431. * @returns a new Color4 object
  73432. */
  73433. toGammaSpace(): Color4;
  73434. /**
  73435. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73436. * @param convertedColor defines the Color4 object where to store the gamma space version
  73437. * @returns the unmodified Color4
  73438. */
  73439. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73440. /**
  73441. * Creates a new Color4 from the string containing valid hexadecimal values
  73442. * @param hex defines a string containing valid hexadecimal values
  73443. * @returns a new Color4 object
  73444. */
  73445. static FromHexString(hex: string): Color4;
  73446. /**
  73447. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73448. * @param left defines the start value
  73449. * @param right defines the end value
  73450. * @param amount defines the gradient factor
  73451. * @returns a new Color4 object
  73452. */
  73453. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73454. /**
  73455. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73456. * @param left defines the start value
  73457. * @param right defines the end value
  73458. * @param amount defines the gradient factor
  73459. * @param result defines the Color4 object where to store data
  73460. */
  73461. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73462. /**
  73463. * Creates a new Color4 from a Color3 and an alpha value
  73464. * @param color3 defines the source Color3 to read from
  73465. * @param alpha defines the alpha component (1.0 by default)
  73466. * @returns a new Color4 object
  73467. */
  73468. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73469. /**
  73470. * Creates a new Color4 from the starting index element of the given array
  73471. * @param array defines the source array to read from
  73472. * @param offset defines the offset in the source array
  73473. * @returns a new Color4 object
  73474. */
  73475. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73476. /**
  73477. * Creates a new Color3 from integer values (< 256)
  73478. * @param r defines the red component to read from (value between 0 and 255)
  73479. * @param g defines the green component to read from (value between 0 and 255)
  73480. * @param b defines the blue component to read from (value between 0 and 255)
  73481. * @param a defines the alpha component to read from (value between 0 and 255)
  73482. * @returns a new Color3 object
  73483. */
  73484. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73485. /**
  73486. * Check the content of a given array and convert it to an array containing RGBA data
  73487. * If the original array was already containing count * 4 values then it is returned directly
  73488. * @param colors defines the array to check
  73489. * @param count defines the number of RGBA data to expect
  73490. * @returns an array containing count * 4 values (RGBA)
  73491. */
  73492. static CheckColors4(colors: number[], count: number): number[];
  73493. }
  73494. /**
  73495. * @hidden
  73496. */
  73497. export class TmpColors {
  73498. static Color3: Color3[];
  73499. static Color4: Color4[];
  73500. }
  73501. }
  73502. declare module BABYLON {
  73503. /**
  73504. * Defines an interface which represents an animation key frame
  73505. */
  73506. export interface IAnimationKey {
  73507. /**
  73508. * Frame of the key frame
  73509. */
  73510. frame: number;
  73511. /**
  73512. * Value at the specifies key frame
  73513. */
  73514. value: any;
  73515. /**
  73516. * The input tangent for the cubic hermite spline
  73517. */
  73518. inTangent?: any;
  73519. /**
  73520. * The output tangent for the cubic hermite spline
  73521. */
  73522. outTangent?: any;
  73523. /**
  73524. * The animation interpolation type
  73525. */
  73526. interpolation?: AnimationKeyInterpolation;
  73527. }
  73528. /**
  73529. * Enum for the animation key frame interpolation type
  73530. */
  73531. export enum AnimationKeyInterpolation {
  73532. /**
  73533. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73534. */
  73535. STEP = 1
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. /**
  73540. * Represents the range of an animation
  73541. */
  73542. export class AnimationRange {
  73543. /**The name of the animation range**/
  73544. name: string;
  73545. /**The starting frame of the animation */
  73546. from: number;
  73547. /**The ending frame of the animation*/
  73548. to: number;
  73549. /**
  73550. * Initializes the range of an animation
  73551. * @param name The name of the animation range
  73552. * @param from The starting frame of the animation
  73553. * @param to The ending frame of the animation
  73554. */
  73555. constructor(
  73556. /**The name of the animation range**/
  73557. name: string,
  73558. /**The starting frame of the animation */
  73559. from: number,
  73560. /**The ending frame of the animation*/
  73561. to: number);
  73562. /**
  73563. * Makes a copy of the animation range
  73564. * @returns A copy of the animation range
  73565. */
  73566. clone(): AnimationRange;
  73567. }
  73568. }
  73569. declare module BABYLON {
  73570. /**
  73571. * Composed of a frame, and an action function
  73572. */
  73573. export class AnimationEvent {
  73574. /** The frame for which the event is triggered **/
  73575. frame: number;
  73576. /** The event to perform when triggered **/
  73577. action: (currentFrame: number) => void;
  73578. /** Specifies if the event should be triggered only once**/
  73579. onlyOnce?: boolean | undefined;
  73580. /**
  73581. * Specifies if the animation event is done
  73582. */
  73583. isDone: boolean;
  73584. /**
  73585. * Initializes the animation event
  73586. * @param frame The frame for which the event is triggered
  73587. * @param action The event to perform when triggered
  73588. * @param onlyOnce Specifies if the event should be triggered only once
  73589. */
  73590. constructor(
  73591. /** The frame for which the event is triggered **/
  73592. frame: number,
  73593. /** The event to perform when triggered **/
  73594. action: (currentFrame: number) => void,
  73595. /** Specifies if the event should be triggered only once**/
  73596. onlyOnce?: boolean | undefined);
  73597. /** @hidden */
  73598. _clone(): AnimationEvent;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Interface used to define a behavior
  73604. */
  73605. export interface Behavior<T> {
  73606. /** gets or sets behavior's name */
  73607. name: string;
  73608. /**
  73609. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73610. */
  73611. init(): void;
  73612. /**
  73613. * Called when the behavior is attached to a target
  73614. * @param target defines the target where the behavior is attached to
  73615. */
  73616. attach(target: T): void;
  73617. /**
  73618. * Called when the behavior is detached from its target
  73619. */
  73620. detach(): void;
  73621. }
  73622. /**
  73623. * Interface implemented by classes supporting behaviors
  73624. */
  73625. export interface IBehaviorAware<T> {
  73626. /**
  73627. * Attach a behavior
  73628. * @param behavior defines the behavior to attach
  73629. * @returns the current host
  73630. */
  73631. addBehavior(behavior: Behavior<T>): T;
  73632. /**
  73633. * Remove a behavior from the current object
  73634. * @param behavior defines the behavior to detach
  73635. * @returns the current host
  73636. */
  73637. removeBehavior(behavior: Behavior<T>): T;
  73638. /**
  73639. * Gets a behavior using its name to search
  73640. * @param name defines the name to search
  73641. * @returns the behavior or null if not found
  73642. */
  73643. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73644. }
  73645. }
  73646. declare module BABYLON {
  73647. /**
  73648. * Defines an array and its length.
  73649. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73650. */
  73651. export interface ISmartArrayLike<T> {
  73652. /**
  73653. * The data of the array.
  73654. */
  73655. data: Array<T>;
  73656. /**
  73657. * The active length of the array.
  73658. */
  73659. length: number;
  73660. }
  73661. /**
  73662. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73663. */
  73664. export class SmartArray<T> implements ISmartArrayLike<T> {
  73665. /**
  73666. * The full set of data from the array.
  73667. */
  73668. data: Array<T>;
  73669. /**
  73670. * The active length of the array.
  73671. */
  73672. length: number;
  73673. protected _id: number;
  73674. /**
  73675. * Instantiates a Smart Array.
  73676. * @param capacity defines the default capacity of the array.
  73677. */
  73678. constructor(capacity: number);
  73679. /**
  73680. * Pushes a value at the end of the active data.
  73681. * @param value defines the object to push in the array.
  73682. */
  73683. push(value: T): void;
  73684. /**
  73685. * Iterates over the active data and apply the lambda to them.
  73686. * @param func defines the action to apply on each value.
  73687. */
  73688. forEach(func: (content: T) => void): void;
  73689. /**
  73690. * Sorts the full sets of data.
  73691. * @param compareFn defines the comparison function to apply.
  73692. */
  73693. sort(compareFn: (a: T, b: T) => number): void;
  73694. /**
  73695. * Resets the active data to an empty array.
  73696. */
  73697. reset(): void;
  73698. /**
  73699. * Releases all the data from the array as well as the array.
  73700. */
  73701. dispose(): void;
  73702. /**
  73703. * Concats the active data with a given array.
  73704. * @param array defines the data to concatenate with.
  73705. */
  73706. concat(array: any): void;
  73707. /**
  73708. * Returns the position of a value in the active data.
  73709. * @param value defines the value to find the index for
  73710. * @returns the index if found in the active data otherwise -1
  73711. */
  73712. indexOf(value: T): number;
  73713. /**
  73714. * Returns whether an element is part of the active data.
  73715. * @param value defines the value to look for
  73716. * @returns true if found in the active data otherwise false
  73717. */
  73718. contains(value: T): boolean;
  73719. private static _GlobalId;
  73720. }
  73721. /**
  73722. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73723. * The data in this array can only be present once
  73724. */
  73725. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73726. private _duplicateId;
  73727. /**
  73728. * Pushes a value at the end of the active data.
  73729. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73730. * @param value defines the object to push in the array.
  73731. */
  73732. push(value: T): void;
  73733. /**
  73734. * Pushes a value at the end of the active data.
  73735. * If the data is already present, it won t be added again
  73736. * @param value defines the object to push in the array.
  73737. * @returns true if added false if it was already present
  73738. */
  73739. pushNoDuplicate(value: T): boolean;
  73740. /**
  73741. * Resets the active data to an empty array.
  73742. */
  73743. reset(): void;
  73744. /**
  73745. * Concats the active data with a given array.
  73746. * This ensures no dupplicate will be present in the result.
  73747. * @param array defines the data to concatenate with.
  73748. */
  73749. concatWithNoDuplicate(array: any): void;
  73750. }
  73751. }
  73752. declare module BABYLON {
  73753. /**
  73754. * @ignore
  73755. * This is a list of all the different input types that are available in the application.
  73756. * Fo instance: ArcRotateCameraGamepadInput...
  73757. */
  73758. export var CameraInputTypes: {};
  73759. /**
  73760. * This is the contract to implement in order to create a new input class.
  73761. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73762. */
  73763. export interface ICameraInput<TCamera extends Camera> {
  73764. /**
  73765. * Defines the camera the input is attached to.
  73766. */
  73767. camera: Nullable<TCamera>;
  73768. /**
  73769. * Gets the class name of the current intput.
  73770. * @returns the class name
  73771. */
  73772. getClassName(): string;
  73773. /**
  73774. * Get the friendly name associated with the input class.
  73775. * @returns the input friendly name
  73776. */
  73777. getSimpleName(): string;
  73778. /**
  73779. * Attach the input controls to a specific dom element to get the input from.
  73780. * @param element Defines the element the controls should be listened from
  73781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73782. */
  73783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73784. /**
  73785. * Detach the current controls from the specified dom element.
  73786. * @param element Defines the element to stop listening the inputs from
  73787. */
  73788. detachControl(element: Nullable<HTMLElement>): void;
  73789. /**
  73790. * Update the current camera state depending on the inputs that have been used this frame.
  73791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73792. */
  73793. checkInputs?: () => void;
  73794. }
  73795. /**
  73796. * Represents a map of input types to input instance or input index to input instance.
  73797. */
  73798. export interface CameraInputsMap<TCamera extends Camera> {
  73799. /**
  73800. * Accessor to the input by input type.
  73801. */
  73802. [name: string]: ICameraInput<TCamera>;
  73803. /**
  73804. * Accessor to the input by input index.
  73805. */
  73806. [idx: number]: ICameraInput<TCamera>;
  73807. }
  73808. /**
  73809. * This represents the input manager used within a camera.
  73810. * It helps dealing with all the different kind of input attached to a camera.
  73811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73812. */
  73813. export class CameraInputsManager<TCamera extends Camera> {
  73814. /**
  73815. * Defines the list of inputs attahed to the camera.
  73816. */
  73817. attached: CameraInputsMap<TCamera>;
  73818. /**
  73819. * Defines the dom element the camera is collecting inputs from.
  73820. * This is null if the controls have not been attached.
  73821. */
  73822. attachedElement: Nullable<HTMLElement>;
  73823. /**
  73824. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73825. */
  73826. noPreventDefault: boolean;
  73827. /**
  73828. * Defined the camera the input manager belongs to.
  73829. */
  73830. camera: TCamera;
  73831. /**
  73832. * Update the current camera state depending on the inputs that have been used this frame.
  73833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73834. */
  73835. checkInputs: () => void;
  73836. /**
  73837. * Instantiate a new Camera Input Manager.
  73838. * @param camera Defines the camera the input manager blongs to
  73839. */
  73840. constructor(camera: TCamera);
  73841. /**
  73842. * Add an input method to a camera
  73843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73844. * @param input camera input method
  73845. */
  73846. add(input: ICameraInput<TCamera>): void;
  73847. /**
  73848. * Remove a specific input method from a camera
  73849. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73850. * @param inputToRemove camera input method
  73851. */
  73852. remove(inputToRemove: ICameraInput<TCamera>): void;
  73853. /**
  73854. * Remove a specific input type from a camera
  73855. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73856. * @param inputType the type of the input to remove
  73857. */
  73858. removeByType(inputType: string): void;
  73859. private _addCheckInputs;
  73860. /**
  73861. * Attach the input controls to the currently attached dom element to listen the events from.
  73862. * @param input Defines the input to attach
  73863. */
  73864. attachInput(input: ICameraInput<TCamera>): void;
  73865. /**
  73866. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73867. * @param element Defines the dom element to collect the events from
  73868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73869. */
  73870. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73871. /**
  73872. * Detach the current manager inputs controls from a specific dom element.
  73873. * @param element Defines the dom element to collect the events from
  73874. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73875. */
  73876. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73877. /**
  73878. * Rebuild the dynamic inputCheck function from the current list of
  73879. * defined inputs in the manager.
  73880. */
  73881. rebuildInputCheck(): void;
  73882. /**
  73883. * Remove all attached input methods from a camera
  73884. */
  73885. clear(): void;
  73886. /**
  73887. * Serialize the current input manager attached to a camera.
  73888. * This ensures than once parsed,
  73889. * the input associated to the camera will be identical to the current ones
  73890. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73891. */
  73892. serialize(serializedCamera: any): void;
  73893. /**
  73894. * Parses an input manager serialized JSON to restore the previous list of inputs
  73895. * and states associated to a camera.
  73896. * @param parsedCamera Defines the JSON to parse
  73897. */
  73898. parse(parsedCamera: any): void;
  73899. }
  73900. }
  73901. declare module BABYLON {
  73902. /**
  73903. * Class used to store data that will be store in GPU memory
  73904. */
  73905. export class Buffer {
  73906. private _engine;
  73907. private _buffer;
  73908. /** @hidden */
  73909. _data: Nullable<DataArray>;
  73910. private _updatable;
  73911. private _instanced;
  73912. private _divisor;
  73913. /**
  73914. * Gets the byte stride.
  73915. */
  73916. readonly byteStride: number;
  73917. /**
  73918. * Constructor
  73919. * @param engine the engine
  73920. * @param data the data to use for this buffer
  73921. * @param updatable whether the data is updatable
  73922. * @param stride the stride (optional)
  73923. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73924. * @param instanced whether the buffer is instanced (optional)
  73925. * @param useBytes set to true if the stride in in bytes (optional)
  73926. * @param divisor sets an optional divisor for instances (1 by default)
  73927. */
  73928. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73929. /**
  73930. * Create a new VertexBuffer based on the current buffer
  73931. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73932. * @param offset defines offset in the buffer (0 by default)
  73933. * @param size defines the size in floats of attributes (position is 3 for instance)
  73934. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73935. * @param instanced defines if the vertex buffer contains indexed data
  73936. * @param useBytes defines if the offset and stride are in bytes *
  73937. * @param divisor sets an optional divisor for instances (1 by default)
  73938. * @returns the new vertex buffer
  73939. */
  73940. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73941. /**
  73942. * Gets a boolean indicating if the Buffer is updatable?
  73943. * @returns true if the buffer is updatable
  73944. */
  73945. isUpdatable(): boolean;
  73946. /**
  73947. * Gets current buffer's data
  73948. * @returns a DataArray or null
  73949. */
  73950. getData(): Nullable<DataArray>;
  73951. /**
  73952. * Gets underlying native buffer
  73953. * @returns underlying native buffer
  73954. */
  73955. getBuffer(): Nullable<DataBuffer>;
  73956. /**
  73957. * Gets the stride in float32 units (i.e. byte stride / 4).
  73958. * May not be an integer if the byte stride is not divisible by 4.
  73959. * DEPRECATED. Use byteStride instead.
  73960. * @returns the stride in float32 units
  73961. */
  73962. getStrideSize(): number;
  73963. /**
  73964. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73965. * @param data defines the data to store
  73966. */
  73967. create(data?: Nullable<DataArray>): void;
  73968. /** @hidden */
  73969. _rebuild(): void;
  73970. /**
  73971. * Update current buffer data
  73972. * @param data defines the data to store
  73973. */
  73974. update(data: DataArray): void;
  73975. /**
  73976. * Updates the data directly.
  73977. * @param data the new data
  73978. * @param offset the new offset
  73979. * @param vertexCount the vertex count (optional)
  73980. * @param useBytes set to true if the offset is in bytes
  73981. */
  73982. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73983. /**
  73984. * Release all resources
  73985. */
  73986. dispose(): void;
  73987. }
  73988. /**
  73989. * Specialized buffer used to store vertex data
  73990. */
  73991. export class VertexBuffer {
  73992. /** @hidden */
  73993. _buffer: Buffer;
  73994. private _kind;
  73995. private _size;
  73996. private _ownsBuffer;
  73997. private _instanced;
  73998. private _instanceDivisor;
  73999. /**
  74000. * The byte type.
  74001. */
  74002. static readonly BYTE: number;
  74003. /**
  74004. * The unsigned byte type.
  74005. */
  74006. static readonly UNSIGNED_BYTE: number;
  74007. /**
  74008. * The short type.
  74009. */
  74010. static readonly SHORT: number;
  74011. /**
  74012. * The unsigned short type.
  74013. */
  74014. static readonly UNSIGNED_SHORT: number;
  74015. /**
  74016. * The integer type.
  74017. */
  74018. static readonly INT: number;
  74019. /**
  74020. * The unsigned integer type.
  74021. */
  74022. static readonly UNSIGNED_INT: number;
  74023. /**
  74024. * The float type.
  74025. */
  74026. static readonly FLOAT: number;
  74027. /**
  74028. * Gets or sets the instance divisor when in instanced mode
  74029. */
  74030. instanceDivisor: number;
  74031. /**
  74032. * Gets the byte stride.
  74033. */
  74034. readonly byteStride: number;
  74035. /**
  74036. * Gets the byte offset.
  74037. */
  74038. readonly byteOffset: number;
  74039. /**
  74040. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74041. */
  74042. readonly normalized: boolean;
  74043. /**
  74044. * Gets the data type of each component in the array.
  74045. */
  74046. readonly type: number;
  74047. /**
  74048. * Constructor
  74049. * @param engine the engine
  74050. * @param data the data to use for this vertex buffer
  74051. * @param kind the vertex buffer kind
  74052. * @param updatable whether the data is updatable
  74053. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74054. * @param stride the stride (optional)
  74055. * @param instanced whether the buffer is instanced (optional)
  74056. * @param offset the offset of the data (optional)
  74057. * @param size the number of components (optional)
  74058. * @param type the type of the component (optional)
  74059. * @param normalized whether the data contains normalized data (optional)
  74060. * @param useBytes set to true if stride and offset are in bytes (optional)
  74061. * @param divisor defines the instance divisor to use (1 by default)
  74062. */
  74063. 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);
  74064. /** @hidden */
  74065. _rebuild(): void;
  74066. /**
  74067. * Returns the kind of the VertexBuffer (string)
  74068. * @returns a string
  74069. */
  74070. getKind(): string;
  74071. /**
  74072. * Gets a boolean indicating if the VertexBuffer is updatable?
  74073. * @returns true if the buffer is updatable
  74074. */
  74075. isUpdatable(): boolean;
  74076. /**
  74077. * Gets current buffer's data
  74078. * @returns a DataArray or null
  74079. */
  74080. getData(): Nullable<DataArray>;
  74081. /**
  74082. * Gets underlying native buffer
  74083. * @returns underlying native buffer
  74084. */
  74085. getBuffer(): Nullable<DataBuffer>;
  74086. /**
  74087. * Gets the stride in float32 units (i.e. byte stride / 4).
  74088. * May not be an integer if the byte stride is not divisible by 4.
  74089. * DEPRECATED. Use byteStride instead.
  74090. * @returns the stride in float32 units
  74091. */
  74092. getStrideSize(): number;
  74093. /**
  74094. * Returns the offset as a multiple of the type byte length.
  74095. * DEPRECATED. Use byteOffset instead.
  74096. * @returns the offset in bytes
  74097. */
  74098. getOffset(): number;
  74099. /**
  74100. * Returns the number of components per vertex attribute (integer)
  74101. * @returns the size in float
  74102. */
  74103. getSize(): number;
  74104. /**
  74105. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74106. * @returns true if this buffer is instanced
  74107. */
  74108. getIsInstanced(): boolean;
  74109. /**
  74110. * Returns the instancing divisor, zero for non-instanced (integer).
  74111. * @returns a number
  74112. */
  74113. getInstanceDivisor(): number;
  74114. /**
  74115. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74116. * @param data defines the data to store
  74117. */
  74118. create(data?: DataArray): void;
  74119. /**
  74120. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74121. * This function will create a new buffer if the current one is not updatable
  74122. * @param data defines the data to store
  74123. */
  74124. update(data: DataArray): void;
  74125. /**
  74126. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74127. * Returns the directly updated WebGLBuffer.
  74128. * @param data the new data
  74129. * @param offset the new offset
  74130. * @param useBytes set to true if the offset is in bytes
  74131. */
  74132. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74133. /**
  74134. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74135. */
  74136. dispose(): void;
  74137. /**
  74138. * Enumerates each value of this vertex buffer as numbers.
  74139. * @param count the number of values to enumerate
  74140. * @param callback the callback function called for each value
  74141. */
  74142. forEach(count: number, callback: (value: number, index: number) => void): void;
  74143. /**
  74144. * Positions
  74145. */
  74146. static readonly PositionKind: string;
  74147. /**
  74148. * Normals
  74149. */
  74150. static readonly NormalKind: string;
  74151. /**
  74152. * Tangents
  74153. */
  74154. static readonly TangentKind: string;
  74155. /**
  74156. * Texture coordinates
  74157. */
  74158. static readonly UVKind: string;
  74159. /**
  74160. * Texture coordinates 2
  74161. */
  74162. static readonly UV2Kind: string;
  74163. /**
  74164. * Texture coordinates 3
  74165. */
  74166. static readonly UV3Kind: string;
  74167. /**
  74168. * Texture coordinates 4
  74169. */
  74170. static readonly UV4Kind: string;
  74171. /**
  74172. * Texture coordinates 5
  74173. */
  74174. static readonly UV5Kind: string;
  74175. /**
  74176. * Texture coordinates 6
  74177. */
  74178. static readonly UV6Kind: string;
  74179. /**
  74180. * Colors
  74181. */
  74182. static readonly ColorKind: string;
  74183. /**
  74184. * Matrix indices (for bones)
  74185. */
  74186. static readonly MatricesIndicesKind: string;
  74187. /**
  74188. * Matrix weights (for bones)
  74189. */
  74190. static readonly MatricesWeightsKind: string;
  74191. /**
  74192. * Additional matrix indices (for bones)
  74193. */
  74194. static readonly MatricesIndicesExtraKind: string;
  74195. /**
  74196. * Additional matrix weights (for bones)
  74197. */
  74198. static readonly MatricesWeightsExtraKind: string;
  74199. /**
  74200. * Deduces the stride given a kind.
  74201. * @param kind The kind string to deduce
  74202. * @returns The deduced stride
  74203. */
  74204. static DeduceStride(kind: string): number;
  74205. /**
  74206. * Gets the byte length of the given type.
  74207. * @param type the type
  74208. * @returns the number of bytes
  74209. */
  74210. static GetTypeByteLength(type: number): number;
  74211. /**
  74212. * Enumerates each value of the given parameters as numbers.
  74213. * @param data the data to enumerate
  74214. * @param byteOffset the byte offset of the data
  74215. * @param byteStride the byte stride of the data
  74216. * @param componentCount the number of components per element
  74217. * @param componentType the type of the component
  74218. * @param count the number of values to enumerate
  74219. * @param normalized whether the data is normalized
  74220. * @param callback the callback function called for each value
  74221. */
  74222. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74223. private static _GetFloatValue;
  74224. }
  74225. }
  74226. declare module BABYLON {
  74227. /**
  74228. * @hidden
  74229. */
  74230. export class IntersectionInfo {
  74231. bu: Nullable<number>;
  74232. bv: Nullable<number>;
  74233. distance: number;
  74234. faceId: number;
  74235. subMeshId: number;
  74236. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74237. }
  74238. }
  74239. declare module BABYLON {
  74240. /**
  74241. * Represens a plane by the equation ax + by + cz + d = 0
  74242. */
  74243. export class Plane {
  74244. private static _TmpMatrix;
  74245. /**
  74246. * Normal of the plane (a,b,c)
  74247. */
  74248. normal: Vector3;
  74249. /**
  74250. * d component of the plane
  74251. */
  74252. d: number;
  74253. /**
  74254. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74255. * @param a a component of the plane
  74256. * @param b b component of the plane
  74257. * @param c c component of the plane
  74258. * @param d d component of the plane
  74259. */
  74260. constructor(a: number, b: number, c: number, d: number);
  74261. /**
  74262. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74263. */
  74264. asArray(): number[];
  74265. /**
  74266. * @returns a new plane copied from the current Plane.
  74267. */
  74268. clone(): Plane;
  74269. /**
  74270. * @returns the string "Plane".
  74271. */
  74272. getClassName(): string;
  74273. /**
  74274. * @returns the Plane hash code.
  74275. */
  74276. getHashCode(): number;
  74277. /**
  74278. * Normalize the current Plane in place.
  74279. * @returns the updated Plane.
  74280. */
  74281. normalize(): Plane;
  74282. /**
  74283. * Applies a transformation the plane and returns the result
  74284. * @param transformation the transformation matrix to be applied to the plane
  74285. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74286. */
  74287. transform(transformation: DeepImmutable<Matrix>): Plane;
  74288. /**
  74289. * Calcualtte the dot product between the point and the plane normal
  74290. * @param point point to calculate the dot product with
  74291. * @returns the dot product (float) of the point coordinates and the plane normal.
  74292. */
  74293. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74294. /**
  74295. * Updates the current Plane from the plane defined by the three given points.
  74296. * @param point1 one of the points used to contruct the plane
  74297. * @param point2 one of the points used to contruct the plane
  74298. * @param point3 one of the points used to contruct the plane
  74299. * @returns the updated Plane.
  74300. */
  74301. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74302. /**
  74303. * Checks if the plane is facing a given direction
  74304. * @param direction the direction to check if the plane is facing
  74305. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74306. * @returns True is the vector "direction" is the same side than the plane normal.
  74307. */
  74308. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74309. /**
  74310. * Calculates the distance to a point
  74311. * @param point point to calculate distance to
  74312. * @returns the signed distance (float) from the given point to the Plane.
  74313. */
  74314. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74315. /**
  74316. * Creates a plane from an array
  74317. * @param array the array to create a plane from
  74318. * @returns a new Plane from the given array.
  74319. */
  74320. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74321. /**
  74322. * Creates a plane from three points
  74323. * @param point1 point used to create the plane
  74324. * @param point2 point used to create the plane
  74325. * @param point3 point used to create the plane
  74326. * @returns a new Plane defined by the three given points.
  74327. */
  74328. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74329. /**
  74330. * Creates a plane from an origin point and a normal
  74331. * @param origin origin of the plane to be constructed
  74332. * @param normal normal of the plane to be constructed
  74333. * @returns a new Plane the normal vector to this plane at the given origin point.
  74334. * Note : the vector "normal" is updated because normalized.
  74335. */
  74336. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74337. /**
  74338. * Calculates the distance from a plane and a point
  74339. * @param origin origin of the plane to be constructed
  74340. * @param normal normal of the plane to be constructed
  74341. * @param point point to calculate distance to
  74342. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74343. */
  74344. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74345. }
  74346. }
  74347. declare module BABYLON {
  74348. /**
  74349. * Class used to store bounding sphere information
  74350. */
  74351. export class BoundingSphere {
  74352. /**
  74353. * Gets the center of the bounding sphere in local space
  74354. */
  74355. readonly center: Vector3;
  74356. /**
  74357. * Radius of the bounding sphere in local space
  74358. */
  74359. radius: number;
  74360. /**
  74361. * Gets the center of the bounding sphere in world space
  74362. */
  74363. readonly centerWorld: Vector3;
  74364. /**
  74365. * Radius of the bounding sphere in world space
  74366. */
  74367. radiusWorld: number;
  74368. /**
  74369. * Gets the minimum vector in local space
  74370. */
  74371. readonly minimum: Vector3;
  74372. /**
  74373. * Gets the maximum vector in local space
  74374. */
  74375. readonly maximum: Vector3;
  74376. private _worldMatrix;
  74377. private static readonly TmpVector3;
  74378. /**
  74379. * Creates a new bounding sphere
  74380. * @param min defines the minimum vector (in local space)
  74381. * @param max defines the maximum vector (in local space)
  74382. * @param worldMatrix defines the new world matrix
  74383. */
  74384. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74385. /**
  74386. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74387. * @param min defines the new minimum vector (in local space)
  74388. * @param max defines the new maximum vector (in local space)
  74389. * @param worldMatrix defines the new world matrix
  74390. */
  74391. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74392. /**
  74393. * Scale the current bounding sphere by applying a scale factor
  74394. * @param factor defines the scale factor to apply
  74395. * @returns the current bounding box
  74396. */
  74397. scale(factor: number): BoundingSphere;
  74398. /**
  74399. * Gets the world matrix of the bounding box
  74400. * @returns a matrix
  74401. */
  74402. getWorldMatrix(): DeepImmutable<Matrix>;
  74403. /** @hidden */
  74404. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74405. /**
  74406. * Tests if the bounding sphere is intersecting the frustum planes
  74407. * @param frustumPlanes defines the frustum planes to test
  74408. * @returns true if there is an intersection
  74409. */
  74410. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74411. /**
  74412. * Tests if the bounding sphere center is in between the frustum planes.
  74413. * Used for optimistic fast inclusion.
  74414. * @param frustumPlanes defines the frustum planes to test
  74415. * @returns true if the sphere center is in between the frustum planes
  74416. */
  74417. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74418. /**
  74419. * Tests if a point is inside the bounding sphere
  74420. * @param point defines the point to test
  74421. * @returns true if the point is inside the bounding sphere
  74422. */
  74423. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74424. /**
  74425. * Checks if two sphere intersct
  74426. * @param sphere0 sphere 0
  74427. * @param sphere1 sphere 1
  74428. * @returns true if the speres intersect
  74429. */
  74430. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74431. }
  74432. }
  74433. declare module BABYLON {
  74434. /**
  74435. * Class used to store bounding box information
  74436. */
  74437. export class BoundingBox implements ICullable {
  74438. /**
  74439. * Gets the 8 vectors representing the bounding box in local space
  74440. */
  74441. readonly vectors: Vector3[];
  74442. /**
  74443. * Gets the center of the bounding box in local space
  74444. */
  74445. readonly center: Vector3;
  74446. /**
  74447. * Gets the center of the bounding box in world space
  74448. */
  74449. readonly centerWorld: Vector3;
  74450. /**
  74451. * Gets the extend size in local space
  74452. */
  74453. readonly extendSize: Vector3;
  74454. /**
  74455. * Gets the extend size in world space
  74456. */
  74457. readonly extendSizeWorld: Vector3;
  74458. /**
  74459. * Gets the OBB (object bounding box) directions
  74460. */
  74461. readonly directions: Vector3[];
  74462. /**
  74463. * Gets the 8 vectors representing the bounding box in world space
  74464. */
  74465. readonly vectorsWorld: Vector3[];
  74466. /**
  74467. * Gets the minimum vector in world space
  74468. */
  74469. readonly minimumWorld: Vector3;
  74470. /**
  74471. * Gets the maximum vector in world space
  74472. */
  74473. readonly maximumWorld: Vector3;
  74474. /**
  74475. * Gets the minimum vector in local space
  74476. */
  74477. readonly minimum: Vector3;
  74478. /**
  74479. * Gets the maximum vector in local space
  74480. */
  74481. readonly maximum: Vector3;
  74482. private _worldMatrix;
  74483. private static readonly TmpVector3;
  74484. /**
  74485. * @hidden
  74486. */
  74487. _tag: number;
  74488. /**
  74489. * Creates a new bounding box
  74490. * @param min defines the minimum vector (in local space)
  74491. * @param max defines the maximum vector (in local space)
  74492. * @param worldMatrix defines the new world matrix
  74493. */
  74494. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74495. /**
  74496. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74497. * @param min defines the new minimum vector (in local space)
  74498. * @param max defines the new maximum vector (in local space)
  74499. * @param worldMatrix defines the new world matrix
  74500. */
  74501. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74502. /**
  74503. * Scale the current bounding box by applying a scale factor
  74504. * @param factor defines the scale factor to apply
  74505. * @returns the current bounding box
  74506. */
  74507. scale(factor: number): BoundingBox;
  74508. /**
  74509. * Gets the world matrix of the bounding box
  74510. * @returns a matrix
  74511. */
  74512. getWorldMatrix(): DeepImmutable<Matrix>;
  74513. /** @hidden */
  74514. _update(world: DeepImmutable<Matrix>): void;
  74515. /**
  74516. * Tests if the bounding box is intersecting the frustum planes
  74517. * @param frustumPlanes defines the frustum planes to test
  74518. * @returns true if there is an intersection
  74519. */
  74520. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74521. /**
  74522. * Tests if the bounding box is entirely inside the frustum planes
  74523. * @param frustumPlanes defines the frustum planes to test
  74524. * @returns true if there is an inclusion
  74525. */
  74526. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74527. /**
  74528. * Tests if a point is inside the bounding box
  74529. * @param point defines the point to test
  74530. * @returns true if the point is inside the bounding box
  74531. */
  74532. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74533. /**
  74534. * Tests if the bounding box intersects with a bounding sphere
  74535. * @param sphere defines the sphere to test
  74536. * @returns true if there is an intersection
  74537. */
  74538. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74539. /**
  74540. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74541. * @param min defines the min vector to use
  74542. * @param max defines the max vector to use
  74543. * @returns true if there is an intersection
  74544. */
  74545. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74546. /**
  74547. * Tests if two bounding boxes are intersections
  74548. * @param box0 defines the first box to test
  74549. * @param box1 defines the second box to test
  74550. * @returns true if there is an intersection
  74551. */
  74552. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74553. /**
  74554. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74555. * @param minPoint defines the minimum vector of the bounding box
  74556. * @param maxPoint defines the maximum vector of the bounding box
  74557. * @param sphereCenter defines the sphere center
  74558. * @param sphereRadius defines the sphere radius
  74559. * @returns true if there is an intersection
  74560. */
  74561. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74562. /**
  74563. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74564. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74565. * @param frustumPlanes defines the frustum planes to test
  74566. * @return true if there is an inclusion
  74567. */
  74568. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74569. /**
  74570. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74571. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74572. * @param frustumPlanes defines the frustum planes to test
  74573. * @return true if there is an intersection
  74574. */
  74575. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74576. }
  74577. }
  74578. declare module BABYLON {
  74579. /** @hidden */
  74580. export class Collider {
  74581. /** Define if a collision was found */
  74582. collisionFound: boolean;
  74583. /**
  74584. * Define last intersection point in local space
  74585. */
  74586. intersectionPoint: Vector3;
  74587. /**
  74588. * Define last collided mesh
  74589. */
  74590. collidedMesh: Nullable<AbstractMesh>;
  74591. private _collisionPoint;
  74592. private _planeIntersectionPoint;
  74593. private _tempVector;
  74594. private _tempVector2;
  74595. private _tempVector3;
  74596. private _tempVector4;
  74597. private _edge;
  74598. private _baseToVertex;
  74599. private _destinationPoint;
  74600. private _slidePlaneNormal;
  74601. private _displacementVector;
  74602. /** @hidden */
  74603. _radius: Vector3;
  74604. /** @hidden */
  74605. _retry: number;
  74606. private _velocity;
  74607. private _basePoint;
  74608. private _epsilon;
  74609. /** @hidden */
  74610. _velocityWorldLength: number;
  74611. /** @hidden */
  74612. _basePointWorld: Vector3;
  74613. private _velocityWorld;
  74614. private _normalizedVelocity;
  74615. /** @hidden */
  74616. _initialVelocity: Vector3;
  74617. /** @hidden */
  74618. _initialPosition: Vector3;
  74619. private _nearestDistance;
  74620. private _collisionMask;
  74621. collisionMask: number;
  74622. /**
  74623. * Gets the plane normal used to compute the sliding response (in local space)
  74624. */
  74625. readonly slidePlaneNormal: Vector3;
  74626. /** @hidden */
  74627. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74628. /** @hidden */
  74629. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74630. /** @hidden */
  74631. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74632. /** @hidden */
  74633. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74634. /** @hidden */
  74635. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74636. /** @hidden */
  74637. _getResponse(pos: Vector3, vel: Vector3): void;
  74638. }
  74639. }
  74640. declare module BABYLON {
  74641. /**
  74642. * Interface for cullable objects
  74643. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74644. */
  74645. export interface ICullable {
  74646. /**
  74647. * Checks if the object or part of the object is in the frustum
  74648. * @param frustumPlanes Camera near/planes
  74649. * @returns true if the object is in frustum otherwise false
  74650. */
  74651. isInFrustum(frustumPlanes: Plane[]): boolean;
  74652. /**
  74653. * Checks if a cullable object (mesh...) is in the camera frustum
  74654. * Unlike isInFrustum this cheks the full bounding box
  74655. * @param frustumPlanes Camera near/planes
  74656. * @returns true if the object is in frustum otherwise false
  74657. */
  74658. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74659. }
  74660. /**
  74661. * Info for a bounding data of a mesh
  74662. */
  74663. export class BoundingInfo implements ICullable {
  74664. /**
  74665. * Bounding box for the mesh
  74666. */
  74667. readonly boundingBox: BoundingBox;
  74668. /**
  74669. * Bounding sphere for the mesh
  74670. */
  74671. readonly boundingSphere: BoundingSphere;
  74672. private _isLocked;
  74673. private static readonly TmpVector3;
  74674. /**
  74675. * Constructs bounding info
  74676. * @param minimum min vector of the bounding box/sphere
  74677. * @param maximum max vector of the bounding box/sphere
  74678. * @param worldMatrix defines the new world matrix
  74679. */
  74680. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74681. /**
  74682. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74683. * @param min defines the new minimum vector (in local space)
  74684. * @param max defines the new maximum vector (in local space)
  74685. * @param worldMatrix defines the new world matrix
  74686. */
  74687. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74688. /**
  74689. * min vector of the bounding box/sphere
  74690. */
  74691. readonly minimum: Vector3;
  74692. /**
  74693. * max vector of the bounding box/sphere
  74694. */
  74695. readonly maximum: Vector3;
  74696. /**
  74697. * If the info is locked and won't be updated to avoid perf overhead
  74698. */
  74699. isLocked: boolean;
  74700. /**
  74701. * Updates the bounding sphere and box
  74702. * @param world world matrix to be used to update
  74703. */
  74704. update(world: DeepImmutable<Matrix>): void;
  74705. /**
  74706. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74707. * @param center New center of the bounding info
  74708. * @param extend New extend of the bounding info
  74709. * @returns the current bounding info
  74710. */
  74711. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74712. /**
  74713. * Scale the current bounding info by applying a scale factor
  74714. * @param factor defines the scale factor to apply
  74715. * @returns the current bounding info
  74716. */
  74717. scale(factor: number): BoundingInfo;
  74718. /**
  74719. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74720. * @param frustumPlanes defines the frustum to test
  74721. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74722. * @returns true if the bounding info is in the frustum planes
  74723. */
  74724. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74725. /**
  74726. * Gets the world distance between the min and max points of the bounding box
  74727. */
  74728. readonly diagonalLength: number;
  74729. /**
  74730. * Checks if a cullable object (mesh...) is in the camera frustum
  74731. * Unlike isInFrustum this cheks the full bounding box
  74732. * @param frustumPlanes Camera near/planes
  74733. * @returns true if the object is in frustum otherwise false
  74734. */
  74735. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74736. /** @hidden */
  74737. _checkCollision(collider: Collider): boolean;
  74738. /**
  74739. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74741. * @param point the point to check intersection with
  74742. * @returns if the point intersects
  74743. */
  74744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74745. /**
  74746. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74747. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74748. * @param boundingInfo the bounding info to check intersection with
  74749. * @param precise if the intersection should be done using OBB
  74750. * @returns if the bounding info intersects
  74751. */
  74752. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74753. }
  74754. }
  74755. declare module BABYLON {
  74756. /**
  74757. * Extracts minimum and maximum values from a list of indexed positions
  74758. * @param positions defines the positions to use
  74759. * @param indices defines the indices to the positions
  74760. * @param indexStart defines the start index
  74761. * @param indexCount defines the end index
  74762. * @param bias defines bias value to add to the result
  74763. * @return minimum and maximum values
  74764. */
  74765. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74766. minimum: Vector3;
  74767. maximum: Vector3;
  74768. };
  74769. /**
  74770. * Extracts minimum and maximum values from a list of positions
  74771. * @param positions defines the positions to use
  74772. * @param start defines the start index in the positions array
  74773. * @param count defines the number of positions to handle
  74774. * @param bias defines bias value to add to the result
  74775. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74776. * @return minimum and maximum values
  74777. */
  74778. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74779. minimum: Vector3;
  74780. maximum: Vector3;
  74781. };
  74782. }
  74783. declare module BABYLON {
  74784. /** @hidden */
  74785. export class WebGLDataBuffer extends DataBuffer {
  74786. private _buffer;
  74787. constructor(resource: WebGLBuffer);
  74788. readonly underlyingResource: any;
  74789. }
  74790. }
  74791. declare module BABYLON {
  74792. /** @hidden */
  74793. export class WebGLPipelineContext implements IPipelineContext {
  74794. engine: ThinEngine;
  74795. program: Nullable<WebGLProgram>;
  74796. context?: WebGLRenderingContext;
  74797. vertexShader?: WebGLShader;
  74798. fragmentShader?: WebGLShader;
  74799. isParallelCompiled: boolean;
  74800. onCompiled?: () => void;
  74801. transformFeedback?: WebGLTransformFeedback | null;
  74802. readonly isAsync: boolean;
  74803. readonly isReady: boolean;
  74804. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74805. }
  74806. }
  74807. declare module BABYLON {
  74808. interface ThinEngine {
  74809. /**
  74810. * Create an uniform buffer
  74811. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74812. * @param elements defines the content of the uniform buffer
  74813. * @returns the webGL uniform buffer
  74814. */
  74815. createUniformBuffer(elements: FloatArray): DataBuffer;
  74816. /**
  74817. * Create a dynamic uniform buffer
  74818. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74819. * @param elements defines the content of the uniform buffer
  74820. * @returns the webGL uniform buffer
  74821. */
  74822. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74823. /**
  74824. * Update an existing uniform buffer
  74825. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74826. * @param uniformBuffer defines the target uniform buffer
  74827. * @param elements defines the content to update
  74828. * @param offset defines the offset in the uniform buffer where update should start
  74829. * @param count defines the size of the data to update
  74830. */
  74831. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74832. /**
  74833. * Bind an uniform buffer to the current webGL context
  74834. * @param buffer defines the buffer to bind
  74835. */
  74836. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74837. /**
  74838. * Bind a buffer to the current webGL context at a given location
  74839. * @param buffer defines the buffer to bind
  74840. * @param location defines the index where to bind the buffer
  74841. */
  74842. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74843. /**
  74844. * Bind a specific block at a given index in a specific shader program
  74845. * @param pipelineContext defines the pipeline context to use
  74846. * @param blockName defines the block name
  74847. * @param index defines the index where to bind the block
  74848. */
  74849. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * Uniform buffer objects.
  74855. *
  74856. * Handles blocks of uniform on the GPU.
  74857. *
  74858. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74859. *
  74860. * For more information, please refer to :
  74861. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74862. */
  74863. export class UniformBuffer {
  74864. private _engine;
  74865. private _buffer;
  74866. private _data;
  74867. private _bufferData;
  74868. private _dynamic?;
  74869. private _uniformLocations;
  74870. private _uniformSizes;
  74871. private _uniformLocationPointer;
  74872. private _needSync;
  74873. private _noUBO;
  74874. private _currentEffect;
  74875. /** @hidden */
  74876. _alreadyBound: boolean;
  74877. private static _MAX_UNIFORM_SIZE;
  74878. private static _tempBuffer;
  74879. /**
  74880. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74881. * This is dynamic to allow compat with webgl 1 and 2.
  74882. * You will need to pass the name of the uniform as well as the value.
  74883. */
  74884. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74885. /**
  74886. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74887. * This is dynamic to allow compat with webgl 1 and 2.
  74888. * You will need to pass the name of the uniform as well as the value.
  74889. */
  74890. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74891. /**
  74892. * Lambda to Update a single float in a uniform buffer.
  74893. * This is dynamic to allow compat with webgl 1 and 2.
  74894. * You will need to pass the name of the uniform as well as the value.
  74895. */
  74896. updateFloat: (name: string, x: number) => void;
  74897. /**
  74898. * Lambda to Update a vec2 of float in a uniform buffer.
  74899. * This is dynamic to allow compat with webgl 1 and 2.
  74900. * You will need to pass the name of the uniform as well as the value.
  74901. */
  74902. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74903. /**
  74904. * Lambda to Update a vec3 of float in a uniform buffer.
  74905. * This is dynamic to allow compat with webgl 1 and 2.
  74906. * You will need to pass the name of the uniform as well as the value.
  74907. */
  74908. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74909. /**
  74910. * Lambda to Update a vec4 of float in a uniform buffer.
  74911. * This is dynamic to allow compat with webgl 1 and 2.
  74912. * You will need to pass the name of the uniform as well as the value.
  74913. */
  74914. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74915. /**
  74916. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74917. * This is dynamic to allow compat with webgl 1 and 2.
  74918. * You will need to pass the name of the uniform as well as the value.
  74919. */
  74920. updateMatrix: (name: string, mat: Matrix) => void;
  74921. /**
  74922. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74923. * This is dynamic to allow compat with webgl 1 and 2.
  74924. * You will need to pass the name of the uniform as well as the value.
  74925. */
  74926. updateVector3: (name: string, vector: Vector3) => void;
  74927. /**
  74928. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74929. * This is dynamic to allow compat with webgl 1 and 2.
  74930. * You will need to pass the name of the uniform as well as the value.
  74931. */
  74932. updateVector4: (name: string, vector: Vector4) => void;
  74933. /**
  74934. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74935. * This is dynamic to allow compat with webgl 1 and 2.
  74936. * You will need to pass the name of the uniform as well as the value.
  74937. */
  74938. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74939. /**
  74940. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74941. * This is dynamic to allow compat with webgl 1 and 2.
  74942. * You will need to pass the name of the uniform as well as the value.
  74943. */
  74944. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74945. /**
  74946. * Instantiates a new Uniform buffer objects.
  74947. *
  74948. * Handles blocks of uniform on the GPU.
  74949. *
  74950. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74951. *
  74952. * For more information, please refer to :
  74953. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74954. * @param engine Define the engine the buffer is associated with
  74955. * @param data Define the data contained in the buffer
  74956. * @param dynamic Define if the buffer is updatable
  74957. */
  74958. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74959. /**
  74960. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74961. * or just falling back on setUniformXXX calls.
  74962. */
  74963. readonly useUbo: boolean;
  74964. /**
  74965. * Indicates if the WebGL underlying uniform buffer is in sync
  74966. * with the javascript cache data.
  74967. */
  74968. readonly isSync: boolean;
  74969. /**
  74970. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74971. * Also, a dynamic UniformBuffer will disable cache verification and always
  74972. * update the underlying WebGL uniform buffer to the GPU.
  74973. * @returns if Dynamic, otherwise false
  74974. */
  74975. isDynamic(): boolean;
  74976. /**
  74977. * The data cache on JS side.
  74978. * @returns the underlying data as a float array
  74979. */
  74980. getData(): Float32Array;
  74981. /**
  74982. * The underlying WebGL Uniform buffer.
  74983. * @returns the webgl buffer
  74984. */
  74985. getBuffer(): Nullable<DataBuffer>;
  74986. /**
  74987. * std140 layout specifies how to align data within an UBO structure.
  74988. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74989. * for specs.
  74990. */
  74991. private _fillAlignment;
  74992. /**
  74993. * Adds an uniform in the buffer.
  74994. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74995. * for the layout to be correct !
  74996. * @param name Name of the uniform, as used in the uniform block in the shader.
  74997. * @param size Data size, or data directly.
  74998. */
  74999. addUniform(name: string, size: number | number[]): void;
  75000. /**
  75001. * Adds a Matrix 4x4 to the uniform buffer.
  75002. * @param name Name of the uniform, as used in the uniform block in the shader.
  75003. * @param mat A 4x4 matrix.
  75004. */
  75005. addMatrix(name: string, mat: Matrix): void;
  75006. /**
  75007. * Adds a vec2 to the uniform buffer.
  75008. * @param name Name of the uniform, as used in the uniform block in the shader.
  75009. * @param x Define the x component value of the vec2
  75010. * @param y Define the y component value of the vec2
  75011. */
  75012. addFloat2(name: string, x: number, y: number): void;
  75013. /**
  75014. * Adds a vec3 to the uniform buffer.
  75015. * @param name Name of the uniform, as used in the uniform block in the shader.
  75016. * @param x Define the x component value of the vec3
  75017. * @param y Define the y component value of the vec3
  75018. * @param z Define the z component value of the vec3
  75019. */
  75020. addFloat3(name: string, x: number, y: number, z: number): void;
  75021. /**
  75022. * Adds a vec3 to the uniform buffer.
  75023. * @param name Name of the uniform, as used in the uniform block in the shader.
  75024. * @param color Define the vec3 from a Color
  75025. */
  75026. addColor3(name: string, color: Color3): void;
  75027. /**
  75028. * Adds a vec4 to the uniform buffer.
  75029. * @param name Name of the uniform, as used in the uniform block in the shader.
  75030. * @param color Define the rgb components from a Color
  75031. * @param alpha Define the a component of the vec4
  75032. */
  75033. addColor4(name: string, color: Color3, alpha: number): void;
  75034. /**
  75035. * Adds a vec3 to the uniform buffer.
  75036. * @param name Name of the uniform, as used in the uniform block in the shader.
  75037. * @param vector Define the vec3 components from a Vector
  75038. */
  75039. addVector3(name: string, vector: Vector3): void;
  75040. /**
  75041. * Adds a Matrix 3x3 to the uniform buffer.
  75042. * @param name Name of the uniform, as used in the uniform block in the shader.
  75043. */
  75044. addMatrix3x3(name: string): void;
  75045. /**
  75046. * Adds a Matrix 2x2 to the uniform buffer.
  75047. * @param name Name of the uniform, as used in the uniform block in the shader.
  75048. */
  75049. addMatrix2x2(name: string): void;
  75050. /**
  75051. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75052. */
  75053. create(): void;
  75054. /** @hidden */
  75055. _rebuild(): void;
  75056. /**
  75057. * Updates the WebGL Uniform Buffer on the GPU.
  75058. * If the `dynamic` flag is set to true, no cache comparison is done.
  75059. * Otherwise, the buffer will be updated only if the cache differs.
  75060. */
  75061. update(): void;
  75062. /**
  75063. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75064. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75065. * @param data Define the flattened data
  75066. * @param size Define the size of the data.
  75067. */
  75068. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75069. private _valueCache;
  75070. private _cacheMatrix;
  75071. private _updateMatrix3x3ForUniform;
  75072. private _updateMatrix3x3ForEffect;
  75073. private _updateMatrix2x2ForEffect;
  75074. private _updateMatrix2x2ForUniform;
  75075. private _updateFloatForEffect;
  75076. private _updateFloatForUniform;
  75077. private _updateFloat2ForEffect;
  75078. private _updateFloat2ForUniform;
  75079. private _updateFloat3ForEffect;
  75080. private _updateFloat3ForUniform;
  75081. private _updateFloat4ForEffect;
  75082. private _updateFloat4ForUniform;
  75083. private _updateMatrixForEffect;
  75084. private _updateMatrixForUniform;
  75085. private _updateVector3ForEffect;
  75086. private _updateVector3ForUniform;
  75087. private _updateVector4ForEffect;
  75088. private _updateVector4ForUniform;
  75089. private _updateColor3ForEffect;
  75090. private _updateColor3ForUniform;
  75091. private _updateColor4ForEffect;
  75092. private _updateColor4ForUniform;
  75093. /**
  75094. * Sets a sampler uniform on the effect.
  75095. * @param name Define the name of the sampler.
  75096. * @param texture Define the texture to set in the sampler
  75097. */
  75098. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75099. /**
  75100. * Directly updates the value of the uniform in the cache AND on the GPU.
  75101. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75102. * @param data Define the flattened data
  75103. */
  75104. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75105. /**
  75106. * Binds this uniform buffer to an effect.
  75107. * @param effect Define the effect to bind the buffer to
  75108. * @param name Name of the uniform block in the shader.
  75109. */
  75110. bindToEffect(effect: Effect, name: string): void;
  75111. /**
  75112. * Disposes the uniform buffer.
  75113. */
  75114. dispose(): void;
  75115. }
  75116. }
  75117. declare module BABYLON {
  75118. /**
  75119. * Enum that determines the text-wrapping mode to use.
  75120. */
  75121. export enum InspectableType {
  75122. /**
  75123. * Checkbox for booleans
  75124. */
  75125. Checkbox = 0,
  75126. /**
  75127. * Sliders for numbers
  75128. */
  75129. Slider = 1,
  75130. /**
  75131. * Vector3
  75132. */
  75133. Vector3 = 2,
  75134. /**
  75135. * Quaternions
  75136. */
  75137. Quaternion = 3,
  75138. /**
  75139. * Color3
  75140. */
  75141. Color3 = 4,
  75142. /**
  75143. * String
  75144. */
  75145. String = 5
  75146. }
  75147. /**
  75148. * Interface used to define custom inspectable properties.
  75149. * This interface is used by the inspector to display custom property grids
  75150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75151. */
  75152. export interface IInspectable {
  75153. /**
  75154. * Gets the label to display
  75155. */
  75156. label: string;
  75157. /**
  75158. * Gets the name of the property to edit
  75159. */
  75160. propertyName: string;
  75161. /**
  75162. * Gets the type of the editor to use
  75163. */
  75164. type: InspectableType;
  75165. /**
  75166. * Gets the minimum value of the property when using in "slider" mode
  75167. */
  75168. min?: number;
  75169. /**
  75170. * Gets the maximum value of the property when using in "slider" mode
  75171. */
  75172. max?: number;
  75173. /**
  75174. * Gets the setp to use when using in "slider" mode
  75175. */
  75176. step?: number;
  75177. }
  75178. }
  75179. declare module BABYLON {
  75180. /**
  75181. * Class used to provide helper for timing
  75182. */
  75183. export class TimingTools {
  75184. /**
  75185. * Polyfill for setImmediate
  75186. * @param action defines the action to execute after the current execution block
  75187. */
  75188. static SetImmediate(action: () => void): void;
  75189. }
  75190. }
  75191. declare module BABYLON {
  75192. /**
  75193. * Class used to enable instatition of objects by class name
  75194. */
  75195. export class InstantiationTools {
  75196. /**
  75197. * Use this object to register external classes like custom textures or material
  75198. * to allow the laoders to instantiate them
  75199. */
  75200. static RegisteredExternalClasses: {
  75201. [key: string]: Object;
  75202. };
  75203. /**
  75204. * Tries to instantiate a new object from a given class name
  75205. * @param className defines the class name to instantiate
  75206. * @returns the new object or null if the system was not able to do the instantiation
  75207. */
  75208. static Instantiate(className: string): any;
  75209. }
  75210. }
  75211. declare module BABYLON {
  75212. /**
  75213. * Define options used to create a depth texture
  75214. */
  75215. export class DepthTextureCreationOptions {
  75216. /** Specifies whether or not a stencil should be allocated in the texture */
  75217. generateStencil?: boolean;
  75218. /** Specifies whether or not bilinear filtering is enable on the texture */
  75219. bilinearFiltering?: boolean;
  75220. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75221. comparisonFunction?: number;
  75222. /** Specifies if the created texture is a cube texture */
  75223. isCube?: boolean;
  75224. }
  75225. }
  75226. declare module BABYLON {
  75227. interface ThinEngine {
  75228. /**
  75229. * Creates a depth stencil cube texture.
  75230. * This is only available in WebGL 2.
  75231. * @param size The size of face edge in the cube texture.
  75232. * @param options The options defining the cube texture.
  75233. * @returns The cube texture
  75234. */
  75235. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75236. /**
  75237. * Creates a cube texture
  75238. * @param rootUrl defines the url where the files to load is located
  75239. * @param scene defines the current scene
  75240. * @param files defines the list of files to load (1 per face)
  75241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75242. * @param onLoad defines an optional callback raised when the texture is loaded
  75243. * @param onError defines an optional callback raised if there is an issue to load the texture
  75244. * @param format defines the format of the data
  75245. * @param forcedExtension defines the extension to use to pick the right loader
  75246. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75249. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75250. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75251. * @returns the cube texture as an InternalTexture
  75252. */
  75253. 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;
  75254. /**
  75255. * Creates a cube texture
  75256. * @param rootUrl defines the url where the files to load is located
  75257. * @param scene defines the current scene
  75258. * @param files defines the list of files to load (1 per face)
  75259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75260. * @param onLoad defines an optional callback raised when the texture is loaded
  75261. * @param onError defines an optional callback raised if there is an issue to load the texture
  75262. * @param format defines the format of the data
  75263. * @param forcedExtension defines the extension to use to pick the right loader
  75264. * @returns the cube texture as an InternalTexture
  75265. */
  75266. 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;
  75267. /**
  75268. * Creates a cube texture
  75269. * @param rootUrl defines the url where the files to load is located
  75270. * @param scene defines the current scene
  75271. * @param files defines the list of files to load (1 per face)
  75272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75273. * @param onLoad defines an optional callback raised when the texture is loaded
  75274. * @param onError defines an optional callback raised if there is an issue to load the texture
  75275. * @param format defines the format of the data
  75276. * @param forcedExtension defines the extension to use to pick the right loader
  75277. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75280. * @returns the cube texture as an InternalTexture
  75281. */
  75282. 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;
  75283. /** @hidden */
  75284. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75285. /** @hidden */
  75286. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75287. /** @hidden */
  75288. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75289. /** @hidden */
  75290. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75291. /**
  75292. * @hidden
  75293. */
  75294. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75295. }
  75296. }
  75297. declare module BABYLON {
  75298. /**
  75299. * Class for creating a cube texture
  75300. */
  75301. export class CubeTexture extends BaseTexture {
  75302. private _delayedOnLoad;
  75303. /**
  75304. * The url of the texture
  75305. */
  75306. url: string;
  75307. /**
  75308. * Gets or sets the center of the bounding box associated with the cube texture.
  75309. * It must define where the camera used to render the texture was set
  75310. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75311. */
  75312. boundingBoxPosition: Vector3;
  75313. private _boundingBoxSize;
  75314. /**
  75315. * Gets or sets the size of the bounding box associated with the cube texture
  75316. * When defined, the cubemap will switch to local mode
  75317. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75318. * @example https://www.babylonjs-playground.com/#RNASML
  75319. */
  75320. /**
  75321. * Returns the bounding box size
  75322. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75323. */
  75324. boundingBoxSize: Vector3;
  75325. protected _rotationY: number;
  75326. /**
  75327. * Sets texture matrix rotation angle around Y axis in radians.
  75328. */
  75329. /**
  75330. * Gets texture matrix rotation angle around Y axis radians.
  75331. */
  75332. rotationY: number;
  75333. /**
  75334. * Are mip maps generated for this texture or not.
  75335. */
  75336. readonly noMipmap: boolean;
  75337. private _noMipmap;
  75338. private _files;
  75339. protected _forcedExtension: Nullable<string>;
  75340. private _extensions;
  75341. private _textureMatrix;
  75342. private _format;
  75343. private _createPolynomials;
  75344. /** @hidden */
  75345. _prefiltered: boolean;
  75346. /**
  75347. * Creates a cube texture from an array of image urls
  75348. * @param files defines an array of image urls
  75349. * @param scene defines the hosting scene
  75350. * @param noMipmap specifies if mip maps are not used
  75351. * @returns a cube texture
  75352. */
  75353. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75354. /**
  75355. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75356. * @param url defines the url of the prefiltered texture
  75357. * @param scene defines the scene the texture is attached to
  75358. * @param forcedExtension defines the extension of the file if different from the url
  75359. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75360. * @return the prefiltered texture
  75361. */
  75362. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75363. /**
  75364. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75365. * as prefiltered data.
  75366. * @param rootUrl defines the url of the texture or the root name of the six images
  75367. * @param scene defines the scene the texture is attached to
  75368. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75369. * @param noMipmap defines if mipmaps should be created or not
  75370. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75371. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75372. * @param onError defines a callback triggered in case of error during load
  75373. * @param format defines the internal format to use for the texture once loaded
  75374. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75375. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75376. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75377. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75378. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75379. * @return the cube texture
  75380. */
  75381. 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);
  75382. /**
  75383. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75384. */
  75385. readonly isPrefiltered: boolean;
  75386. /**
  75387. * Get the current class name of the texture useful for serialization or dynamic coding.
  75388. * @returns "CubeTexture"
  75389. */
  75390. getClassName(): string;
  75391. /**
  75392. * Update the url (and optional buffer) of this texture if url was null during construction.
  75393. * @param url the url of the texture
  75394. * @param forcedExtension defines the extension to use
  75395. * @param onLoad callback called when the texture is loaded (defaults to null)
  75396. */
  75397. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75398. /**
  75399. * Delays loading of the cube texture
  75400. * @param forcedExtension defines the extension to use
  75401. */
  75402. delayLoad(forcedExtension?: string): void;
  75403. /**
  75404. * Returns the reflection texture matrix
  75405. * @returns the reflection texture matrix
  75406. */
  75407. getReflectionTextureMatrix(): Matrix;
  75408. /**
  75409. * Sets the reflection texture matrix
  75410. * @param value Reflection texture matrix
  75411. */
  75412. setReflectionTextureMatrix(value: Matrix): void;
  75413. /**
  75414. * Parses text to create a cube texture
  75415. * @param parsedTexture define the serialized text to read from
  75416. * @param scene defines the hosting scene
  75417. * @param rootUrl defines the root url of the cube texture
  75418. * @returns a cube texture
  75419. */
  75420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75421. /**
  75422. * Makes a clone, or deep copy, of the cube texture
  75423. * @returns a new cube texture
  75424. */
  75425. clone(): CubeTexture;
  75426. }
  75427. }
  75428. declare module BABYLON {
  75429. /**
  75430. * Manages the defines for the Material
  75431. */
  75432. export class MaterialDefines {
  75433. /** @hidden */
  75434. protected _keys: string[];
  75435. private _isDirty;
  75436. /** @hidden */
  75437. _renderId: number;
  75438. /** @hidden */
  75439. _areLightsDirty: boolean;
  75440. /** @hidden */
  75441. _areLightsDisposed: boolean;
  75442. /** @hidden */
  75443. _areAttributesDirty: boolean;
  75444. /** @hidden */
  75445. _areTexturesDirty: boolean;
  75446. /** @hidden */
  75447. _areFresnelDirty: boolean;
  75448. /** @hidden */
  75449. _areMiscDirty: boolean;
  75450. /** @hidden */
  75451. _areImageProcessingDirty: boolean;
  75452. /** @hidden */
  75453. _normals: boolean;
  75454. /** @hidden */
  75455. _uvs: boolean;
  75456. /** @hidden */
  75457. _needNormals: boolean;
  75458. /** @hidden */
  75459. _needUVs: boolean;
  75460. [id: string]: any;
  75461. /**
  75462. * Specifies if the material needs to be re-calculated
  75463. */
  75464. readonly isDirty: boolean;
  75465. /**
  75466. * Marks the material to indicate that it has been re-calculated
  75467. */
  75468. markAsProcessed(): void;
  75469. /**
  75470. * Marks the material to indicate that it needs to be re-calculated
  75471. */
  75472. markAsUnprocessed(): void;
  75473. /**
  75474. * Marks the material to indicate all of its defines need to be re-calculated
  75475. */
  75476. markAllAsDirty(): void;
  75477. /**
  75478. * Marks the material to indicate that image processing needs to be re-calculated
  75479. */
  75480. markAsImageProcessingDirty(): void;
  75481. /**
  75482. * Marks the material to indicate the lights need to be re-calculated
  75483. * @param disposed Defines whether the light is dirty due to dispose or not
  75484. */
  75485. markAsLightDirty(disposed?: boolean): void;
  75486. /**
  75487. * Marks the attribute state as changed
  75488. */
  75489. markAsAttributesDirty(): void;
  75490. /**
  75491. * Marks the texture state as changed
  75492. */
  75493. markAsTexturesDirty(): void;
  75494. /**
  75495. * Marks the fresnel state as changed
  75496. */
  75497. markAsFresnelDirty(): void;
  75498. /**
  75499. * Marks the misc state as changed
  75500. */
  75501. markAsMiscDirty(): void;
  75502. /**
  75503. * Rebuilds the material defines
  75504. */
  75505. rebuild(): void;
  75506. /**
  75507. * Specifies if two material defines are equal
  75508. * @param other - A material define instance to compare to
  75509. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75510. */
  75511. isEqual(other: MaterialDefines): boolean;
  75512. /**
  75513. * Clones this instance's defines to another instance
  75514. * @param other - material defines to clone values to
  75515. */
  75516. cloneTo(other: MaterialDefines): void;
  75517. /**
  75518. * Resets the material define values
  75519. */
  75520. reset(): void;
  75521. /**
  75522. * Converts the material define values to a string
  75523. * @returns - String of material define information
  75524. */
  75525. toString(): string;
  75526. }
  75527. }
  75528. declare module BABYLON {
  75529. /**
  75530. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75531. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75532. * 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;
  75533. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75534. */
  75535. export class ColorCurves {
  75536. private _dirty;
  75537. private _tempColor;
  75538. private _globalCurve;
  75539. private _highlightsCurve;
  75540. private _midtonesCurve;
  75541. private _shadowsCurve;
  75542. private _positiveCurve;
  75543. private _negativeCurve;
  75544. private _globalHue;
  75545. private _globalDensity;
  75546. private _globalSaturation;
  75547. private _globalExposure;
  75548. /**
  75549. * Gets the global Hue value.
  75550. * 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).
  75551. */
  75552. /**
  75553. * Sets the global Hue value.
  75554. * 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).
  75555. */
  75556. globalHue: number;
  75557. /**
  75558. * Gets the global Density value.
  75559. * 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.
  75560. * Values less than zero provide a filter of opposite hue.
  75561. */
  75562. /**
  75563. * Sets the global Density value.
  75564. * 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.
  75565. * Values less than zero provide a filter of opposite hue.
  75566. */
  75567. globalDensity: number;
  75568. /**
  75569. * Gets the global Saturation value.
  75570. * 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.
  75571. */
  75572. /**
  75573. * Sets the global Saturation value.
  75574. * 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.
  75575. */
  75576. globalSaturation: number;
  75577. /**
  75578. * Gets the global Exposure value.
  75579. * 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.
  75580. */
  75581. /**
  75582. * Sets the global Exposure value.
  75583. * 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.
  75584. */
  75585. globalExposure: number;
  75586. private _highlightsHue;
  75587. private _highlightsDensity;
  75588. private _highlightsSaturation;
  75589. private _highlightsExposure;
  75590. /**
  75591. * Gets the highlights Hue value.
  75592. * 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).
  75593. */
  75594. /**
  75595. * Sets the highlights Hue value.
  75596. * 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).
  75597. */
  75598. highlightsHue: number;
  75599. /**
  75600. * Gets the highlights Density value.
  75601. * 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.
  75602. * Values less than zero provide a filter of opposite hue.
  75603. */
  75604. /**
  75605. * Sets the highlights Density value.
  75606. * 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.
  75607. * Values less than zero provide a filter of opposite hue.
  75608. */
  75609. highlightsDensity: number;
  75610. /**
  75611. * Gets the highlights Saturation value.
  75612. * 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.
  75613. */
  75614. /**
  75615. * Sets the highlights Saturation value.
  75616. * 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.
  75617. */
  75618. highlightsSaturation: number;
  75619. /**
  75620. * Gets the highlights Exposure value.
  75621. * 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.
  75622. */
  75623. /**
  75624. * Sets the highlights Exposure value.
  75625. * 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.
  75626. */
  75627. highlightsExposure: number;
  75628. private _midtonesHue;
  75629. private _midtonesDensity;
  75630. private _midtonesSaturation;
  75631. private _midtonesExposure;
  75632. /**
  75633. * Gets the midtones Hue value.
  75634. * 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).
  75635. */
  75636. /**
  75637. * Sets the midtones Hue value.
  75638. * 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).
  75639. */
  75640. midtonesHue: number;
  75641. /**
  75642. * Gets the midtones Density value.
  75643. * 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.
  75644. * Values less than zero provide a filter of opposite hue.
  75645. */
  75646. /**
  75647. * Sets the midtones Density value.
  75648. * 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.
  75649. * Values less than zero provide a filter of opposite hue.
  75650. */
  75651. midtonesDensity: number;
  75652. /**
  75653. * Gets the midtones Saturation value.
  75654. * 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.
  75655. */
  75656. /**
  75657. * Sets the midtones Saturation value.
  75658. * 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.
  75659. */
  75660. midtonesSaturation: number;
  75661. /**
  75662. * Gets the midtones Exposure value.
  75663. * 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.
  75664. */
  75665. /**
  75666. * Sets the midtones Exposure value.
  75667. * 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.
  75668. */
  75669. midtonesExposure: number;
  75670. private _shadowsHue;
  75671. private _shadowsDensity;
  75672. private _shadowsSaturation;
  75673. private _shadowsExposure;
  75674. /**
  75675. * Gets the shadows Hue value.
  75676. * 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).
  75677. */
  75678. /**
  75679. * Sets the shadows Hue value.
  75680. * 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).
  75681. */
  75682. shadowsHue: number;
  75683. /**
  75684. * Gets the shadows Density value.
  75685. * 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.
  75686. * Values less than zero provide a filter of opposite hue.
  75687. */
  75688. /**
  75689. * Sets the shadows Density value.
  75690. * 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.
  75691. * Values less than zero provide a filter of opposite hue.
  75692. */
  75693. shadowsDensity: number;
  75694. /**
  75695. * Gets the shadows Saturation value.
  75696. * 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.
  75697. */
  75698. /**
  75699. * Sets the shadows Saturation value.
  75700. * 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.
  75701. */
  75702. shadowsSaturation: number;
  75703. /**
  75704. * Gets the shadows Exposure value.
  75705. * 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.
  75706. */
  75707. /**
  75708. * Sets the shadows Exposure value.
  75709. * 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.
  75710. */
  75711. shadowsExposure: number;
  75712. /**
  75713. * Returns the class name
  75714. * @returns The class name
  75715. */
  75716. getClassName(): string;
  75717. /**
  75718. * Binds the color curves to the shader.
  75719. * @param colorCurves The color curve to bind
  75720. * @param effect The effect to bind to
  75721. * @param positiveUniform The positive uniform shader parameter
  75722. * @param neutralUniform The neutral uniform shader parameter
  75723. * @param negativeUniform The negative uniform shader parameter
  75724. */
  75725. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75726. /**
  75727. * Prepare the list of uniforms associated with the ColorCurves effects.
  75728. * @param uniformsList The list of uniforms used in the effect
  75729. */
  75730. static PrepareUniforms(uniformsList: string[]): void;
  75731. /**
  75732. * Returns color grading data based on a hue, density, saturation and exposure value.
  75733. * @param filterHue The hue of the color filter.
  75734. * @param filterDensity The density of the color filter.
  75735. * @param saturation The saturation.
  75736. * @param exposure The exposure.
  75737. * @param result The result data container.
  75738. */
  75739. private getColorGradingDataToRef;
  75740. /**
  75741. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75742. * @param value The input slider value in range [-100,100].
  75743. * @returns Adjusted value.
  75744. */
  75745. private static applyColorGradingSliderNonlinear;
  75746. /**
  75747. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75748. * @param hue The hue (H) input.
  75749. * @param saturation The saturation (S) input.
  75750. * @param brightness The brightness (B) input.
  75751. * @result An RGBA color represented as Vector4.
  75752. */
  75753. private static fromHSBToRef;
  75754. /**
  75755. * Returns a value clamped between min and max
  75756. * @param value The value to clamp
  75757. * @param min The minimum of value
  75758. * @param max The maximum of value
  75759. * @returns The clamped value.
  75760. */
  75761. private static clamp;
  75762. /**
  75763. * Clones the current color curve instance.
  75764. * @return The cloned curves
  75765. */
  75766. clone(): ColorCurves;
  75767. /**
  75768. * Serializes the current color curve instance to a json representation.
  75769. * @return a JSON representation
  75770. */
  75771. serialize(): any;
  75772. /**
  75773. * Parses the color curve from a json representation.
  75774. * @param source the JSON source to parse
  75775. * @return The parsed curves
  75776. */
  75777. static Parse(source: any): ColorCurves;
  75778. }
  75779. }
  75780. declare module BABYLON {
  75781. /**
  75782. * Interface to follow in your material defines to integrate easily the
  75783. * Image proccessing functions.
  75784. * @hidden
  75785. */
  75786. export interface IImageProcessingConfigurationDefines {
  75787. IMAGEPROCESSING: boolean;
  75788. VIGNETTE: boolean;
  75789. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75790. VIGNETTEBLENDMODEOPAQUE: boolean;
  75791. TONEMAPPING: boolean;
  75792. TONEMAPPING_ACES: boolean;
  75793. CONTRAST: boolean;
  75794. EXPOSURE: boolean;
  75795. COLORCURVES: boolean;
  75796. COLORGRADING: boolean;
  75797. COLORGRADING3D: boolean;
  75798. SAMPLER3DGREENDEPTH: boolean;
  75799. SAMPLER3DBGRMAP: boolean;
  75800. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75801. }
  75802. /**
  75803. * @hidden
  75804. */
  75805. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75806. IMAGEPROCESSING: boolean;
  75807. VIGNETTE: boolean;
  75808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75809. VIGNETTEBLENDMODEOPAQUE: boolean;
  75810. TONEMAPPING: boolean;
  75811. TONEMAPPING_ACES: boolean;
  75812. CONTRAST: boolean;
  75813. COLORCURVES: boolean;
  75814. COLORGRADING: boolean;
  75815. COLORGRADING3D: boolean;
  75816. SAMPLER3DGREENDEPTH: boolean;
  75817. SAMPLER3DBGRMAP: boolean;
  75818. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75819. EXPOSURE: boolean;
  75820. constructor();
  75821. }
  75822. /**
  75823. * This groups together the common properties used for image processing either in direct forward pass
  75824. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75825. * or not.
  75826. */
  75827. export class ImageProcessingConfiguration {
  75828. /**
  75829. * Default tone mapping applied in BabylonJS.
  75830. */
  75831. static readonly TONEMAPPING_STANDARD: number;
  75832. /**
  75833. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75834. * to other engines rendering to increase portability.
  75835. */
  75836. static readonly TONEMAPPING_ACES: number;
  75837. /**
  75838. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75839. */
  75840. colorCurves: Nullable<ColorCurves>;
  75841. private _colorCurvesEnabled;
  75842. /**
  75843. * Gets wether the color curves effect is enabled.
  75844. */
  75845. /**
  75846. * Sets wether the color curves effect is enabled.
  75847. */
  75848. colorCurvesEnabled: boolean;
  75849. private _colorGradingTexture;
  75850. /**
  75851. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75852. */
  75853. /**
  75854. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75855. */
  75856. colorGradingTexture: Nullable<BaseTexture>;
  75857. private _colorGradingEnabled;
  75858. /**
  75859. * Gets wether the color grading effect is enabled.
  75860. */
  75861. /**
  75862. * Sets wether the color grading effect is enabled.
  75863. */
  75864. colorGradingEnabled: boolean;
  75865. private _colorGradingWithGreenDepth;
  75866. /**
  75867. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75868. */
  75869. /**
  75870. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75871. */
  75872. colorGradingWithGreenDepth: boolean;
  75873. private _colorGradingBGR;
  75874. /**
  75875. * Gets wether the color grading texture contains BGR values.
  75876. */
  75877. /**
  75878. * Sets wether the color grading texture contains BGR values.
  75879. */
  75880. colorGradingBGR: boolean;
  75881. /** @hidden */
  75882. _exposure: number;
  75883. /**
  75884. * Gets the Exposure used in the effect.
  75885. */
  75886. /**
  75887. * Sets the Exposure used in the effect.
  75888. */
  75889. exposure: number;
  75890. private _toneMappingEnabled;
  75891. /**
  75892. * Gets wether the tone mapping effect is enabled.
  75893. */
  75894. /**
  75895. * Sets wether the tone mapping effect is enabled.
  75896. */
  75897. toneMappingEnabled: boolean;
  75898. private _toneMappingType;
  75899. /**
  75900. * Gets the type of tone mapping effect.
  75901. */
  75902. /**
  75903. * Sets the type of tone mapping effect used in BabylonJS.
  75904. */
  75905. toneMappingType: number;
  75906. protected _contrast: number;
  75907. /**
  75908. * Gets the contrast used in the effect.
  75909. */
  75910. /**
  75911. * Sets the contrast used in the effect.
  75912. */
  75913. contrast: number;
  75914. /**
  75915. * Vignette stretch size.
  75916. */
  75917. vignetteStretch: number;
  75918. /**
  75919. * Vignette centre X Offset.
  75920. */
  75921. vignetteCentreX: number;
  75922. /**
  75923. * Vignette centre Y Offset.
  75924. */
  75925. vignetteCentreY: number;
  75926. /**
  75927. * Vignette weight or intensity of the vignette effect.
  75928. */
  75929. vignetteWeight: number;
  75930. /**
  75931. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75932. * if vignetteEnabled is set to true.
  75933. */
  75934. vignetteColor: Color4;
  75935. /**
  75936. * Camera field of view used by the Vignette effect.
  75937. */
  75938. vignetteCameraFov: number;
  75939. private _vignetteBlendMode;
  75940. /**
  75941. * Gets the vignette blend mode allowing different kind of effect.
  75942. */
  75943. /**
  75944. * Sets the vignette blend mode allowing different kind of effect.
  75945. */
  75946. vignetteBlendMode: number;
  75947. private _vignetteEnabled;
  75948. /**
  75949. * Gets wether the vignette effect is enabled.
  75950. */
  75951. /**
  75952. * Sets wether the vignette effect is enabled.
  75953. */
  75954. vignetteEnabled: boolean;
  75955. private _applyByPostProcess;
  75956. /**
  75957. * Gets wether the image processing is applied through a post process or not.
  75958. */
  75959. /**
  75960. * Sets wether the image processing is applied through a post process or not.
  75961. */
  75962. applyByPostProcess: boolean;
  75963. private _isEnabled;
  75964. /**
  75965. * Gets wether the image processing is enabled or not.
  75966. */
  75967. /**
  75968. * Sets wether the image processing is enabled or not.
  75969. */
  75970. isEnabled: boolean;
  75971. /**
  75972. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75973. */
  75974. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75975. /**
  75976. * Method called each time the image processing information changes requires to recompile the effect.
  75977. */
  75978. protected _updateParameters(): void;
  75979. /**
  75980. * Gets the current class name.
  75981. * @return "ImageProcessingConfiguration"
  75982. */
  75983. getClassName(): string;
  75984. /**
  75985. * Prepare the list of uniforms associated with the Image Processing effects.
  75986. * @param uniforms The list of uniforms used in the effect
  75987. * @param defines the list of defines currently in use
  75988. */
  75989. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75990. /**
  75991. * Prepare the list of samplers associated with the Image Processing effects.
  75992. * @param samplersList The list of uniforms used in the effect
  75993. * @param defines the list of defines currently in use
  75994. */
  75995. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75996. /**
  75997. * Prepare the list of defines associated to the shader.
  75998. * @param defines the list of defines to complete
  75999. * @param forPostProcess Define if we are currently in post process mode or not
  76000. */
  76001. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76002. /**
  76003. * Returns true if all the image processing information are ready.
  76004. * @returns True if ready, otherwise, false
  76005. */
  76006. isReady(): boolean;
  76007. /**
  76008. * Binds the image processing to the shader.
  76009. * @param effect The effect to bind to
  76010. * @param overrideAspectRatio Override the aspect ratio of the effect
  76011. */
  76012. bind(effect: Effect, overrideAspectRatio?: number): void;
  76013. /**
  76014. * Clones the current image processing instance.
  76015. * @return The cloned image processing
  76016. */
  76017. clone(): ImageProcessingConfiguration;
  76018. /**
  76019. * Serializes the current image processing instance to a json representation.
  76020. * @return a JSON representation
  76021. */
  76022. serialize(): any;
  76023. /**
  76024. * Parses the image processing from a json representation.
  76025. * @param source the JSON source to parse
  76026. * @return The parsed image processing
  76027. */
  76028. static Parse(source: any): ImageProcessingConfiguration;
  76029. private static _VIGNETTEMODE_MULTIPLY;
  76030. private static _VIGNETTEMODE_OPAQUE;
  76031. /**
  76032. * Used to apply the vignette as a mix with the pixel color.
  76033. */
  76034. static readonly VIGNETTEMODE_MULTIPLY: number;
  76035. /**
  76036. * Used to apply the vignette as a replacement of the pixel color.
  76037. */
  76038. static readonly VIGNETTEMODE_OPAQUE: number;
  76039. }
  76040. }
  76041. declare module BABYLON {
  76042. /** @hidden */
  76043. export var postprocessVertexShader: {
  76044. name: string;
  76045. shader: string;
  76046. };
  76047. }
  76048. declare module BABYLON {
  76049. interface ThinEngine {
  76050. /**
  76051. * Creates a new render target texture
  76052. * @param size defines the size of the texture
  76053. * @param options defines the options used to create the texture
  76054. * @returns a new render target texture stored in an InternalTexture
  76055. */
  76056. createRenderTargetTexture(size: number | {
  76057. width: number;
  76058. height: number;
  76059. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76060. /**
  76061. * Creates a depth stencil texture.
  76062. * This is only available in WebGL 2 or with the depth texture extension available.
  76063. * @param size The size of face edge in the texture.
  76064. * @param options The options defining the texture.
  76065. * @returns The texture
  76066. */
  76067. createDepthStencilTexture(size: number | {
  76068. width: number;
  76069. height: number;
  76070. }, options: DepthTextureCreationOptions): InternalTexture;
  76071. /** @hidden */
  76072. _createDepthStencilTexture(size: number | {
  76073. width: number;
  76074. height: number;
  76075. }, options: DepthTextureCreationOptions): InternalTexture;
  76076. }
  76077. }
  76078. declare module BABYLON {
  76079. /** Defines supported spaces */
  76080. export enum Space {
  76081. /** Local (object) space */
  76082. LOCAL = 0,
  76083. /** World space */
  76084. WORLD = 1,
  76085. /** Bone space */
  76086. BONE = 2
  76087. }
  76088. /** Defines the 3 main axes */
  76089. export class Axis {
  76090. /** X axis */
  76091. static X: Vector3;
  76092. /** Y axis */
  76093. static Y: Vector3;
  76094. /** Z axis */
  76095. static Z: Vector3;
  76096. }
  76097. }
  76098. declare module BABYLON {
  76099. /**
  76100. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76101. * This is the base of the follow, arc rotate cameras and Free camera
  76102. * @see http://doc.babylonjs.com/features/cameras
  76103. */
  76104. export class TargetCamera extends Camera {
  76105. private static _RigCamTransformMatrix;
  76106. private static _TargetTransformMatrix;
  76107. private static _TargetFocalPoint;
  76108. /**
  76109. * Define the current direction the camera is moving to
  76110. */
  76111. cameraDirection: Vector3;
  76112. /**
  76113. * Define the current rotation the camera is rotating to
  76114. */
  76115. cameraRotation: Vector2;
  76116. /**
  76117. * When set, the up vector of the camera will be updated by the rotation of the camera
  76118. */
  76119. updateUpVectorFromRotation: boolean;
  76120. private _tmpQuaternion;
  76121. /**
  76122. * Define the current rotation of the camera
  76123. */
  76124. rotation: Vector3;
  76125. /**
  76126. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76127. */
  76128. rotationQuaternion: Quaternion;
  76129. /**
  76130. * Define the current speed of the camera
  76131. */
  76132. speed: number;
  76133. /**
  76134. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76135. * around all axis.
  76136. */
  76137. noRotationConstraint: boolean;
  76138. /**
  76139. * Define the current target of the camera as an object or a position.
  76140. */
  76141. lockedTarget: any;
  76142. /** @hidden */
  76143. _currentTarget: Vector3;
  76144. /** @hidden */
  76145. _initialFocalDistance: number;
  76146. /** @hidden */
  76147. _viewMatrix: Matrix;
  76148. /** @hidden */
  76149. _camMatrix: Matrix;
  76150. /** @hidden */
  76151. _cameraTransformMatrix: Matrix;
  76152. /** @hidden */
  76153. _cameraRotationMatrix: Matrix;
  76154. /** @hidden */
  76155. _referencePoint: Vector3;
  76156. /** @hidden */
  76157. _transformedReferencePoint: Vector3;
  76158. protected _globalCurrentTarget: Vector3;
  76159. protected _globalCurrentUpVector: Vector3;
  76160. /** @hidden */
  76161. _reset: () => void;
  76162. private _defaultUp;
  76163. /**
  76164. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76165. * This is the base of the follow, arc rotate cameras and Free camera
  76166. * @see http://doc.babylonjs.com/features/cameras
  76167. * @param name Defines the name of the camera in the scene
  76168. * @param position Defines the start position of the camera in the scene
  76169. * @param scene Defines the scene the camera belongs to
  76170. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76171. */
  76172. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76173. /**
  76174. * Gets the position in front of the camera at a given distance.
  76175. * @param distance The distance from the camera we want the position to be
  76176. * @returns the position
  76177. */
  76178. getFrontPosition(distance: number): Vector3;
  76179. /** @hidden */
  76180. _getLockedTargetPosition(): Nullable<Vector3>;
  76181. private _storedPosition;
  76182. private _storedRotation;
  76183. private _storedRotationQuaternion;
  76184. /**
  76185. * Store current camera state of the camera (fov, position, rotation, etc..)
  76186. * @returns the camera
  76187. */
  76188. storeState(): Camera;
  76189. /**
  76190. * Restored camera state. You must call storeState() first
  76191. * @returns whether it was successful or not
  76192. * @hidden
  76193. */
  76194. _restoreStateValues(): boolean;
  76195. /** @hidden */
  76196. _initCache(): void;
  76197. /** @hidden */
  76198. _updateCache(ignoreParentClass?: boolean): void;
  76199. /** @hidden */
  76200. _isSynchronizedViewMatrix(): boolean;
  76201. /** @hidden */
  76202. _computeLocalCameraSpeed(): number;
  76203. /**
  76204. * Defines the target the camera should look at.
  76205. * @param target Defines the new target as a Vector or a mesh
  76206. */
  76207. setTarget(target: Vector3): void;
  76208. /**
  76209. * Return the current target position of the camera. This value is expressed in local space.
  76210. * @returns the target position
  76211. */
  76212. getTarget(): Vector3;
  76213. /** @hidden */
  76214. _decideIfNeedsToMove(): boolean;
  76215. /** @hidden */
  76216. _updatePosition(): void;
  76217. /** @hidden */
  76218. _checkInputs(): void;
  76219. protected _updateCameraRotationMatrix(): void;
  76220. /**
  76221. * 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)
  76222. * @returns the current camera
  76223. */
  76224. private _rotateUpVectorWithCameraRotationMatrix;
  76225. private _cachedRotationZ;
  76226. private _cachedQuaternionRotationZ;
  76227. /** @hidden */
  76228. _getViewMatrix(): Matrix;
  76229. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76230. /**
  76231. * @hidden
  76232. */
  76233. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76234. /**
  76235. * @hidden
  76236. */
  76237. _updateRigCameras(): void;
  76238. private _getRigCamPositionAndTarget;
  76239. /**
  76240. * Gets the current object class name.
  76241. * @return the class name
  76242. */
  76243. getClassName(): string;
  76244. }
  76245. }
  76246. declare module BABYLON {
  76247. /**
  76248. * Gather the list of keyboard event types as constants.
  76249. */
  76250. export class KeyboardEventTypes {
  76251. /**
  76252. * The keydown event is fired when a key becomes active (pressed).
  76253. */
  76254. static readonly KEYDOWN: number;
  76255. /**
  76256. * The keyup event is fired when a key has been released.
  76257. */
  76258. static readonly KEYUP: number;
  76259. }
  76260. /**
  76261. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76262. */
  76263. export class KeyboardInfo {
  76264. /**
  76265. * Defines the type of event (KeyboardEventTypes)
  76266. */
  76267. type: number;
  76268. /**
  76269. * Defines the related dom event
  76270. */
  76271. event: KeyboardEvent;
  76272. /**
  76273. * Instantiates a new keyboard info.
  76274. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76275. * @param type Defines the type of event (KeyboardEventTypes)
  76276. * @param event Defines the related dom event
  76277. */
  76278. constructor(
  76279. /**
  76280. * Defines the type of event (KeyboardEventTypes)
  76281. */
  76282. type: number,
  76283. /**
  76284. * Defines the related dom event
  76285. */
  76286. event: KeyboardEvent);
  76287. }
  76288. /**
  76289. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76290. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76291. */
  76292. export class KeyboardInfoPre extends KeyboardInfo {
  76293. /**
  76294. * Defines the type of event (KeyboardEventTypes)
  76295. */
  76296. type: number;
  76297. /**
  76298. * Defines the related dom event
  76299. */
  76300. event: KeyboardEvent;
  76301. /**
  76302. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76303. */
  76304. skipOnPointerObservable: boolean;
  76305. /**
  76306. * Instantiates a new keyboard pre info.
  76307. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76308. * @param type Defines the type of event (KeyboardEventTypes)
  76309. * @param event Defines the related dom event
  76310. */
  76311. constructor(
  76312. /**
  76313. * Defines the type of event (KeyboardEventTypes)
  76314. */
  76315. type: number,
  76316. /**
  76317. * Defines the related dom event
  76318. */
  76319. event: KeyboardEvent);
  76320. }
  76321. }
  76322. declare module BABYLON {
  76323. /**
  76324. * Manage the keyboard inputs to control the movement of a free camera.
  76325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76326. */
  76327. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76328. /**
  76329. * Defines the camera the input is attached to.
  76330. */
  76331. camera: FreeCamera;
  76332. /**
  76333. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76334. */
  76335. keysUp: number[];
  76336. /**
  76337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76338. */
  76339. keysDown: number[];
  76340. /**
  76341. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76342. */
  76343. keysLeft: number[];
  76344. /**
  76345. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76346. */
  76347. keysRight: number[];
  76348. private _keys;
  76349. private _onCanvasBlurObserver;
  76350. private _onKeyboardObserver;
  76351. private _engine;
  76352. private _scene;
  76353. /**
  76354. * Attach the input controls to a specific dom element to get the input from.
  76355. * @param element Defines the element the controls should be listened from
  76356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76357. */
  76358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76359. /**
  76360. * Detach the current controls from the specified dom element.
  76361. * @param element Defines the element to stop listening the inputs from
  76362. */
  76363. detachControl(element: Nullable<HTMLElement>): void;
  76364. /**
  76365. * Update the current camera state depending on the inputs that have been used this frame.
  76366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76367. */
  76368. checkInputs(): void;
  76369. /**
  76370. * Gets the class name of the current intput.
  76371. * @returns the class name
  76372. */
  76373. getClassName(): string;
  76374. /** @hidden */
  76375. _onLostFocus(): void;
  76376. /**
  76377. * Get the friendly name associated with the input class.
  76378. * @returns the input friendly name
  76379. */
  76380. getSimpleName(): string;
  76381. }
  76382. }
  76383. declare module BABYLON {
  76384. /**
  76385. * Interface describing all the common properties and methods a shadow light needs to implement.
  76386. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76387. * as well as binding the different shadow properties to the effects.
  76388. */
  76389. export interface IShadowLight extends Light {
  76390. /**
  76391. * The light id in the scene (used in scene.findLighById for instance)
  76392. */
  76393. id: string;
  76394. /**
  76395. * The position the shdow will be casted from.
  76396. */
  76397. position: Vector3;
  76398. /**
  76399. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76400. */
  76401. direction: Vector3;
  76402. /**
  76403. * The transformed position. Position of the light in world space taking parenting in account.
  76404. */
  76405. transformedPosition: Vector3;
  76406. /**
  76407. * The transformed direction. Direction of the light in world space taking parenting in account.
  76408. */
  76409. transformedDirection: Vector3;
  76410. /**
  76411. * The friendly name of the light in the scene.
  76412. */
  76413. name: string;
  76414. /**
  76415. * Defines the shadow projection clipping minimum z value.
  76416. */
  76417. shadowMinZ: number;
  76418. /**
  76419. * Defines the shadow projection clipping maximum z value.
  76420. */
  76421. shadowMaxZ: number;
  76422. /**
  76423. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76424. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76425. */
  76426. computeTransformedInformation(): boolean;
  76427. /**
  76428. * Gets the scene the light belongs to.
  76429. * @returns The scene
  76430. */
  76431. getScene(): Scene;
  76432. /**
  76433. * Callback defining a custom Projection Matrix Builder.
  76434. * This can be used to override the default projection matrix computation.
  76435. */
  76436. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76437. /**
  76438. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76439. * @param matrix The materix to updated with the projection information
  76440. * @param viewMatrix The transform matrix of the light
  76441. * @param renderList The list of mesh to render in the map
  76442. * @returns The current light
  76443. */
  76444. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76445. /**
  76446. * Gets the current depth scale used in ESM.
  76447. * @returns The scale
  76448. */
  76449. getDepthScale(): number;
  76450. /**
  76451. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76452. * @returns true if a cube texture needs to be use
  76453. */
  76454. needCube(): boolean;
  76455. /**
  76456. * Detects if the projection matrix requires to be recomputed this frame.
  76457. * @returns true if it requires to be recomputed otherwise, false.
  76458. */
  76459. needProjectionMatrixCompute(): boolean;
  76460. /**
  76461. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76462. */
  76463. forceProjectionMatrixCompute(): void;
  76464. /**
  76465. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76466. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76467. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76468. */
  76469. getShadowDirection(faceIndex?: number): Vector3;
  76470. /**
  76471. * Gets the minZ used for shadow according to both the scene and the light.
  76472. * @param activeCamera The camera we are returning the min for
  76473. * @returns the depth min z
  76474. */
  76475. getDepthMinZ(activeCamera: Camera): number;
  76476. /**
  76477. * Gets the maxZ used for shadow according to both the scene and the light.
  76478. * @param activeCamera The camera we are returning the max for
  76479. * @returns the depth max z
  76480. */
  76481. getDepthMaxZ(activeCamera: Camera): number;
  76482. }
  76483. /**
  76484. * Base implementation IShadowLight
  76485. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76486. */
  76487. export abstract class ShadowLight extends Light implements IShadowLight {
  76488. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76489. protected _position: Vector3;
  76490. protected _setPosition(value: Vector3): void;
  76491. /**
  76492. * Sets the position the shadow will be casted from. Also use as the light position for both
  76493. * point and spot lights.
  76494. */
  76495. /**
  76496. * Sets the position the shadow will be casted from. Also use as the light position for both
  76497. * point and spot lights.
  76498. */
  76499. position: Vector3;
  76500. protected _direction: Vector3;
  76501. protected _setDirection(value: Vector3): void;
  76502. /**
  76503. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76504. * Also use as the light direction on spot and directional lights.
  76505. */
  76506. /**
  76507. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76508. * Also use as the light direction on spot and directional lights.
  76509. */
  76510. direction: Vector3;
  76511. private _shadowMinZ;
  76512. /**
  76513. * Gets the shadow projection clipping minimum z value.
  76514. */
  76515. /**
  76516. * Sets the shadow projection clipping minimum z value.
  76517. */
  76518. shadowMinZ: number;
  76519. private _shadowMaxZ;
  76520. /**
  76521. * Sets the shadow projection clipping maximum z value.
  76522. */
  76523. /**
  76524. * Gets the shadow projection clipping maximum z value.
  76525. */
  76526. shadowMaxZ: number;
  76527. /**
  76528. * Callback defining a custom Projection Matrix Builder.
  76529. * This can be used to override the default projection matrix computation.
  76530. */
  76531. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76532. /**
  76533. * The transformed position. Position of the light in world space taking parenting in account.
  76534. */
  76535. transformedPosition: Vector3;
  76536. /**
  76537. * The transformed direction. Direction of the light in world space taking parenting in account.
  76538. */
  76539. transformedDirection: Vector3;
  76540. private _needProjectionMatrixCompute;
  76541. /**
  76542. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76543. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76544. */
  76545. computeTransformedInformation(): boolean;
  76546. /**
  76547. * Return the depth scale used for the shadow map.
  76548. * @returns the depth scale.
  76549. */
  76550. getDepthScale(): number;
  76551. /**
  76552. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76553. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76554. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76555. */
  76556. getShadowDirection(faceIndex?: number): Vector3;
  76557. /**
  76558. * Returns the ShadowLight absolute position in the World.
  76559. * @returns the position vector in world space
  76560. */
  76561. getAbsolutePosition(): Vector3;
  76562. /**
  76563. * Sets the ShadowLight direction toward the passed target.
  76564. * @param target The point to target in local space
  76565. * @returns the updated ShadowLight direction
  76566. */
  76567. setDirectionToTarget(target: Vector3): Vector3;
  76568. /**
  76569. * Returns the light rotation in euler definition.
  76570. * @returns the x y z rotation in local space.
  76571. */
  76572. getRotation(): Vector3;
  76573. /**
  76574. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76575. * @returns true if a cube texture needs to be use
  76576. */
  76577. needCube(): boolean;
  76578. /**
  76579. * Detects if the projection matrix requires to be recomputed this frame.
  76580. * @returns true if it requires to be recomputed otherwise, false.
  76581. */
  76582. needProjectionMatrixCompute(): boolean;
  76583. /**
  76584. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76585. */
  76586. forceProjectionMatrixCompute(): void;
  76587. /** @hidden */
  76588. _initCache(): void;
  76589. /** @hidden */
  76590. _isSynchronized(): boolean;
  76591. /**
  76592. * Computes the world matrix of the node
  76593. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76594. * @returns the world matrix
  76595. */
  76596. computeWorldMatrix(force?: boolean): Matrix;
  76597. /**
  76598. * Gets the minZ used for shadow according to both the scene and the light.
  76599. * @param activeCamera The camera we are returning the min for
  76600. * @returns the depth min z
  76601. */
  76602. getDepthMinZ(activeCamera: Camera): number;
  76603. /**
  76604. * Gets the maxZ used for shadow according to both the scene and the light.
  76605. * @param activeCamera The camera we are returning the max for
  76606. * @returns the depth max z
  76607. */
  76608. getDepthMaxZ(activeCamera: Camera): number;
  76609. /**
  76610. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76611. * @param matrix The materix to updated with the projection information
  76612. * @param viewMatrix The transform matrix of the light
  76613. * @param renderList The list of mesh to render in the map
  76614. * @returns The current light
  76615. */
  76616. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76617. }
  76618. }
  76619. declare module BABYLON {
  76620. /**
  76621. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76622. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76623. */
  76624. export class EffectFallbacks implements IEffectFallbacks {
  76625. private _defines;
  76626. private _currentRank;
  76627. private _maxRank;
  76628. private _mesh;
  76629. /**
  76630. * Removes the fallback from the bound mesh.
  76631. */
  76632. unBindMesh(): void;
  76633. /**
  76634. * Adds a fallback on the specified property.
  76635. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76636. * @param define The name of the define in the shader
  76637. */
  76638. addFallback(rank: number, define: string): void;
  76639. /**
  76640. * Sets the mesh to use CPU skinning when needing to fallback.
  76641. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76642. * @param mesh The mesh to use the fallbacks.
  76643. */
  76644. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76645. /**
  76646. * Checks to see if more fallbacks are still availible.
  76647. */
  76648. readonly hasMoreFallbacks: boolean;
  76649. /**
  76650. * Removes the defines that should be removed when falling back.
  76651. * @param currentDefines defines the current define statements for the shader.
  76652. * @param effect defines the current effect we try to compile
  76653. * @returns The resulting defines with defines of the current rank removed.
  76654. */
  76655. reduce(currentDefines: string, effect: Effect): string;
  76656. }
  76657. }
  76658. declare module BABYLON {
  76659. /**
  76660. * "Static Class" containing the most commonly used helper while dealing with material for
  76661. * rendering purpose.
  76662. *
  76663. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76664. *
  76665. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76666. */
  76667. export class MaterialHelper {
  76668. /**
  76669. * Bind the current view position to an effect.
  76670. * @param effect The effect to be bound
  76671. * @param scene The scene the eyes position is used from
  76672. */
  76673. static BindEyePosition(effect: Effect, scene: Scene): void;
  76674. /**
  76675. * Helps preparing the defines values about the UVs in used in the effect.
  76676. * UVs are shared as much as we can accross channels in the shaders.
  76677. * @param texture The texture we are preparing the UVs for
  76678. * @param defines The defines to update
  76679. * @param key The channel key "diffuse", "specular"... used in the shader
  76680. */
  76681. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76682. /**
  76683. * Binds a texture matrix value to its corrsponding uniform
  76684. * @param texture The texture to bind the matrix for
  76685. * @param uniformBuffer The uniform buffer receivin the data
  76686. * @param key The channel key "diffuse", "specular"... used in the shader
  76687. */
  76688. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76689. /**
  76690. * Gets the current status of the fog (should it be enabled?)
  76691. * @param mesh defines the mesh to evaluate for fog support
  76692. * @param scene defines the hosting scene
  76693. * @returns true if fog must be enabled
  76694. */
  76695. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76696. /**
  76697. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76698. * @param mesh defines the current mesh
  76699. * @param scene defines the current scene
  76700. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76701. * @param pointsCloud defines if point cloud rendering has to be turned on
  76702. * @param fogEnabled defines if fog has to be turned on
  76703. * @param alphaTest defines if alpha testing has to be turned on
  76704. * @param defines defines the current list of defines
  76705. */
  76706. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76707. /**
  76708. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76709. * @param scene defines the current scene
  76710. * @param engine defines the current engine
  76711. * @param defines specifies the list of active defines
  76712. * @param useInstances defines if instances have to be turned on
  76713. * @param useClipPlane defines if clip plane have to be turned on
  76714. */
  76715. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76716. /**
  76717. * Prepares the defines for bones
  76718. * @param mesh The mesh containing the geometry data we will draw
  76719. * @param defines The defines to update
  76720. */
  76721. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76722. /**
  76723. * Prepares the defines for morph targets
  76724. * @param mesh The mesh containing the geometry data we will draw
  76725. * @param defines The defines to update
  76726. */
  76727. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76728. /**
  76729. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76730. * @param mesh The mesh containing the geometry data we will draw
  76731. * @param defines The defines to update
  76732. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76733. * @param useBones Precise whether bones should be used or not (override mesh info)
  76734. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76735. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76736. * @returns false if defines are considered not dirty and have not been checked
  76737. */
  76738. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76739. /**
  76740. * Prepares the defines related to multiview
  76741. * @param scene The scene we are intending to draw
  76742. * @param defines The defines to update
  76743. */
  76744. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76745. /**
  76746. * Prepares the defines related to the light information passed in parameter
  76747. * @param scene The scene we are intending to draw
  76748. * @param mesh The mesh the effect is compiling for
  76749. * @param light The light the effect is compiling for
  76750. * @param lightIndex The index of the light
  76751. * @param defines The defines to update
  76752. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76753. * @param state Defines the current state regarding what is needed (normals, etc...)
  76754. */
  76755. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76756. needNormals: boolean;
  76757. needRebuild: boolean;
  76758. shadowEnabled: boolean;
  76759. specularEnabled: boolean;
  76760. lightmapMode: boolean;
  76761. }): void;
  76762. /**
  76763. * Prepares the defines related to the light information passed in parameter
  76764. * @param scene The scene we are intending to draw
  76765. * @param mesh The mesh the effect is compiling for
  76766. * @param defines The defines to update
  76767. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76768. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76769. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76770. * @returns true if normals will be required for the rest of the effect
  76771. */
  76772. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76773. /**
  76774. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76775. * @param lightIndex defines the light index
  76776. * @param uniformsList The uniform list
  76777. * @param samplersList The sampler list
  76778. * @param projectedLightTexture defines if projected texture must be used
  76779. * @param uniformBuffersList defines an optional list of uniform buffers
  76780. */
  76781. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76782. /**
  76783. * Prepares the uniforms and samplers list to be used in the effect
  76784. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76785. * @param samplersList The sampler list
  76786. * @param defines The defines helping in the list generation
  76787. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76788. */
  76789. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76790. /**
  76791. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76792. * @param defines The defines to update while falling back
  76793. * @param fallbacks The authorized effect fallbacks
  76794. * @param maxSimultaneousLights The maximum number of lights allowed
  76795. * @param rank the current rank of the Effect
  76796. * @returns The newly affected rank
  76797. */
  76798. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76799. private static _TmpMorphInfluencers;
  76800. /**
  76801. * Prepares the list of attributes required for morph targets according to the effect defines.
  76802. * @param attribs The current list of supported attribs
  76803. * @param mesh The mesh to prepare the morph targets attributes for
  76804. * @param influencers The number of influencers
  76805. */
  76806. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76807. /**
  76808. * Prepares the list of attributes required for morph targets according to the effect defines.
  76809. * @param attribs The current list of supported attribs
  76810. * @param mesh The mesh to prepare the morph targets attributes for
  76811. * @param defines The current Defines of the effect
  76812. */
  76813. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76814. /**
  76815. * Prepares the list of attributes required for bones according to the effect defines.
  76816. * @param attribs The current list of supported attribs
  76817. * @param mesh The mesh to prepare the bones attributes for
  76818. * @param defines The current Defines of the effect
  76819. * @param fallbacks The current efffect fallback strategy
  76820. */
  76821. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76822. /**
  76823. * Check and prepare the list of attributes required for instances according to the effect defines.
  76824. * @param attribs The current list of supported attribs
  76825. * @param defines The current MaterialDefines of the effect
  76826. */
  76827. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76828. /**
  76829. * Add the list of attributes required for instances to the attribs array.
  76830. * @param attribs The current list of supported attribs
  76831. */
  76832. static PushAttributesForInstances(attribs: string[]): void;
  76833. /**
  76834. * Binds the light information to the effect.
  76835. * @param light The light containing the generator
  76836. * @param effect The effect we are binding the data to
  76837. * @param lightIndex The light index in the effect used to render
  76838. */
  76839. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76840. /**
  76841. * Binds the lights information from the scene to the effect for the given mesh.
  76842. * @param light Light to bind
  76843. * @param lightIndex Light index
  76844. * @param scene The scene where the light belongs to
  76845. * @param effect The effect we are binding the data to
  76846. * @param useSpecular Defines if specular is supported
  76847. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76848. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76849. */
  76850. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76851. /**
  76852. * Binds the lights information from the scene to the effect for the given mesh.
  76853. * @param scene The scene the lights belongs to
  76854. * @param mesh The mesh we are binding the information to render
  76855. * @param effect The effect we are binding the data to
  76856. * @param defines The generated defines for the effect
  76857. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76858. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76859. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76860. */
  76861. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76862. private static _tempFogColor;
  76863. /**
  76864. * Binds the fog information from the scene to the effect for the given mesh.
  76865. * @param scene The scene the lights belongs to
  76866. * @param mesh The mesh we are binding the information to render
  76867. * @param effect The effect we are binding the data to
  76868. * @param linearSpace Defines if the fog effect is applied in linear space
  76869. */
  76870. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76871. /**
  76872. * Binds the bones information from the mesh to the effect.
  76873. * @param mesh The mesh we are binding the information to render
  76874. * @param effect The effect we are binding the data to
  76875. */
  76876. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76877. /**
  76878. * Binds the morph targets information from the mesh to the effect.
  76879. * @param abstractMesh The mesh we are binding the information to render
  76880. * @param effect The effect we are binding the data to
  76881. */
  76882. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76883. /**
  76884. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76885. * @param defines The generated defines used in the effect
  76886. * @param effect The effect we are binding the data to
  76887. * @param scene The scene we are willing to render with logarithmic scale for
  76888. */
  76889. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76890. /**
  76891. * Binds the clip plane information from the scene to the effect.
  76892. * @param scene The scene the clip plane information are extracted from
  76893. * @param effect The effect we are binding the data to
  76894. */
  76895. static BindClipPlane(effect: Effect, scene: Scene): void;
  76896. }
  76897. }
  76898. declare module BABYLON {
  76899. /** @hidden */
  76900. export var packingFunctions: {
  76901. name: string;
  76902. shader: string;
  76903. };
  76904. }
  76905. declare module BABYLON {
  76906. /** @hidden */
  76907. export var shadowMapPixelShader: {
  76908. name: string;
  76909. shader: string;
  76910. };
  76911. }
  76912. declare module BABYLON {
  76913. /** @hidden */
  76914. export var bonesDeclaration: {
  76915. name: string;
  76916. shader: string;
  76917. };
  76918. }
  76919. declare module BABYLON {
  76920. /** @hidden */
  76921. export var morphTargetsVertexGlobalDeclaration: {
  76922. name: string;
  76923. shader: string;
  76924. };
  76925. }
  76926. declare module BABYLON {
  76927. /** @hidden */
  76928. export var morphTargetsVertexDeclaration: {
  76929. name: string;
  76930. shader: string;
  76931. };
  76932. }
  76933. declare module BABYLON {
  76934. /** @hidden */
  76935. export var instancesDeclaration: {
  76936. name: string;
  76937. shader: string;
  76938. };
  76939. }
  76940. declare module BABYLON {
  76941. /** @hidden */
  76942. export var helperFunctions: {
  76943. name: string;
  76944. shader: string;
  76945. };
  76946. }
  76947. declare module BABYLON {
  76948. /** @hidden */
  76949. export var morphTargetsVertex: {
  76950. name: string;
  76951. shader: string;
  76952. };
  76953. }
  76954. declare module BABYLON {
  76955. /** @hidden */
  76956. export var instancesVertex: {
  76957. name: string;
  76958. shader: string;
  76959. };
  76960. }
  76961. declare module BABYLON {
  76962. /** @hidden */
  76963. export var bonesVertex: {
  76964. name: string;
  76965. shader: string;
  76966. };
  76967. }
  76968. declare module BABYLON {
  76969. /** @hidden */
  76970. export var shadowMapVertexShader: {
  76971. name: string;
  76972. shader: string;
  76973. };
  76974. }
  76975. declare module BABYLON {
  76976. /** @hidden */
  76977. export var depthBoxBlurPixelShader: {
  76978. name: string;
  76979. shader: string;
  76980. };
  76981. }
  76982. declare module BABYLON {
  76983. /**
  76984. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76985. */
  76986. export interface ICustomShaderOptions {
  76987. /**
  76988. * Gets or sets the custom shader name to use
  76989. */
  76990. shaderName: string;
  76991. /**
  76992. * The list of attribute names used in the shader
  76993. */
  76994. attributes?: string[];
  76995. /**
  76996. * The list of unifrom names used in the shader
  76997. */
  76998. uniforms?: string[];
  76999. /**
  77000. * The list of sampler names used in the shader
  77001. */
  77002. samplers?: string[];
  77003. /**
  77004. * The list of defines used in the shader
  77005. */
  77006. defines?: string[];
  77007. }
  77008. /**
  77009. * Interface to implement to create a shadow generator compatible with BJS.
  77010. */
  77011. export interface IShadowGenerator {
  77012. /**
  77013. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77014. * @returns The render target texture if present otherwise, null
  77015. */
  77016. getShadowMap(): Nullable<RenderTargetTexture>;
  77017. /**
  77018. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77019. * @returns The render target texture if the shadow map is present otherwise, null
  77020. */
  77021. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77022. /**
  77023. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77024. * @param subMesh The submesh we want to render in the shadow map
  77025. * @param useInstances Defines wether will draw in the map using instances
  77026. * @returns true if ready otherwise, false
  77027. */
  77028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77029. /**
  77030. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77031. * @param defines Defines of the material we want to update
  77032. * @param lightIndex Index of the light in the enabled light list of the material
  77033. */
  77034. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77035. /**
  77036. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77037. * defined in the generator but impacting the effect).
  77038. * It implies the unifroms available on the materials are the standard BJS ones.
  77039. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77040. * @param effect The effect we are binfing the information for
  77041. */
  77042. bindShadowLight(lightIndex: string, effect: Effect): void;
  77043. /**
  77044. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77045. * (eq to shadow prjection matrix * light transform matrix)
  77046. * @returns The transform matrix used to create the shadow map
  77047. */
  77048. getTransformMatrix(): Matrix;
  77049. /**
  77050. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77051. * Cube and 2D textures for instance.
  77052. */
  77053. recreateShadowMap(): void;
  77054. /**
  77055. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77056. * @param onCompiled Callback triggered at the and of the effects compilation
  77057. * @param options Sets of optional options forcing the compilation with different modes
  77058. */
  77059. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77060. useInstances: boolean;
  77061. }>): void;
  77062. /**
  77063. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77064. * @param options Sets of optional options forcing the compilation with different modes
  77065. * @returns A promise that resolves when the compilation completes
  77066. */
  77067. forceCompilationAsync(options?: Partial<{
  77068. useInstances: boolean;
  77069. }>): Promise<void>;
  77070. /**
  77071. * Serializes the shadow generator setup to a json object.
  77072. * @returns The serialized JSON object
  77073. */
  77074. serialize(): any;
  77075. /**
  77076. * Disposes the Shadow map and related Textures and effects.
  77077. */
  77078. dispose(): void;
  77079. }
  77080. /**
  77081. * Default implementation IShadowGenerator.
  77082. * This is the main object responsible of generating shadows in the framework.
  77083. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77084. */
  77085. export class ShadowGenerator implements IShadowGenerator {
  77086. /**
  77087. * Shadow generator mode None: no filtering applied.
  77088. */
  77089. static readonly FILTER_NONE: number;
  77090. /**
  77091. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77092. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77093. */
  77094. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77095. /**
  77096. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77097. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77098. */
  77099. static readonly FILTER_POISSONSAMPLING: number;
  77100. /**
  77101. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77102. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77103. */
  77104. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77105. /**
  77106. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77107. * edge artifacts on steep falloff.
  77108. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77109. */
  77110. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77111. /**
  77112. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77113. * edge artifacts on steep falloff.
  77114. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77115. */
  77116. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77117. /**
  77118. * Shadow generator mode PCF: Percentage Closer Filtering
  77119. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77120. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77121. */
  77122. static readonly FILTER_PCF: number;
  77123. /**
  77124. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77125. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77126. * Contact Hardening
  77127. */
  77128. static readonly FILTER_PCSS: number;
  77129. /**
  77130. * Reserved for PCF and PCSS
  77131. * Highest Quality.
  77132. *
  77133. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77134. *
  77135. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77136. */
  77137. static readonly QUALITY_HIGH: number;
  77138. /**
  77139. * Reserved for PCF and PCSS
  77140. * Good tradeoff for quality/perf cross devices
  77141. *
  77142. * Execute PCF on a 3*3 kernel.
  77143. *
  77144. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77145. */
  77146. static readonly QUALITY_MEDIUM: number;
  77147. /**
  77148. * Reserved for PCF and PCSS
  77149. * The lowest quality but the fastest.
  77150. *
  77151. * Execute PCF on a 1*1 kernel.
  77152. *
  77153. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77154. */
  77155. static readonly QUALITY_LOW: number;
  77156. /** Gets or sets the custom shader name to use */
  77157. customShaderOptions: ICustomShaderOptions;
  77158. /**
  77159. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77160. */
  77161. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77162. /**
  77163. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77164. */
  77165. onAfterShadowMapRenderObservable: Observable<Effect>;
  77166. /**
  77167. * Observable triggered before a mesh is rendered in the shadow map.
  77168. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77169. */
  77170. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77171. /**
  77172. * Observable triggered after a mesh is rendered in the shadow map.
  77173. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77174. */
  77175. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77176. private _bias;
  77177. /**
  77178. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77179. */
  77180. /**
  77181. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77182. */
  77183. bias: number;
  77184. private _normalBias;
  77185. /**
  77186. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77187. */
  77188. /**
  77189. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77190. */
  77191. normalBias: number;
  77192. private _blurBoxOffset;
  77193. /**
  77194. * Gets the blur box offset: offset applied during the blur pass.
  77195. * Only useful if useKernelBlur = false
  77196. */
  77197. /**
  77198. * Sets the blur box offset: offset applied during the blur pass.
  77199. * Only useful if useKernelBlur = false
  77200. */
  77201. blurBoxOffset: number;
  77202. private _blurScale;
  77203. /**
  77204. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77205. * 2 means half of the size.
  77206. */
  77207. /**
  77208. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77209. * 2 means half of the size.
  77210. */
  77211. blurScale: number;
  77212. private _blurKernel;
  77213. /**
  77214. * Gets the blur kernel: kernel size of the blur pass.
  77215. * Only useful if useKernelBlur = true
  77216. */
  77217. /**
  77218. * Sets the blur kernel: kernel size of the blur pass.
  77219. * Only useful if useKernelBlur = true
  77220. */
  77221. blurKernel: number;
  77222. private _useKernelBlur;
  77223. /**
  77224. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77225. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77226. */
  77227. /**
  77228. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77229. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77230. */
  77231. useKernelBlur: boolean;
  77232. private _depthScale;
  77233. /**
  77234. * Gets the depth scale used in ESM mode.
  77235. */
  77236. /**
  77237. * Sets the depth scale used in ESM mode.
  77238. * This can override the scale stored on the light.
  77239. */
  77240. depthScale: number;
  77241. private _filter;
  77242. /**
  77243. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77244. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77245. */
  77246. /**
  77247. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77248. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77249. */
  77250. filter: number;
  77251. /**
  77252. * Gets if the current filter is set to Poisson Sampling.
  77253. */
  77254. /**
  77255. * Sets the current filter to Poisson Sampling.
  77256. */
  77257. usePoissonSampling: boolean;
  77258. /**
  77259. * Gets if the current filter is set to ESM.
  77260. */
  77261. /**
  77262. * Sets the current filter is to ESM.
  77263. */
  77264. useExponentialShadowMap: boolean;
  77265. /**
  77266. * Gets if the current filter is set to filtered ESM.
  77267. */
  77268. /**
  77269. * Gets if the current filter is set to filtered ESM.
  77270. */
  77271. useBlurExponentialShadowMap: boolean;
  77272. /**
  77273. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77274. * exponential to prevent steep falloff artifacts).
  77275. */
  77276. /**
  77277. * Sets the current filter to "close ESM" (using the inverse of the
  77278. * exponential to prevent steep falloff artifacts).
  77279. */
  77280. useCloseExponentialShadowMap: boolean;
  77281. /**
  77282. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77283. * exponential to prevent steep falloff artifacts).
  77284. */
  77285. /**
  77286. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77287. * exponential to prevent steep falloff artifacts).
  77288. */
  77289. useBlurCloseExponentialShadowMap: boolean;
  77290. /**
  77291. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77292. */
  77293. /**
  77294. * Sets the current filter to "PCF" (percentage closer filtering).
  77295. */
  77296. usePercentageCloserFiltering: boolean;
  77297. private _filteringQuality;
  77298. /**
  77299. * Gets the PCF or PCSS Quality.
  77300. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77301. */
  77302. /**
  77303. * Sets the PCF or PCSS Quality.
  77304. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77305. */
  77306. filteringQuality: number;
  77307. /**
  77308. * Gets if the current filter is set to "PCSS" (contact hardening).
  77309. */
  77310. /**
  77311. * Sets the current filter to "PCSS" (contact hardening).
  77312. */
  77313. useContactHardeningShadow: boolean;
  77314. private _contactHardeningLightSizeUVRatio;
  77315. /**
  77316. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77317. * Using a ratio helps keeping shape stability independently of the map size.
  77318. *
  77319. * It does not account for the light projection as it was having too much
  77320. * instability during the light setup or during light position changes.
  77321. *
  77322. * Only valid if useContactHardeningShadow is true.
  77323. */
  77324. /**
  77325. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77326. * Using a ratio helps keeping shape stability independently of the map size.
  77327. *
  77328. * It does not account for the light projection as it was having too much
  77329. * instability during the light setup or during light position changes.
  77330. *
  77331. * Only valid if useContactHardeningShadow is true.
  77332. */
  77333. contactHardeningLightSizeUVRatio: number;
  77334. private _darkness;
  77335. /** Gets or sets the actual darkness of a shadow */
  77336. darkness: number;
  77337. /**
  77338. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77339. * 0 means strongest and 1 would means no shadow.
  77340. * @returns the darkness.
  77341. */
  77342. getDarkness(): number;
  77343. /**
  77344. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77345. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77346. * @returns the shadow generator allowing fluent coding.
  77347. */
  77348. setDarkness(darkness: number): ShadowGenerator;
  77349. private _transparencyShadow;
  77350. /** Gets or sets the ability to have transparent shadow */
  77351. transparencyShadow: boolean;
  77352. /**
  77353. * Sets the ability to have transparent shadow (boolean).
  77354. * @param transparent True if transparent else False
  77355. * @returns the shadow generator allowing fluent coding
  77356. */
  77357. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77358. private _shadowMap;
  77359. private _shadowMap2;
  77360. /**
  77361. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77362. * @returns The render target texture if present otherwise, null
  77363. */
  77364. getShadowMap(): Nullable<RenderTargetTexture>;
  77365. /**
  77366. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77367. * @returns The render target texture if the shadow map is present otherwise, null
  77368. */
  77369. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77370. /**
  77371. * Gets the class name of that object
  77372. * @returns "ShadowGenerator"
  77373. */
  77374. getClassName(): string;
  77375. /**
  77376. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77377. * @param mesh Mesh to add
  77378. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77379. * @returns the Shadow Generator itself
  77380. */
  77381. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77382. /**
  77383. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77384. * @param mesh Mesh to remove
  77385. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77386. * @returns the Shadow Generator itself
  77387. */
  77388. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77389. /**
  77390. * Controls the extent to which the shadows fade out at the edge of the frustum
  77391. * Used only by directionals and spots
  77392. */
  77393. frustumEdgeFalloff: number;
  77394. private _light;
  77395. /**
  77396. * Returns the associated light object.
  77397. * @returns the light generating the shadow
  77398. */
  77399. getLight(): IShadowLight;
  77400. /**
  77401. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77402. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77403. * It might on the other hand introduce peter panning.
  77404. */
  77405. forceBackFacesOnly: boolean;
  77406. private _scene;
  77407. private _lightDirection;
  77408. private _effect;
  77409. private _viewMatrix;
  77410. private _projectionMatrix;
  77411. private _transformMatrix;
  77412. private _cachedPosition;
  77413. private _cachedDirection;
  77414. private _cachedDefines;
  77415. private _currentRenderID;
  77416. private _boxBlurPostprocess;
  77417. private _kernelBlurXPostprocess;
  77418. private _kernelBlurYPostprocess;
  77419. private _blurPostProcesses;
  77420. private _mapSize;
  77421. private _currentFaceIndex;
  77422. private _currentFaceIndexCache;
  77423. private _textureType;
  77424. private _defaultTextureMatrix;
  77425. private _storedUniqueId;
  77426. /** @hidden */
  77427. static _SceneComponentInitialization: (scene: Scene) => void;
  77428. /**
  77429. * Creates a ShadowGenerator object.
  77430. * A ShadowGenerator is the required tool to use the shadows.
  77431. * Each light casting shadows needs to use its own ShadowGenerator.
  77432. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77433. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77434. * @param light The light object generating the shadows.
  77435. * @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.
  77436. */
  77437. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77438. private _initializeGenerator;
  77439. private _initializeShadowMap;
  77440. private _initializeBlurRTTAndPostProcesses;
  77441. private _renderForShadowMap;
  77442. private _renderSubMeshForShadowMap;
  77443. private _applyFilterValues;
  77444. /**
  77445. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77446. * @param onCompiled Callback triggered at the and of the effects compilation
  77447. * @param options Sets of optional options forcing the compilation with different modes
  77448. */
  77449. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77450. useInstances: boolean;
  77451. }>): void;
  77452. /**
  77453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77454. * @param options Sets of optional options forcing the compilation with different modes
  77455. * @returns A promise that resolves when the compilation completes
  77456. */
  77457. forceCompilationAsync(options?: Partial<{
  77458. useInstances: boolean;
  77459. }>): Promise<void>;
  77460. /**
  77461. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77462. * @param subMesh The submesh we want to render in the shadow map
  77463. * @param useInstances Defines wether will draw in the map using instances
  77464. * @returns true if ready otherwise, false
  77465. */
  77466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77467. /**
  77468. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77469. * @param defines Defines of the material we want to update
  77470. * @param lightIndex Index of the light in the enabled light list of the material
  77471. */
  77472. prepareDefines(defines: any, lightIndex: number): void;
  77473. /**
  77474. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77475. * defined in the generator but impacting the effect).
  77476. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77477. * @param effect The effect we are binfing the information for
  77478. */
  77479. bindShadowLight(lightIndex: string, effect: Effect): void;
  77480. /**
  77481. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77482. * (eq to shadow prjection matrix * light transform matrix)
  77483. * @returns The transform matrix used to create the shadow map
  77484. */
  77485. getTransformMatrix(): Matrix;
  77486. /**
  77487. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77488. * Cube and 2D textures for instance.
  77489. */
  77490. recreateShadowMap(): void;
  77491. private _disposeBlurPostProcesses;
  77492. private _disposeRTTandPostProcesses;
  77493. /**
  77494. * Disposes the ShadowGenerator.
  77495. * Returns nothing.
  77496. */
  77497. dispose(): void;
  77498. /**
  77499. * Serializes the shadow generator setup to a json object.
  77500. * @returns The serialized JSON object
  77501. */
  77502. serialize(): any;
  77503. /**
  77504. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77505. * @param parsedShadowGenerator The JSON object to parse
  77506. * @param scene The scene to create the shadow map for
  77507. * @returns The parsed shadow generator
  77508. */
  77509. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77510. }
  77511. }
  77512. declare module BABYLON {
  77513. /**
  77514. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77515. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77516. * 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.
  77517. */
  77518. export abstract class Light extends Node {
  77519. /**
  77520. * Falloff Default: light is falling off following the material specification:
  77521. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77522. */
  77523. static readonly FALLOFF_DEFAULT: number;
  77524. /**
  77525. * Falloff Physical: light is falling off following the inverse squared distance law.
  77526. */
  77527. static readonly FALLOFF_PHYSICAL: number;
  77528. /**
  77529. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77530. * to enhance interoperability with other engines.
  77531. */
  77532. static readonly FALLOFF_GLTF: number;
  77533. /**
  77534. * Falloff Standard: light is falling off like in the standard material
  77535. * to enhance interoperability with other materials.
  77536. */
  77537. static readonly FALLOFF_STANDARD: number;
  77538. /**
  77539. * If every light affecting the material is in this lightmapMode,
  77540. * material.lightmapTexture adds or multiplies
  77541. * (depends on material.useLightmapAsShadowmap)
  77542. * after every other light calculations.
  77543. */
  77544. static readonly LIGHTMAP_DEFAULT: number;
  77545. /**
  77546. * material.lightmapTexture as only diffuse lighting from this light
  77547. * adds only specular lighting from this light
  77548. * adds dynamic shadows
  77549. */
  77550. static readonly LIGHTMAP_SPECULAR: number;
  77551. /**
  77552. * material.lightmapTexture as only lighting
  77553. * no light calculation from this light
  77554. * only adds dynamic shadows from this light
  77555. */
  77556. static readonly LIGHTMAP_SHADOWSONLY: number;
  77557. /**
  77558. * Each light type uses the default quantity according to its type:
  77559. * point/spot lights use luminous intensity
  77560. * directional lights use illuminance
  77561. */
  77562. static readonly INTENSITYMODE_AUTOMATIC: number;
  77563. /**
  77564. * lumen (lm)
  77565. */
  77566. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77567. /**
  77568. * candela (lm/sr)
  77569. */
  77570. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77571. /**
  77572. * lux (lm/m^2)
  77573. */
  77574. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77575. /**
  77576. * nit (cd/m^2)
  77577. */
  77578. static readonly INTENSITYMODE_LUMINANCE: number;
  77579. /**
  77580. * Light type const id of the point light.
  77581. */
  77582. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77583. /**
  77584. * Light type const id of the directional light.
  77585. */
  77586. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77587. /**
  77588. * Light type const id of the spot light.
  77589. */
  77590. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77591. /**
  77592. * Light type const id of the hemispheric light.
  77593. */
  77594. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77595. /**
  77596. * Diffuse gives the basic color to an object.
  77597. */
  77598. diffuse: Color3;
  77599. /**
  77600. * Specular produces a highlight color on an object.
  77601. * Note: This is note affecting PBR materials.
  77602. */
  77603. specular: Color3;
  77604. /**
  77605. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77606. * falling off base on range or angle.
  77607. * This can be set to any values in Light.FALLOFF_x.
  77608. *
  77609. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77610. * other types of materials.
  77611. */
  77612. falloffType: number;
  77613. /**
  77614. * Strength of the light.
  77615. * Note: By default it is define in the framework own unit.
  77616. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77617. */
  77618. intensity: number;
  77619. private _range;
  77620. protected _inverseSquaredRange: number;
  77621. /**
  77622. * Defines how far from the source the light is impacting in scene units.
  77623. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77624. */
  77625. /**
  77626. * Defines how far from the source the light is impacting in scene units.
  77627. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77628. */
  77629. range: number;
  77630. /**
  77631. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77632. * of light.
  77633. */
  77634. private _photometricScale;
  77635. private _intensityMode;
  77636. /**
  77637. * Gets the photometric scale used to interpret the intensity.
  77638. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77639. */
  77640. /**
  77641. * Sets the photometric scale used to interpret the intensity.
  77642. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77643. */
  77644. intensityMode: number;
  77645. private _radius;
  77646. /**
  77647. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77648. */
  77649. /**
  77650. * sets the light radius used by PBR Materials to simulate soft area lights.
  77651. */
  77652. radius: number;
  77653. private _renderPriority;
  77654. /**
  77655. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77656. * exceeding the number allowed of the materials.
  77657. */
  77658. renderPriority: number;
  77659. private _shadowEnabled;
  77660. /**
  77661. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77662. * the current shadow generator.
  77663. */
  77664. /**
  77665. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77666. * the current shadow generator.
  77667. */
  77668. shadowEnabled: boolean;
  77669. private _includedOnlyMeshes;
  77670. /**
  77671. * Gets the only meshes impacted by this light.
  77672. */
  77673. /**
  77674. * Sets the only meshes impacted by this light.
  77675. */
  77676. includedOnlyMeshes: AbstractMesh[];
  77677. private _excludedMeshes;
  77678. /**
  77679. * Gets the meshes not impacted by this light.
  77680. */
  77681. /**
  77682. * Sets the meshes not impacted by this light.
  77683. */
  77684. excludedMeshes: AbstractMesh[];
  77685. private _excludeWithLayerMask;
  77686. /**
  77687. * Gets the layer id use to find what meshes are not impacted by the light.
  77688. * Inactive if 0
  77689. */
  77690. /**
  77691. * Sets the layer id use to find what meshes are not impacted by the light.
  77692. * Inactive if 0
  77693. */
  77694. excludeWithLayerMask: number;
  77695. private _includeOnlyWithLayerMask;
  77696. /**
  77697. * Gets the layer id use to find what meshes are impacted by the light.
  77698. * Inactive if 0
  77699. */
  77700. /**
  77701. * Sets the layer id use to find what meshes are impacted by the light.
  77702. * Inactive if 0
  77703. */
  77704. includeOnlyWithLayerMask: number;
  77705. private _lightmapMode;
  77706. /**
  77707. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77708. */
  77709. /**
  77710. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77711. */
  77712. lightmapMode: number;
  77713. /**
  77714. * Shadow generator associted to the light.
  77715. * @hidden Internal use only.
  77716. */
  77717. _shadowGenerator: Nullable<IShadowGenerator>;
  77718. /**
  77719. * @hidden Internal use only.
  77720. */
  77721. _excludedMeshesIds: string[];
  77722. /**
  77723. * @hidden Internal use only.
  77724. */
  77725. _includedOnlyMeshesIds: string[];
  77726. /**
  77727. * The current light unifom buffer.
  77728. * @hidden Internal use only.
  77729. */
  77730. _uniformBuffer: UniformBuffer;
  77731. /** @hidden */
  77732. _renderId: number;
  77733. /**
  77734. * Creates a Light object in the scene.
  77735. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77736. * @param name The firendly name of the light
  77737. * @param scene The scene the light belongs too
  77738. */
  77739. constructor(name: string, scene: Scene);
  77740. protected abstract _buildUniformLayout(): void;
  77741. /**
  77742. * Sets the passed Effect "effect" with the Light information.
  77743. * @param effect The effect to update
  77744. * @param lightIndex The index of the light in the effect to update
  77745. * @returns The light
  77746. */
  77747. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77748. /**
  77749. * Sets the passed Effect "effect" with the Light information.
  77750. * @param effect The effect to update
  77751. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77752. * @returns The light
  77753. */
  77754. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77755. /**
  77756. * Returns the string "Light".
  77757. * @returns the class name
  77758. */
  77759. getClassName(): string;
  77760. /** @hidden */
  77761. readonly _isLight: boolean;
  77762. /**
  77763. * Converts the light information to a readable string for debug purpose.
  77764. * @param fullDetails Supports for multiple levels of logging within scene loading
  77765. * @returns the human readable light info
  77766. */
  77767. toString(fullDetails?: boolean): string;
  77768. /** @hidden */
  77769. protected _syncParentEnabledState(): void;
  77770. /**
  77771. * Set the enabled state of this node.
  77772. * @param value - the new enabled state
  77773. */
  77774. setEnabled(value: boolean): void;
  77775. /**
  77776. * Returns the Light associated shadow generator if any.
  77777. * @return the associated shadow generator.
  77778. */
  77779. getShadowGenerator(): Nullable<IShadowGenerator>;
  77780. /**
  77781. * Returns a Vector3, the absolute light position in the World.
  77782. * @returns the world space position of the light
  77783. */
  77784. getAbsolutePosition(): Vector3;
  77785. /**
  77786. * Specifies if the light will affect the passed mesh.
  77787. * @param mesh The mesh to test against the light
  77788. * @return true the mesh is affected otherwise, false.
  77789. */
  77790. canAffectMesh(mesh: AbstractMesh): boolean;
  77791. /**
  77792. * Sort function to order lights for rendering.
  77793. * @param a First Light object to compare to second.
  77794. * @param b Second Light object to compare first.
  77795. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77796. */
  77797. static CompareLightsPriority(a: Light, b: Light): number;
  77798. /**
  77799. * Releases resources associated with this node.
  77800. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77801. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77802. */
  77803. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77804. /**
  77805. * Returns the light type ID (integer).
  77806. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77807. */
  77808. getTypeID(): number;
  77809. /**
  77810. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77811. * @returns the scaled intensity in intensity mode unit
  77812. */
  77813. getScaledIntensity(): number;
  77814. /**
  77815. * Returns a new Light object, named "name", from the current one.
  77816. * @param name The name of the cloned light
  77817. * @returns the new created light
  77818. */
  77819. clone(name: string): Nullable<Light>;
  77820. /**
  77821. * Serializes the current light into a Serialization object.
  77822. * @returns the serialized object.
  77823. */
  77824. serialize(): any;
  77825. /**
  77826. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77827. * This new light is named "name" and added to the passed scene.
  77828. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77829. * @param name The friendly name of the light
  77830. * @param scene The scene the new light will belong to
  77831. * @returns the constructor function
  77832. */
  77833. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77834. /**
  77835. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77836. * @param parsedLight The JSON representation of the light
  77837. * @param scene The scene to create the parsed light in
  77838. * @returns the created light after parsing
  77839. */
  77840. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77841. private _hookArrayForExcluded;
  77842. private _hookArrayForIncludedOnly;
  77843. private _resyncMeshes;
  77844. /**
  77845. * Forces the meshes to update their light related information in their rendering used effects
  77846. * @hidden Internal Use Only
  77847. */
  77848. _markMeshesAsLightDirty(): void;
  77849. /**
  77850. * Recomputes the cached photometric scale if needed.
  77851. */
  77852. private _computePhotometricScale;
  77853. /**
  77854. * Returns the Photometric Scale according to the light type and intensity mode.
  77855. */
  77856. private _getPhotometricScale;
  77857. /**
  77858. * Reorder the light in the scene according to their defined priority.
  77859. * @hidden Internal Use Only
  77860. */
  77861. _reorderLightsInScene(): void;
  77862. /**
  77863. * Prepares the list of defines specific to the light type.
  77864. * @param defines the list of defines
  77865. * @param lightIndex defines the index of the light for the effect
  77866. */
  77867. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77868. }
  77869. }
  77870. declare module BABYLON {
  77871. /**
  77872. * Interface used to define Action
  77873. */
  77874. export interface IAction {
  77875. /**
  77876. * Trigger for the action
  77877. */
  77878. trigger: number;
  77879. /** Options of the trigger */
  77880. triggerOptions: any;
  77881. /**
  77882. * Gets the trigger parameters
  77883. * @returns the trigger parameters
  77884. */
  77885. getTriggerParameter(): any;
  77886. /**
  77887. * Internal only - executes current action event
  77888. * @hidden
  77889. */
  77890. _executeCurrent(evt?: ActionEvent): void;
  77891. /**
  77892. * Serialize placeholder for child classes
  77893. * @param parent of child
  77894. * @returns the serialized object
  77895. */
  77896. serialize(parent: any): any;
  77897. /**
  77898. * Internal only
  77899. * @hidden
  77900. */
  77901. _prepare(): void;
  77902. /**
  77903. * Internal only - manager for action
  77904. * @hidden
  77905. */
  77906. _actionManager: AbstractActionManager;
  77907. /**
  77908. * Adds action to chain of actions, may be a DoNothingAction
  77909. * @param action defines the next action to execute
  77910. * @returns The action passed in
  77911. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77912. */
  77913. then(action: IAction): IAction;
  77914. }
  77915. /**
  77916. * The action to be carried out following a trigger
  77917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77918. */
  77919. export class Action implements IAction {
  77920. /** the trigger, with or without parameters, for the action */
  77921. triggerOptions: any;
  77922. /**
  77923. * Trigger for the action
  77924. */
  77925. trigger: number;
  77926. /**
  77927. * Internal only - manager for action
  77928. * @hidden
  77929. */
  77930. _actionManager: ActionManager;
  77931. private _nextActiveAction;
  77932. private _child;
  77933. private _condition?;
  77934. private _triggerParameter;
  77935. /**
  77936. * An event triggered prior to action being executed.
  77937. */
  77938. onBeforeExecuteObservable: Observable<Action>;
  77939. /**
  77940. * Creates a new Action
  77941. * @param triggerOptions the trigger, with or without parameters, for the action
  77942. * @param condition an optional determinant of action
  77943. */
  77944. constructor(
  77945. /** the trigger, with or without parameters, for the action */
  77946. triggerOptions: any, condition?: Condition);
  77947. /**
  77948. * Internal only
  77949. * @hidden
  77950. */
  77951. _prepare(): void;
  77952. /**
  77953. * Gets the trigger parameters
  77954. * @returns the trigger parameters
  77955. */
  77956. getTriggerParameter(): any;
  77957. /**
  77958. * Internal only - executes current action event
  77959. * @hidden
  77960. */
  77961. _executeCurrent(evt?: ActionEvent): void;
  77962. /**
  77963. * Execute placeholder for child classes
  77964. * @param evt optional action event
  77965. */
  77966. execute(evt?: ActionEvent): void;
  77967. /**
  77968. * Skips to next active action
  77969. */
  77970. skipToNextActiveAction(): void;
  77971. /**
  77972. * Adds action to chain of actions, may be a DoNothingAction
  77973. * @param action defines the next action to execute
  77974. * @returns The action passed in
  77975. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77976. */
  77977. then(action: Action): Action;
  77978. /**
  77979. * Internal only
  77980. * @hidden
  77981. */
  77982. _getProperty(propertyPath: string): string;
  77983. /**
  77984. * Internal only
  77985. * @hidden
  77986. */
  77987. _getEffectiveTarget(target: any, propertyPath: string): any;
  77988. /**
  77989. * Serialize placeholder for child classes
  77990. * @param parent of child
  77991. * @returns the serialized object
  77992. */
  77993. serialize(parent: any): any;
  77994. /**
  77995. * Internal only called by serialize
  77996. * @hidden
  77997. */
  77998. protected _serialize(serializedAction: any, parent?: any): any;
  77999. /**
  78000. * Internal only
  78001. * @hidden
  78002. */
  78003. static _SerializeValueAsString: (value: any) => string;
  78004. /**
  78005. * Internal only
  78006. * @hidden
  78007. */
  78008. static _GetTargetProperty: (target: Node | Scene) => {
  78009. name: string;
  78010. targetType: string;
  78011. value: string;
  78012. };
  78013. }
  78014. }
  78015. declare module BABYLON {
  78016. /**
  78017. * A Condition applied to an Action
  78018. */
  78019. export class Condition {
  78020. /**
  78021. * Internal only - manager for action
  78022. * @hidden
  78023. */
  78024. _actionManager: ActionManager;
  78025. /**
  78026. * Internal only
  78027. * @hidden
  78028. */
  78029. _evaluationId: number;
  78030. /**
  78031. * Internal only
  78032. * @hidden
  78033. */
  78034. _currentResult: boolean;
  78035. /**
  78036. * Creates a new Condition
  78037. * @param actionManager the manager of the action the condition is applied to
  78038. */
  78039. constructor(actionManager: ActionManager);
  78040. /**
  78041. * Check if the current condition is valid
  78042. * @returns a boolean
  78043. */
  78044. isValid(): boolean;
  78045. /**
  78046. * Internal only
  78047. * @hidden
  78048. */
  78049. _getProperty(propertyPath: string): string;
  78050. /**
  78051. * Internal only
  78052. * @hidden
  78053. */
  78054. _getEffectiveTarget(target: any, propertyPath: string): any;
  78055. /**
  78056. * Serialize placeholder for child classes
  78057. * @returns the serialized object
  78058. */
  78059. serialize(): any;
  78060. /**
  78061. * Internal only
  78062. * @hidden
  78063. */
  78064. protected _serialize(serializedCondition: any): any;
  78065. }
  78066. /**
  78067. * Defines specific conditional operators as extensions of Condition
  78068. */
  78069. export class ValueCondition extends Condition {
  78070. /** path to specify the property of the target the conditional operator uses */
  78071. propertyPath: string;
  78072. /** the value compared by the conditional operator against the current value of the property */
  78073. value: any;
  78074. /** the conditional operator, default ValueCondition.IsEqual */
  78075. operator: number;
  78076. /**
  78077. * Internal only
  78078. * @hidden
  78079. */
  78080. private static _IsEqual;
  78081. /**
  78082. * Internal only
  78083. * @hidden
  78084. */
  78085. private static _IsDifferent;
  78086. /**
  78087. * Internal only
  78088. * @hidden
  78089. */
  78090. private static _IsGreater;
  78091. /**
  78092. * Internal only
  78093. * @hidden
  78094. */
  78095. private static _IsLesser;
  78096. /**
  78097. * returns the number for IsEqual
  78098. */
  78099. static readonly IsEqual: number;
  78100. /**
  78101. * Returns the number for IsDifferent
  78102. */
  78103. static readonly IsDifferent: number;
  78104. /**
  78105. * Returns the number for IsGreater
  78106. */
  78107. static readonly IsGreater: number;
  78108. /**
  78109. * Returns the number for IsLesser
  78110. */
  78111. static readonly IsLesser: number;
  78112. /**
  78113. * Internal only The action manager for the condition
  78114. * @hidden
  78115. */
  78116. _actionManager: ActionManager;
  78117. /**
  78118. * Internal only
  78119. * @hidden
  78120. */
  78121. private _target;
  78122. /**
  78123. * Internal only
  78124. * @hidden
  78125. */
  78126. private _effectiveTarget;
  78127. /**
  78128. * Internal only
  78129. * @hidden
  78130. */
  78131. private _property;
  78132. /**
  78133. * Creates a new ValueCondition
  78134. * @param actionManager manager for the action the condition applies to
  78135. * @param target for the action
  78136. * @param propertyPath path to specify the property of the target the conditional operator uses
  78137. * @param value the value compared by the conditional operator against the current value of the property
  78138. * @param operator the conditional operator, default ValueCondition.IsEqual
  78139. */
  78140. constructor(actionManager: ActionManager, target: any,
  78141. /** path to specify the property of the target the conditional operator uses */
  78142. propertyPath: string,
  78143. /** the value compared by the conditional operator against the current value of the property */
  78144. value: any,
  78145. /** the conditional operator, default ValueCondition.IsEqual */
  78146. operator?: number);
  78147. /**
  78148. * Compares the given value with the property value for the specified conditional operator
  78149. * @returns the result of the comparison
  78150. */
  78151. isValid(): boolean;
  78152. /**
  78153. * Serialize the ValueCondition into a JSON compatible object
  78154. * @returns serialization object
  78155. */
  78156. serialize(): any;
  78157. /**
  78158. * Gets the name of the conditional operator for the ValueCondition
  78159. * @param operator the conditional operator
  78160. * @returns the name
  78161. */
  78162. static GetOperatorName(operator: number): string;
  78163. }
  78164. /**
  78165. * Defines a predicate condition as an extension of Condition
  78166. */
  78167. export class PredicateCondition extends Condition {
  78168. /** defines the predicate function used to validate the condition */
  78169. predicate: () => boolean;
  78170. /**
  78171. * Internal only - manager for action
  78172. * @hidden
  78173. */
  78174. _actionManager: ActionManager;
  78175. /**
  78176. * Creates a new PredicateCondition
  78177. * @param actionManager manager for the action the condition applies to
  78178. * @param predicate defines the predicate function used to validate the condition
  78179. */
  78180. constructor(actionManager: ActionManager,
  78181. /** defines the predicate function used to validate the condition */
  78182. predicate: () => boolean);
  78183. /**
  78184. * @returns the validity of the predicate condition
  78185. */
  78186. isValid(): boolean;
  78187. }
  78188. /**
  78189. * Defines a state condition as an extension of Condition
  78190. */
  78191. export class StateCondition extends Condition {
  78192. /** Value to compare with target state */
  78193. value: string;
  78194. /**
  78195. * Internal only - manager for action
  78196. * @hidden
  78197. */
  78198. _actionManager: ActionManager;
  78199. /**
  78200. * Internal only
  78201. * @hidden
  78202. */
  78203. private _target;
  78204. /**
  78205. * Creates a new StateCondition
  78206. * @param actionManager manager for the action the condition applies to
  78207. * @param target of the condition
  78208. * @param value to compare with target state
  78209. */
  78210. constructor(actionManager: ActionManager, target: any,
  78211. /** Value to compare with target state */
  78212. value: string);
  78213. /**
  78214. * Gets a boolean indicating if the current condition is met
  78215. * @returns the validity of the state
  78216. */
  78217. isValid(): boolean;
  78218. /**
  78219. * Serialize the StateCondition into a JSON compatible object
  78220. * @returns serialization object
  78221. */
  78222. serialize(): any;
  78223. }
  78224. }
  78225. declare module BABYLON {
  78226. /**
  78227. * This defines an action responsible to toggle a boolean once triggered.
  78228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78229. */
  78230. export class SwitchBooleanAction extends Action {
  78231. /**
  78232. * The path to the boolean property in the target object
  78233. */
  78234. propertyPath: string;
  78235. private _target;
  78236. private _effectiveTarget;
  78237. private _property;
  78238. /**
  78239. * Instantiate the action
  78240. * @param triggerOptions defines the trigger options
  78241. * @param target defines the object containing the boolean
  78242. * @param propertyPath defines the path to the boolean property in the target object
  78243. * @param condition defines the trigger related conditions
  78244. */
  78245. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78246. /** @hidden */
  78247. _prepare(): void;
  78248. /**
  78249. * Execute the action toggle the boolean value.
  78250. */
  78251. execute(): void;
  78252. /**
  78253. * Serializes the actions and its related information.
  78254. * @param parent defines the object to serialize in
  78255. * @returns the serialized object
  78256. */
  78257. serialize(parent: any): any;
  78258. }
  78259. /**
  78260. * This defines an action responsible to set a the state field of the target
  78261. * to a desired value once triggered.
  78262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78263. */
  78264. export class SetStateAction extends Action {
  78265. /**
  78266. * The value to store in the state field.
  78267. */
  78268. value: string;
  78269. private _target;
  78270. /**
  78271. * Instantiate the action
  78272. * @param triggerOptions defines the trigger options
  78273. * @param target defines the object containing the state property
  78274. * @param value defines the value to store in the state field
  78275. * @param condition defines the trigger related conditions
  78276. */
  78277. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78278. /**
  78279. * Execute the action and store the value on the target state property.
  78280. */
  78281. execute(): void;
  78282. /**
  78283. * Serializes the actions and its related information.
  78284. * @param parent defines the object to serialize in
  78285. * @returns the serialized object
  78286. */
  78287. serialize(parent: any): any;
  78288. }
  78289. /**
  78290. * This defines an action responsible to set a property of the target
  78291. * to a desired value once triggered.
  78292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78293. */
  78294. export class SetValueAction extends Action {
  78295. /**
  78296. * The path of the property to set in the target.
  78297. */
  78298. propertyPath: string;
  78299. /**
  78300. * The value to set in the property
  78301. */
  78302. value: any;
  78303. private _target;
  78304. private _effectiveTarget;
  78305. private _property;
  78306. /**
  78307. * Instantiate the action
  78308. * @param triggerOptions defines the trigger options
  78309. * @param target defines the object containing the property
  78310. * @param propertyPath defines the path of the property to set in the target
  78311. * @param value defines the value to set in the property
  78312. * @param condition defines the trigger related conditions
  78313. */
  78314. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78315. /** @hidden */
  78316. _prepare(): void;
  78317. /**
  78318. * Execute the action and set the targetted property to the desired value.
  78319. */
  78320. execute(): void;
  78321. /**
  78322. * Serializes the actions and its related information.
  78323. * @param parent defines the object to serialize in
  78324. * @returns the serialized object
  78325. */
  78326. serialize(parent: any): any;
  78327. }
  78328. /**
  78329. * This defines an action responsible to increment the target value
  78330. * to a desired value once triggered.
  78331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78332. */
  78333. export class IncrementValueAction extends Action {
  78334. /**
  78335. * The path of the property to increment in the target.
  78336. */
  78337. propertyPath: string;
  78338. /**
  78339. * The value we should increment the property by.
  78340. */
  78341. value: any;
  78342. private _target;
  78343. private _effectiveTarget;
  78344. private _property;
  78345. /**
  78346. * Instantiate the action
  78347. * @param triggerOptions defines the trigger options
  78348. * @param target defines the object containing the property
  78349. * @param propertyPath defines the path of the property to increment in the target
  78350. * @param value defines the value value we should increment the property by
  78351. * @param condition defines the trigger related conditions
  78352. */
  78353. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78354. /** @hidden */
  78355. _prepare(): void;
  78356. /**
  78357. * Execute the action and increment the target of the value amount.
  78358. */
  78359. execute(): void;
  78360. /**
  78361. * Serializes the actions and its related information.
  78362. * @param parent defines the object to serialize in
  78363. * @returns the serialized object
  78364. */
  78365. serialize(parent: any): any;
  78366. }
  78367. /**
  78368. * This defines an action responsible to start an animation once triggered.
  78369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78370. */
  78371. export class PlayAnimationAction extends Action {
  78372. /**
  78373. * Where the animation should start (animation frame)
  78374. */
  78375. from: number;
  78376. /**
  78377. * Where the animation should stop (animation frame)
  78378. */
  78379. to: number;
  78380. /**
  78381. * Define if the animation should loop or stop after the first play.
  78382. */
  78383. loop?: boolean;
  78384. private _target;
  78385. /**
  78386. * Instantiate the action
  78387. * @param triggerOptions defines the trigger options
  78388. * @param target defines the target animation or animation name
  78389. * @param from defines from where the animation should start (animation frame)
  78390. * @param end defines where the animation should stop (animation frame)
  78391. * @param loop defines if the animation should loop or stop after the first play
  78392. * @param condition defines the trigger related conditions
  78393. */
  78394. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78395. /** @hidden */
  78396. _prepare(): void;
  78397. /**
  78398. * Execute the action and play the animation.
  78399. */
  78400. execute(): void;
  78401. /**
  78402. * Serializes the actions and its related information.
  78403. * @param parent defines the object to serialize in
  78404. * @returns the serialized object
  78405. */
  78406. serialize(parent: any): any;
  78407. }
  78408. /**
  78409. * This defines an action responsible to stop an animation once triggered.
  78410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78411. */
  78412. export class StopAnimationAction extends Action {
  78413. private _target;
  78414. /**
  78415. * Instantiate the action
  78416. * @param triggerOptions defines the trigger options
  78417. * @param target defines the target animation or animation name
  78418. * @param condition defines the trigger related conditions
  78419. */
  78420. constructor(triggerOptions: any, target: any, condition?: Condition);
  78421. /** @hidden */
  78422. _prepare(): void;
  78423. /**
  78424. * Execute the action and stop the animation.
  78425. */
  78426. execute(): void;
  78427. /**
  78428. * Serializes the actions and its related information.
  78429. * @param parent defines the object to serialize in
  78430. * @returns the serialized object
  78431. */
  78432. serialize(parent: any): any;
  78433. }
  78434. /**
  78435. * This defines an action responsible that does nothing once triggered.
  78436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78437. */
  78438. export class DoNothingAction extends Action {
  78439. /**
  78440. * Instantiate the action
  78441. * @param triggerOptions defines the trigger options
  78442. * @param condition defines the trigger related conditions
  78443. */
  78444. constructor(triggerOptions?: any, condition?: Condition);
  78445. /**
  78446. * Execute the action and do nothing.
  78447. */
  78448. execute(): void;
  78449. /**
  78450. * Serializes the actions and its related information.
  78451. * @param parent defines the object to serialize in
  78452. * @returns the serialized object
  78453. */
  78454. serialize(parent: any): any;
  78455. }
  78456. /**
  78457. * This defines an action responsible to trigger several actions once triggered.
  78458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78459. */
  78460. export class CombineAction extends Action {
  78461. /**
  78462. * The list of aggregated animations to run.
  78463. */
  78464. children: Action[];
  78465. /**
  78466. * Instantiate the action
  78467. * @param triggerOptions defines the trigger options
  78468. * @param children defines the list of aggregated animations to run
  78469. * @param condition defines the trigger related conditions
  78470. */
  78471. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78472. /** @hidden */
  78473. _prepare(): void;
  78474. /**
  78475. * Execute the action and executes all the aggregated actions.
  78476. */
  78477. execute(evt: ActionEvent): void;
  78478. /**
  78479. * Serializes the actions and its related information.
  78480. * @param parent defines the object to serialize in
  78481. * @returns the serialized object
  78482. */
  78483. serialize(parent: any): any;
  78484. }
  78485. /**
  78486. * This defines an action responsible to run code (external event) once triggered.
  78487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78488. */
  78489. export class ExecuteCodeAction extends Action {
  78490. /**
  78491. * The callback function to run.
  78492. */
  78493. func: (evt: ActionEvent) => void;
  78494. /**
  78495. * Instantiate the action
  78496. * @param triggerOptions defines the trigger options
  78497. * @param func defines the callback function to run
  78498. * @param condition defines the trigger related conditions
  78499. */
  78500. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78501. /**
  78502. * Execute the action and run the attached code.
  78503. */
  78504. execute(evt: ActionEvent): void;
  78505. }
  78506. /**
  78507. * This defines an action responsible to set the parent property of the target once triggered.
  78508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78509. */
  78510. export class SetParentAction extends Action {
  78511. private _parent;
  78512. private _target;
  78513. /**
  78514. * Instantiate the action
  78515. * @param triggerOptions defines the trigger options
  78516. * @param target defines the target containing the parent property
  78517. * @param parent defines from where the animation should start (animation frame)
  78518. * @param condition defines the trigger related conditions
  78519. */
  78520. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78521. /** @hidden */
  78522. _prepare(): void;
  78523. /**
  78524. * Execute the action and set the parent property.
  78525. */
  78526. execute(): void;
  78527. /**
  78528. * Serializes the actions and its related information.
  78529. * @param parent defines the object to serialize in
  78530. * @returns the serialized object
  78531. */
  78532. serialize(parent: any): any;
  78533. }
  78534. }
  78535. declare module BABYLON {
  78536. /**
  78537. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78538. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78540. */
  78541. export class ActionManager extends AbstractActionManager {
  78542. /**
  78543. * Nothing
  78544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78545. */
  78546. static readonly NothingTrigger: number;
  78547. /**
  78548. * On pick
  78549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78550. */
  78551. static readonly OnPickTrigger: number;
  78552. /**
  78553. * On left pick
  78554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78555. */
  78556. static readonly OnLeftPickTrigger: number;
  78557. /**
  78558. * On right pick
  78559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78560. */
  78561. static readonly OnRightPickTrigger: number;
  78562. /**
  78563. * On center pick
  78564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78565. */
  78566. static readonly OnCenterPickTrigger: number;
  78567. /**
  78568. * On pick down
  78569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78570. */
  78571. static readonly OnPickDownTrigger: number;
  78572. /**
  78573. * On double pick
  78574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78575. */
  78576. static readonly OnDoublePickTrigger: number;
  78577. /**
  78578. * On pick up
  78579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78580. */
  78581. static readonly OnPickUpTrigger: number;
  78582. /**
  78583. * On pick out.
  78584. * This trigger will only be raised if you also declared a OnPickDown
  78585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78586. */
  78587. static readonly OnPickOutTrigger: number;
  78588. /**
  78589. * On long press
  78590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78591. */
  78592. static readonly OnLongPressTrigger: number;
  78593. /**
  78594. * On pointer over
  78595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78596. */
  78597. static readonly OnPointerOverTrigger: number;
  78598. /**
  78599. * On pointer out
  78600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78601. */
  78602. static readonly OnPointerOutTrigger: number;
  78603. /**
  78604. * On every frame
  78605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78606. */
  78607. static readonly OnEveryFrameTrigger: number;
  78608. /**
  78609. * On intersection enter
  78610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78611. */
  78612. static readonly OnIntersectionEnterTrigger: number;
  78613. /**
  78614. * On intersection exit
  78615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78616. */
  78617. static readonly OnIntersectionExitTrigger: number;
  78618. /**
  78619. * On key down
  78620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78621. */
  78622. static readonly OnKeyDownTrigger: number;
  78623. /**
  78624. * On key up
  78625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78626. */
  78627. static readonly OnKeyUpTrigger: number;
  78628. private _scene;
  78629. /**
  78630. * Creates a new action manager
  78631. * @param scene defines the hosting scene
  78632. */
  78633. constructor(scene: Scene);
  78634. /**
  78635. * Releases all associated resources
  78636. */
  78637. dispose(): void;
  78638. /**
  78639. * Gets hosting scene
  78640. * @returns the hosting scene
  78641. */
  78642. getScene(): Scene;
  78643. /**
  78644. * Does this action manager handles actions of any of the given triggers
  78645. * @param triggers defines the triggers to be tested
  78646. * @return a boolean indicating whether one (or more) of the triggers is handled
  78647. */
  78648. hasSpecificTriggers(triggers: number[]): boolean;
  78649. /**
  78650. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78651. * speed.
  78652. * @param triggerA defines the trigger to be tested
  78653. * @param triggerB defines the trigger to be tested
  78654. * @return a boolean indicating whether one (or more) of the triggers is handled
  78655. */
  78656. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78657. /**
  78658. * Does this action manager handles actions of a given trigger
  78659. * @param trigger defines the trigger to be tested
  78660. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78661. * @return whether the trigger is handled
  78662. */
  78663. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78664. /**
  78665. * Does this action manager has pointer triggers
  78666. */
  78667. readonly hasPointerTriggers: boolean;
  78668. /**
  78669. * Does this action manager has pick triggers
  78670. */
  78671. readonly hasPickTriggers: boolean;
  78672. /**
  78673. * Registers an action to this action manager
  78674. * @param action defines the action to be registered
  78675. * @return the action amended (prepared) after registration
  78676. */
  78677. registerAction(action: IAction): Nullable<IAction>;
  78678. /**
  78679. * Unregisters an action to this action manager
  78680. * @param action defines the action to be unregistered
  78681. * @return a boolean indicating whether the action has been unregistered
  78682. */
  78683. unregisterAction(action: IAction): Boolean;
  78684. /**
  78685. * Process a specific trigger
  78686. * @param trigger defines the trigger to process
  78687. * @param evt defines the event details to be processed
  78688. */
  78689. processTrigger(trigger: number, evt?: IActionEvent): void;
  78690. /** @hidden */
  78691. _getEffectiveTarget(target: any, propertyPath: string): any;
  78692. /** @hidden */
  78693. _getProperty(propertyPath: string): string;
  78694. /**
  78695. * Serialize this manager to a JSON object
  78696. * @param name defines the property name to store this manager
  78697. * @returns a JSON representation of this manager
  78698. */
  78699. serialize(name: string): any;
  78700. /**
  78701. * Creates a new ActionManager from a JSON data
  78702. * @param parsedActions defines the JSON data to read from
  78703. * @param object defines the hosting mesh
  78704. * @param scene defines the hosting scene
  78705. */
  78706. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78707. /**
  78708. * Get a trigger name by index
  78709. * @param trigger defines the trigger index
  78710. * @returns a trigger name
  78711. */
  78712. static GetTriggerName(trigger: number): string;
  78713. }
  78714. }
  78715. declare module BABYLON {
  78716. /**
  78717. * Class representing a ray with position and direction
  78718. */
  78719. export class Ray {
  78720. /** origin point */
  78721. origin: Vector3;
  78722. /** direction */
  78723. direction: Vector3;
  78724. /** length of the ray */
  78725. length: number;
  78726. private static readonly TmpVector3;
  78727. private _tmpRay;
  78728. /**
  78729. * Creates a new ray
  78730. * @param origin origin point
  78731. * @param direction direction
  78732. * @param length length of the ray
  78733. */
  78734. constructor(
  78735. /** origin point */
  78736. origin: Vector3,
  78737. /** direction */
  78738. direction: Vector3,
  78739. /** length of the ray */
  78740. length?: number);
  78741. /**
  78742. * Checks if the ray intersects a box
  78743. * @param minimum bound of the box
  78744. * @param maximum bound of the box
  78745. * @param intersectionTreshold extra extend to be added to the box in all direction
  78746. * @returns if the box was hit
  78747. */
  78748. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78749. /**
  78750. * Checks if the ray intersects a box
  78751. * @param box the bounding box to check
  78752. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78753. * @returns if the box was hit
  78754. */
  78755. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78756. /**
  78757. * If the ray hits a sphere
  78758. * @param sphere the bounding sphere to check
  78759. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78760. * @returns true if it hits the sphere
  78761. */
  78762. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78763. /**
  78764. * If the ray hits a triange
  78765. * @param vertex0 triangle vertex
  78766. * @param vertex1 triangle vertex
  78767. * @param vertex2 triangle vertex
  78768. * @returns intersection information if hit
  78769. */
  78770. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78771. /**
  78772. * Checks if ray intersects a plane
  78773. * @param plane the plane to check
  78774. * @returns the distance away it was hit
  78775. */
  78776. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78777. /**
  78778. * Calculate the intercept of a ray on a given axis
  78779. * @param axis to check 'x' | 'y' | 'z'
  78780. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78781. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78782. */
  78783. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78784. /**
  78785. * Checks if ray intersects a mesh
  78786. * @param mesh the mesh to check
  78787. * @param fastCheck if only the bounding box should checked
  78788. * @returns picking info of the intersecton
  78789. */
  78790. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78791. /**
  78792. * Checks if ray intersects a mesh
  78793. * @param meshes the meshes to check
  78794. * @param fastCheck if only the bounding box should checked
  78795. * @param results array to store result in
  78796. * @returns Array of picking infos
  78797. */
  78798. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78799. private _comparePickingInfo;
  78800. private static smallnum;
  78801. private static rayl;
  78802. /**
  78803. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78804. * @param sega the first point of the segment to test the intersection against
  78805. * @param segb the second point of the segment to test the intersection against
  78806. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78807. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78808. */
  78809. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78810. /**
  78811. * Update the ray from viewport position
  78812. * @param x position
  78813. * @param y y position
  78814. * @param viewportWidth viewport width
  78815. * @param viewportHeight viewport height
  78816. * @param world world matrix
  78817. * @param view view matrix
  78818. * @param projection projection matrix
  78819. * @returns this ray updated
  78820. */
  78821. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78822. /**
  78823. * Creates a ray with origin and direction of 0,0,0
  78824. * @returns the new ray
  78825. */
  78826. static Zero(): Ray;
  78827. /**
  78828. * Creates a new ray from screen space and viewport
  78829. * @param x position
  78830. * @param y y position
  78831. * @param viewportWidth viewport width
  78832. * @param viewportHeight viewport height
  78833. * @param world world matrix
  78834. * @param view view matrix
  78835. * @param projection projection matrix
  78836. * @returns new ray
  78837. */
  78838. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78839. /**
  78840. * 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
  78841. * transformed to the given world matrix.
  78842. * @param origin The origin point
  78843. * @param end The end point
  78844. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78845. * @returns the new ray
  78846. */
  78847. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78848. /**
  78849. * Transforms a ray by a matrix
  78850. * @param ray ray to transform
  78851. * @param matrix matrix to apply
  78852. * @returns the resulting new ray
  78853. */
  78854. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78855. /**
  78856. * Transforms a ray by a matrix
  78857. * @param ray ray to transform
  78858. * @param matrix matrix to apply
  78859. * @param result ray to store result in
  78860. */
  78861. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78862. /**
  78863. * Unproject a ray from screen space to object space
  78864. * @param sourceX defines the screen space x coordinate to use
  78865. * @param sourceY defines the screen space y coordinate to use
  78866. * @param viewportWidth defines the current width of the viewport
  78867. * @param viewportHeight defines the current height of the viewport
  78868. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78869. * @param view defines the view matrix to use
  78870. * @param projection defines the projection matrix to use
  78871. */
  78872. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78873. }
  78874. /**
  78875. * Type used to define predicate used to select faces when a mesh intersection is detected
  78876. */
  78877. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78878. interface Scene {
  78879. /** @hidden */
  78880. _tempPickingRay: Nullable<Ray>;
  78881. /** @hidden */
  78882. _cachedRayForTransform: Ray;
  78883. /** @hidden */
  78884. _pickWithRayInverseMatrix: Matrix;
  78885. /** @hidden */
  78886. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78887. /** @hidden */
  78888. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78889. }
  78890. }
  78891. declare module BABYLON {
  78892. /**
  78893. * Groups all the scene component constants in one place to ease maintenance.
  78894. * @hidden
  78895. */
  78896. export class SceneComponentConstants {
  78897. static readonly NAME_EFFECTLAYER: string;
  78898. static readonly NAME_LAYER: string;
  78899. static readonly NAME_LENSFLARESYSTEM: string;
  78900. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78901. static readonly NAME_PARTICLESYSTEM: string;
  78902. static readonly NAME_GAMEPAD: string;
  78903. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78904. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78905. static readonly NAME_DEPTHRENDERER: string;
  78906. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78907. static readonly NAME_SPRITE: string;
  78908. static readonly NAME_OUTLINERENDERER: string;
  78909. static readonly NAME_PROCEDURALTEXTURE: string;
  78910. static readonly NAME_SHADOWGENERATOR: string;
  78911. static readonly NAME_OCTREE: string;
  78912. static readonly NAME_PHYSICSENGINE: string;
  78913. static readonly NAME_AUDIO: string;
  78914. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78915. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78916. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78917. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78918. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78919. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78920. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78921. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78922. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78923. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78924. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78925. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78926. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78927. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78928. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78929. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78930. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78931. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78932. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78933. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78934. static readonly STEP_AFTERRENDER_AUDIO: number;
  78935. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78936. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78937. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78938. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78939. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78940. static readonly STEP_POINTERMOVE_SPRITE: number;
  78941. static readonly STEP_POINTERDOWN_SPRITE: number;
  78942. static readonly STEP_POINTERUP_SPRITE: number;
  78943. }
  78944. /**
  78945. * This represents a scene component.
  78946. *
  78947. * This is used to decouple the dependency the scene is having on the different workloads like
  78948. * layers, post processes...
  78949. */
  78950. export interface ISceneComponent {
  78951. /**
  78952. * The name of the component. Each component must have a unique name.
  78953. */
  78954. name: string;
  78955. /**
  78956. * The scene the component belongs to.
  78957. */
  78958. scene: Scene;
  78959. /**
  78960. * Register the component to one instance of a scene.
  78961. */
  78962. register(): void;
  78963. /**
  78964. * Rebuilds the elements related to this component in case of
  78965. * context lost for instance.
  78966. */
  78967. rebuild(): void;
  78968. /**
  78969. * Disposes the component and the associated ressources.
  78970. */
  78971. dispose(): void;
  78972. }
  78973. /**
  78974. * This represents a SERIALIZABLE scene component.
  78975. *
  78976. * This extends Scene Component to add Serialization methods on top.
  78977. */
  78978. export interface ISceneSerializableComponent extends ISceneComponent {
  78979. /**
  78980. * Adds all the elements from the container to the scene
  78981. * @param container the container holding the elements
  78982. */
  78983. addFromContainer(container: AbstractScene): void;
  78984. /**
  78985. * Removes all the elements in the container from the scene
  78986. * @param container contains the elements to remove
  78987. * @param dispose if the removed element should be disposed (default: false)
  78988. */
  78989. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78990. /**
  78991. * Serializes the component data to the specified json object
  78992. * @param serializationObject The object to serialize to
  78993. */
  78994. serialize(serializationObject: any): void;
  78995. }
  78996. /**
  78997. * Strong typing of a Mesh related stage step action
  78998. */
  78999. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79000. /**
  79001. * Strong typing of a Evaluate Sub Mesh related stage step action
  79002. */
  79003. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79004. /**
  79005. * Strong typing of a Active Mesh related stage step action
  79006. */
  79007. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79008. /**
  79009. * Strong typing of a Camera related stage step action
  79010. */
  79011. export type CameraStageAction = (camera: Camera) => void;
  79012. /**
  79013. * Strong typing of a Camera Frame buffer related stage step action
  79014. */
  79015. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79016. /**
  79017. * Strong typing of a Render Target related stage step action
  79018. */
  79019. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79020. /**
  79021. * Strong typing of a RenderingGroup related stage step action
  79022. */
  79023. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79024. /**
  79025. * Strong typing of a Mesh Render related stage step action
  79026. */
  79027. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79028. /**
  79029. * Strong typing of a simple stage step action
  79030. */
  79031. export type SimpleStageAction = () => void;
  79032. /**
  79033. * Strong typing of a render target action.
  79034. */
  79035. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79036. /**
  79037. * Strong typing of a pointer move action.
  79038. */
  79039. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79040. /**
  79041. * Strong typing of a pointer up/down action.
  79042. */
  79043. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79044. /**
  79045. * Representation of a stage in the scene (Basically a list of ordered steps)
  79046. * @hidden
  79047. */
  79048. export class Stage<T extends Function> extends Array<{
  79049. index: number;
  79050. component: ISceneComponent;
  79051. action: T;
  79052. }> {
  79053. /**
  79054. * Hide ctor from the rest of the world.
  79055. * @param items The items to add.
  79056. */
  79057. private constructor();
  79058. /**
  79059. * Creates a new Stage.
  79060. * @returns A new instance of a Stage
  79061. */
  79062. static Create<T extends Function>(): Stage<T>;
  79063. /**
  79064. * Registers a step in an ordered way in the targeted stage.
  79065. * @param index Defines the position to register the step in
  79066. * @param component Defines the component attached to the step
  79067. * @param action Defines the action to launch during the step
  79068. */
  79069. registerStep(index: number, component: ISceneComponent, action: T): void;
  79070. /**
  79071. * Clears all the steps from the stage.
  79072. */
  79073. clear(): void;
  79074. }
  79075. }
  79076. declare module BABYLON {
  79077. interface Scene {
  79078. /** @hidden */
  79079. _pointerOverSprite: Nullable<Sprite>;
  79080. /** @hidden */
  79081. _pickedDownSprite: Nullable<Sprite>;
  79082. /** @hidden */
  79083. _tempSpritePickingRay: Nullable<Ray>;
  79084. /**
  79085. * All of the sprite managers added to this scene
  79086. * @see http://doc.babylonjs.com/babylon101/sprites
  79087. */
  79088. spriteManagers: Array<ISpriteManager>;
  79089. /**
  79090. * An event triggered when sprites rendering is about to start
  79091. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79092. */
  79093. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79094. /**
  79095. * An event triggered when sprites rendering is done
  79096. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79097. */
  79098. onAfterSpritesRenderingObservable: Observable<Scene>;
  79099. /** @hidden */
  79100. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79101. /** Launch a ray to try to pick a sprite in the scene
  79102. * @param x position on screen
  79103. * @param y position on screen
  79104. * @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
  79105. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79107. * @returns a PickingInfo
  79108. */
  79109. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79110. /** Use the given ray to pick a sprite in the scene
  79111. * @param ray The ray (in world space) to use to pick meshes
  79112. * @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
  79113. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79115. * @returns a PickingInfo
  79116. */
  79117. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79118. /** @hidden */
  79119. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79120. /** Launch a ray to try to pick sprites in the scene
  79121. * @param x position on screen
  79122. * @param y position on screen
  79123. * @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
  79124. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79125. * @returns a PickingInfo array
  79126. */
  79127. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79128. /** Use the given ray to pick sprites in the scene
  79129. * @param ray The ray (in world space) to use to pick meshes
  79130. * @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
  79131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79132. * @returns a PickingInfo array
  79133. */
  79134. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79135. /**
  79136. * Force the sprite under the pointer
  79137. * @param sprite defines the sprite to use
  79138. */
  79139. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79140. /**
  79141. * Gets the sprite under the pointer
  79142. * @returns a Sprite or null if no sprite is under the pointer
  79143. */
  79144. getPointerOverSprite(): Nullable<Sprite>;
  79145. }
  79146. /**
  79147. * Defines the sprite scene component responsible to manage sprites
  79148. * in a given scene.
  79149. */
  79150. export class SpriteSceneComponent implements ISceneComponent {
  79151. /**
  79152. * The component name helpfull to identify the component in the list of scene components.
  79153. */
  79154. readonly name: string;
  79155. /**
  79156. * The scene the component belongs to.
  79157. */
  79158. scene: Scene;
  79159. /** @hidden */
  79160. private _spritePredicate;
  79161. /**
  79162. * Creates a new instance of the component for the given scene
  79163. * @param scene Defines the scene to register the component in
  79164. */
  79165. constructor(scene: Scene);
  79166. /**
  79167. * Registers the component in a given scene
  79168. */
  79169. register(): void;
  79170. /**
  79171. * Rebuilds the elements related to this component in case of
  79172. * context lost for instance.
  79173. */
  79174. rebuild(): void;
  79175. /**
  79176. * Disposes the component and the associated ressources.
  79177. */
  79178. dispose(): void;
  79179. private _pickSpriteButKeepRay;
  79180. private _pointerMove;
  79181. private _pointerDown;
  79182. private _pointerUp;
  79183. }
  79184. }
  79185. declare module BABYLON {
  79186. /** @hidden */
  79187. export var fogFragmentDeclaration: {
  79188. name: string;
  79189. shader: string;
  79190. };
  79191. }
  79192. declare module BABYLON {
  79193. /** @hidden */
  79194. export var fogFragment: {
  79195. name: string;
  79196. shader: string;
  79197. };
  79198. }
  79199. declare module BABYLON {
  79200. /** @hidden */
  79201. export var spritesPixelShader: {
  79202. name: string;
  79203. shader: string;
  79204. };
  79205. }
  79206. declare module BABYLON {
  79207. /** @hidden */
  79208. export var fogVertexDeclaration: {
  79209. name: string;
  79210. shader: string;
  79211. };
  79212. }
  79213. declare module BABYLON {
  79214. /** @hidden */
  79215. export var spritesVertexShader: {
  79216. name: string;
  79217. shader: string;
  79218. };
  79219. }
  79220. declare module BABYLON {
  79221. /**
  79222. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79223. */
  79224. export interface ISpriteManager extends IDisposable {
  79225. /**
  79226. * Restricts the camera to viewing objects with the same layerMask.
  79227. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79228. */
  79229. layerMask: number;
  79230. /**
  79231. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79232. */
  79233. isPickable: boolean;
  79234. /**
  79235. * Specifies the rendering group id for this mesh (0 by default)
  79236. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79237. */
  79238. renderingGroupId: number;
  79239. /**
  79240. * Defines the list of sprites managed by the manager.
  79241. */
  79242. sprites: Array<Sprite>;
  79243. /**
  79244. * Tests the intersection of a sprite with a specific ray.
  79245. * @param ray The ray we are sending to test the collision
  79246. * @param camera The camera space we are sending rays in
  79247. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79248. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79249. * @returns picking info or null.
  79250. */
  79251. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79252. /**
  79253. * Intersects the sprites with a ray
  79254. * @param ray defines the ray to intersect with
  79255. * @param camera defines the current active camera
  79256. * @param predicate defines a predicate used to select candidate sprites
  79257. * @returns null if no hit or a PickingInfo array
  79258. */
  79259. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79260. /**
  79261. * Renders the list of sprites on screen.
  79262. */
  79263. render(): void;
  79264. }
  79265. /**
  79266. * Class used to manage multiple sprites on the same spritesheet
  79267. * @see http://doc.babylonjs.com/babylon101/sprites
  79268. */
  79269. export class SpriteManager implements ISpriteManager {
  79270. /** defines the manager's name */
  79271. name: string;
  79272. /** Gets the list of sprites */
  79273. sprites: Sprite[];
  79274. /** Gets or sets the rendering group id (0 by default) */
  79275. renderingGroupId: number;
  79276. /** Gets or sets camera layer mask */
  79277. layerMask: number;
  79278. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79279. fogEnabled: boolean;
  79280. /** Gets or sets a boolean indicating if the sprites are pickable */
  79281. isPickable: boolean;
  79282. /** Defines the default width of a cell in the spritesheet */
  79283. cellWidth: number;
  79284. /** Defines the default height of a cell in the spritesheet */
  79285. cellHeight: number;
  79286. /** Associative array from JSON sprite data file */
  79287. private _cellData;
  79288. /** Array of sprite names from JSON sprite data file */
  79289. private _spriteMap;
  79290. /** True when packed cell data from JSON file is ready*/
  79291. private _packedAndReady;
  79292. /**
  79293. * An event triggered when the manager is disposed.
  79294. */
  79295. onDisposeObservable: Observable<SpriteManager>;
  79296. private _onDisposeObserver;
  79297. /**
  79298. * Callback called when the manager is disposed
  79299. */
  79300. onDispose: () => void;
  79301. private _capacity;
  79302. private _fromPacked;
  79303. private _spriteTexture;
  79304. private _epsilon;
  79305. private _scene;
  79306. private _vertexData;
  79307. private _buffer;
  79308. private _vertexBuffers;
  79309. private _indexBuffer;
  79310. private _effectBase;
  79311. private _effectFog;
  79312. /**
  79313. * Gets or sets the spritesheet texture
  79314. */
  79315. texture: Texture;
  79316. /**
  79317. * Creates a new sprite manager
  79318. * @param name defines the manager's name
  79319. * @param imgUrl defines the sprite sheet url
  79320. * @param capacity defines the maximum allowed number of sprites
  79321. * @param cellSize defines the size of a sprite cell
  79322. * @param scene defines the hosting scene
  79323. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79324. * @param samplingMode defines the smapling mode to use with spritesheet
  79325. * @param fromPacked set to false; do not alter
  79326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79327. */
  79328. constructor(
  79329. /** defines the manager's name */
  79330. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79331. private _makePacked;
  79332. private _appendSpriteVertex;
  79333. /**
  79334. * Intersects the sprites with a ray
  79335. * @param ray defines the ray to intersect with
  79336. * @param camera defines the current active camera
  79337. * @param predicate defines a predicate used to select candidate sprites
  79338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79339. * @returns null if no hit or a PickingInfo
  79340. */
  79341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79342. /**
  79343. * Intersects the sprites with a ray
  79344. * @param ray defines the ray to intersect with
  79345. * @param camera defines the current active camera
  79346. * @param predicate defines a predicate used to select candidate sprites
  79347. * @returns null if no hit or a PickingInfo array
  79348. */
  79349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79350. /**
  79351. * Render all child sprites
  79352. */
  79353. render(): void;
  79354. /**
  79355. * Release associated resources
  79356. */
  79357. dispose(): void;
  79358. }
  79359. }
  79360. declare module BABYLON {
  79361. /**
  79362. * Class used to represent a sprite
  79363. * @see http://doc.babylonjs.com/babylon101/sprites
  79364. */
  79365. export class Sprite {
  79366. /** defines the name */
  79367. name: string;
  79368. /** Gets or sets the current world position */
  79369. position: Vector3;
  79370. /** Gets or sets the main color */
  79371. color: Color4;
  79372. /** Gets or sets the width */
  79373. width: number;
  79374. /** Gets or sets the height */
  79375. height: number;
  79376. /** Gets or sets rotation angle */
  79377. angle: number;
  79378. /** Gets or sets the cell index in the sprite sheet */
  79379. cellIndex: number;
  79380. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79381. cellRef: string;
  79382. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79383. invertU: number;
  79384. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79385. invertV: number;
  79386. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79387. disposeWhenFinishedAnimating: boolean;
  79388. /** Gets the list of attached animations */
  79389. animations: Animation[];
  79390. /** Gets or sets a boolean indicating if the sprite can be picked */
  79391. isPickable: boolean;
  79392. /**
  79393. * Gets or sets the associated action manager
  79394. */
  79395. actionManager: Nullable<ActionManager>;
  79396. private _animationStarted;
  79397. private _loopAnimation;
  79398. private _fromIndex;
  79399. private _toIndex;
  79400. private _delay;
  79401. private _direction;
  79402. private _manager;
  79403. private _time;
  79404. private _onAnimationEnd;
  79405. /**
  79406. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79407. */
  79408. isVisible: boolean;
  79409. /**
  79410. * Gets or sets the sprite size
  79411. */
  79412. size: number;
  79413. /**
  79414. * Creates a new Sprite
  79415. * @param name defines the name
  79416. * @param manager defines the manager
  79417. */
  79418. constructor(
  79419. /** defines the name */
  79420. name: string, manager: ISpriteManager);
  79421. /**
  79422. * Starts an animation
  79423. * @param from defines the initial key
  79424. * @param to defines the end key
  79425. * @param loop defines if the animation must loop
  79426. * @param delay defines the start delay (in ms)
  79427. * @param onAnimationEnd defines a callback to call when animation ends
  79428. */
  79429. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79430. /** Stops current animation (if any) */
  79431. stopAnimation(): void;
  79432. /** @hidden */
  79433. _animate(deltaTime: number): void;
  79434. /** Release associated resources */
  79435. dispose(): void;
  79436. }
  79437. }
  79438. declare module BABYLON {
  79439. /**
  79440. * Information about the result of picking within a scene
  79441. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79442. */
  79443. export class PickingInfo {
  79444. /** @hidden */
  79445. _pickingUnavailable: boolean;
  79446. /**
  79447. * If the pick collided with an object
  79448. */
  79449. hit: boolean;
  79450. /**
  79451. * Distance away where the pick collided
  79452. */
  79453. distance: number;
  79454. /**
  79455. * The location of pick collision
  79456. */
  79457. pickedPoint: Nullable<Vector3>;
  79458. /**
  79459. * The mesh corresponding the the pick collision
  79460. */
  79461. pickedMesh: Nullable<AbstractMesh>;
  79462. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79463. bu: number;
  79464. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79465. bv: number;
  79466. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79467. faceId: number;
  79468. /** Id of the the submesh that was picked */
  79469. subMeshId: number;
  79470. /** If a sprite was picked, this will be the sprite the pick collided with */
  79471. pickedSprite: Nullable<Sprite>;
  79472. /**
  79473. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79474. */
  79475. originMesh: Nullable<AbstractMesh>;
  79476. /**
  79477. * The ray that was used to perform the picking.
  79478. */
  79479. ray: Nullable<Ray>;
  79480. /**
  79481. * Gets the normal correspodning to the face the pick collided with
  79482. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79483. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79484. * @returns The normal correspodning to the face the pick collided with
  79485. */
  79486. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79487. /**
  79488. * Gets the texture coordinates of where the pick occured
  79489. * @returns the vector containing the coordnates of the texture
  79490. */
  79491. getTextureCoordinates(): Nullable<Vector2>;
  79492. }
  79493. }
  79494. declare module BABYLON {
  79495. /**
  79496. * Gather the list of pointer event types as constants.
  79497. */
  79498. export class PointerEventTypes {
  79499. /**
  79500. * 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.
  79501. */
  79502. static readonly POINTERDOWN: number;
  79503. /**
  79504. * The pointerup event is fired when a pointer is no longer active.
  79505. */
  79506. static readonly POINTERUP: number;
  79507. /**
  79508. * The pointermove event is fired when a pointer changes coordinates.
  79509. */
  79510. static readonly POINTERMOVE: number;
  79511. /**
  79512. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79513. */
  79514. static readonly POINTERWHEEL: number;
  79515. /**
  79516. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79517. */
  79518. static readonly POINTERPICK: number;
  79519. /**
  79520. * The pointertap event is fired when a the object has been touched and released without drag.
  79521. */
  79522. static readonly POINTERTAP: number;
  79523. /**
  79524. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79525. */
  79526. static readonly POINTERDOUBLETAP: number;
  79527. }
  79528. /**
  79529. * Base class of pointer info types.
  79530. */
  79531. export class PointerInfoBase {
  79532. /**
  79533. * Defines the type of event (PointerEventTypes)
  79534. */
  79535. type: number;
  79536. /**
  79537. * Defines the related dom event
  79538. */
  79539. event: PointerEvent | MouseWheelEvent;
  79540. /**
  79541. * Instantiates the base class of pointers info.
  79542. * @param type Defines the type of event (PointerEventTypes)
  79543. * @param event Defines the related dom event
  79544. */
  79545. constructor(
  79546. /**
  79547. * Defines the type of event (PointerEventTypes)
  79548. */
  79549. type: number,
  79550. /**
  79551. * Defines the related dom event
  79552. */
  79553. event: PointerEvent | MouseWheelEvent);
  79554. }
  79555. /**
  79556. * This class is used to store pointer related info for the onPrePointerObservable event.
  79557. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79558. */
  79559. export class PointerInfoPre extends PointerInfoBase {
  79560. /**
  79561. * Ray from a pointer if availible (eg. 6dof controller)
  79562. */
  79563. ray: Nullable<Ray>;
  79564. /**
  79565. * Defines the local position of the pointer on the canvas.
  79566. */
  79567. localPosition: Vector2;
  79568. /**
  79569. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79570. */
  79571. skipOnPointerObservable: boolean;
  79572. /**
  79573. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79574. * @param type Defines the type of event (PointerEventTypes)
  79575. * @param event Defines the related dom event
  79576. * @param localX Defines the local x coordinates of the pointer when the event occured
  79577. * @param localY Defines the local y coordinates of the pointer when the event occured
  79578. */
  79579. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79580. }
  79581. /**
  79582. * This type contains all the data related to a pointer event in Babylon.js.
  79583. * 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.
  79584. */
  79585. export class PointerInfo extends PointerInfoBase {
  79586. /**
  79587. * Defines the picking info associated to the info (if any)\
  79588. */
  79589. pickInfo: Nullable<PickingInfo>;
  79590. /**
  79591. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79592. * @param type Defines the type of event (PointerEventTypes)
  79593. * @param event Defines the related dom event
  79594. * @param pickInfo Defines the picking info associated to the info (if any)\
  79595. */
  79596. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79597. /**
  79598. * Defines the picking info associated to the info (if any)\
  79599. */
  79600. pickInfo: Nullable<PickingInfo>);
  79601. }
  79602. /**
  79603. * Data relating to a touch event on the screen.
  79604. */
  79605. export interface PointerTouch {
  79606. /**
  79607. * X coordinate of touch.
  79608. */
  79609. x: number;
  79610. /**
  79611. * Y coordinate of touch.
  79612. */
  79613. y: number;
  79614. /**
  79615. * Id of touch. Unique for each finger.
  79616. */
  79617. pointerId: number;
  79618. /**
  79619. * Event type passed from DOM.
  79620. */
  79621. type: any;
  79622. }
  79623. }
  79624. declare module BABYLON {
  79625. /**
  79626. * Manage the mouse inputs to control the movement of a free camera.
  79627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79628. */
  79629. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79630. /**
  79631. * Define if touch is enabled in the mouse input
  79632. */
  79633. touchEnabled: boolean;
  79634. /**
  79635. * Defines the camera the input is attached to.
  79636. */
  79637. camera: FreeCamera;
  79638. /**
  79639. * Defines the buttons associated with the input to handle camera move.
  79640. */
  79641. buttons: number[];
  79642. /**
  79643. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79644. */
  79645. angularSensibility: number;
  79646. private _pointerInput;
  79647. private _onMouseMove;
  79648. private _observer;
  79649. private previousPosition;
  79650. /**
  79651. * Observable for when a pointer move event occurs containing the move offset
  79652. */
  79653. onPointerMovedObservable: Observable<{
  79654. offsetX: number;
  79655. offsetY: number;
  79656. }>;
  79657. /**
  79658. * @hidden
  79659. * If the camera should be rotated automatically based on pointer movement
  79660. */
  79661. _allowCameraRotation: boolean;
  79662. /**
  79663. * Manage the mouse inputs to control the movement of a free camera.
  79664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79665. * @param touchEnabled Defines if touch is enabled or not
  79666. */
  79667. constructor(
  79668. /**
  79669. * Define if touch is enabled in the mouse input
  79670. */
  79671. touchEnabled?: boolean);
  79672. /**
  79673. * Attach the input controls to a specific dom element to get the input from.
  79674. * @param element Defines the element the controls should be listened from
  79675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79676. */
  79677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79678. /**
  79679. * Called on JS contextmenu event.
  79680. * Override this method to provide functionality.
  79681. */
  79682. protected onContextMenu(evt: PointerEvent): void;
  79683. /**
  79684. * Detach the current controls from the specified dom element.
  79685. * @param element Defines the element to stop listening the inputs from
  79686. */
  79687. detachControl(element: Nullable<HTMLElement>): void;
  79688. /**
  79689. * Gets the class name of the current intput.
  79690. * @returns the class name
  79691. */
  79692. getClassName(): string;
  79693. /**
  79694. * Get the friendly name associated with the input class.
  79695. * @returns the input friendly name
  79696. */
  79697. getSimpleName(): string;
  79698. }
  79699. }
  79700. declare module BABYLON {
  79701. /**
  79702. * Manage the touch inputs to control the movement of a free camera.
  79703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79704. */
  79705. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79706. /**
  79707. * Defines the camera the input is attached to.
  79708. */
  79709. camera: FreeCamera;
  79710. /**
  79711. * Defines the touch sensibility for rotation.
  79712. * The higher the faster.
  79713. */
  79714. touchAngularSensibility: number;
  79715. /**
  79716. * Defines the touch sensibility for move.
  79717. * The higher the faster.
  79718. */
  79719. touchMoveSensibility: number;
  79720. private _offsetX;
  79721. private _offsetY;
  79722. private _pointerPressed;
  79723. private _pointerInput;
  79724. private _observer;
  79725. private _onLostFocus;
  79726. /**
  79727. * Attach the input controls to a specific dom element to get the input from.
  79728. * @param element Defines the element the controls should be listened from
  79729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79730. */
  79731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79732. /**
  79733. * Detach the current controls from the specified dom element.
  79734. * @param element Defines the element to stop listening the inputs from
  79735. */
  79736. detachControl(element: Nullable<HTMLElement>): void;
  79737. /**
  79738. * Update the current camera state depending on the inputs that have been used this frame.
  79739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79740. */
  79741. checkInputs(): void;
  79742. /**
  79743. * Gets the class name of the current intput.
  79744. * @returns the class name
  79745. */
  79746. getClassName(): string;
  79747. /**
  79748. * Get the friendly name associated with the input class.
  79749. * @returns the input friendly name
  79750. */
  79751. getSimpleName(): string;
  79752. }
  79753. }
  79754. declare module BABYLON {
  79755. /**
  79756. * Default Inputs manager for the FreeCamera.
  79757. * It groups all the default supported inputs for ease of use.
  79758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79759. */
  79760. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79761. /**
  79762. * @hidden
  79763. */
  79764. _mouseInput: Nullable<FreeCameraMouseInput>;
  79765. /**
  79766. * Instantiates a new FreeCameraInputsManager.
  79767. * @param camera Defines the camera the inputs belong to
  79768. */
  79769. constructor(camera: FreeCamera);
  79770. /**
  79771. * Add keyboard input support to the input manager.
  79772. * @returns the current input manager
  79773. */
  79774. addKeyboard(): FreeCameraInputsManager;
  79775. /**
  79776. * Add mouse input support to the input manager.
  79777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79778. * @returns the current input manager
  79779. */
  79780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79781. /**
  79782. * Removes the mouse input support from the manager
  79783. * @returns the current input manager
  79784. */
  79785. removeMouse(): FreeCameraInputsManager;
  79786. /**
  79787. * Add touch input support to the input manager.
  79788. * @returns the current input manager
  79789. */
  79790. addTouch(): FreeCameraInputsManager;
  79791. /**
  79792. * Remove all attached input methods from a camera
  79793. */
  79794. clear(): void;
  79795. }
  79796. }
  79797. declare module BABYLON {
  79798. /**
  79799. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79800. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79802. */
  79803. export class FreeCamera extends TargetCamera {
  79804. /**
  79805. * Define the collision ellipsoid of the camera.
  79806. * This is helpful to simulate a camera body like the player body around the camera
  79807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79808. */
  79809. ellipsoid: Vector3;
  79810. /**
  79811. * Define an offset for the position of the ellipsoid around the camera.
  79812. * This can be helpful to determine the center of the body near the gravity center of the body
  79813. * instead of its head.
  79814. */
  79815. ellipsoidOffset: Vector3;
  79816. /**
  79817. * Enable or disable collisions of the camera with the rest of the scene objects.
  79818. */
  79819. checkCollisions: boolean;
  79820. /**
  79821. * Enable or disable gravity on the camera.
  79822. */
  79823. applyGravity: boolean;
  79824. /**
  79825. * Define the input manager associated to the camera.
  79826. */
  79827. inputs: FreeCameraInputsManager;
  79828. /**
  79829. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79830. * Higher values reduce sensitivity.
  79831. */
  79832. /**
  79833. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79834. * Higher values reduce sensitivity.
  79835. */
  79836. angularSensibility: number;
  79837. /**
  79838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79839. */
  79840. keysUp: number[];
  79841. /**
  79842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79843. */
  79844. keysDown: number[];
  79845. /**
  79846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79847. */
  79848. keysLeft: number[];
  79849. /**
  79850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79851. */
  79852. keysRight: number[];
  79853. /**
  79854. * Event raised when the camera collide with a mesh in the scene.
  79855. */
  79856. onCollide: (collidedMesh: AbstractMesh) => void;
  79857. private _collider;
  79858. private _needMoveForGravity;
  79859. private _oldPosition;
  79860. private _diffPosition;
  79861. private _newPosition;
  79862. /** @hidden */
  79863. _localDirection: Vector3;
  79864. /** @hidden */
  79865. _transformedDirection: Vector3;
  79866. /**
  79867. * Instantiates a Free Camera.
  79868. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79869. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79871. * @param name Define the name of the camera in the scene
  79872. * @param position Define the start position of the camera in the scene
  79873. * @param scene Define the scene the camera belongs to
  79874. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79875. */
  79876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79877. /**
  79878. * Attached controls to the current camera.
  79879. * @param element Defines the element the controls should be listened from
  79880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79881. */
  79882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79883. /**
  79884. * Detach the current controls from the camera.
  79885. * The camera will stop reacting to inputs.
  79886. * @param element Defines the element to stop listening the inputs from
  79887. */
  79888. detachControl(element: HTMLElement): void;
  79889. private _collisionMask;
  79890. /**
  79891. * Define a collision mask to limit the list of object the camera can collide with
  79892. */
  79893. collisionMask: number;
  79894. /** @hidden */
  79895. _collideWithWorld(displacement: Vector3): void;
  79896. private _onCollisionPositionChange;
  79897. /** @hidden */
  79898. _checkInputs(): void;
  79899. /** @hidden */
  79900. _decideIfNeedsToMove(): boolean;
  79901. /** @hidden */
  79902. _updatePosition(): void;
  79903. /**
  79904. * Destroy the camera and release the current resources hold by it.
  79905. */
  79906. dispose(): void;
  79907. /**
  79908. * Gets the current object class name.
  79909. * @return the class name
  79910. */
  79911. getClassName(): string;
  79912. }
  79913. }
  79914. declare module BABYLON {
  79915. /**
  79916. * Represents a gamepad control stick position
  79917. */
  79918. export class StickValues {
  79919. /**
  79920. * The x component of the control stick
  79921. */
  79922. x: number;
  79923. /**
  79924. * The y component of the control stick
  79925. */
  79926. y: number;
  79927. /**
  79928. * Initializes the gamepad x and y control stick values
  79929. * @param x The x component of the gamepad control stick value
  79930. * @param y The y component of the gamepad control stick value
  79931. */
  79932. constructor(
  79933. /**
  79934. * The x component of the control stick
  79935. */
  79936. x: number,
  79937. /**
  79938. * The y component of the control stick
  79939. */
  79940. y: number);
  79941. }
  79942. /**
  79943. * An interface which manages callbacks for gamepad button changes
  79944. */
  79945. export interface GamepadButtonChanges {
  79946. /**
  79947. * Called when a gamepad has been changed
  79948. */
  79949. changed: boolean;
  79950. /**
  79951. * Called when a gamepad press event has been triggered
  79952. */
  79953. pressChanged: boolean;
  79954. /**
  79955. * Called when a touch event has been triggered
  79956. */
  79957. touchChanged: boolean;
  79958. /**
  79959. * Called when a value has changed
  79960. */
  79961. valueChanged: boolean;
  79962. }
  79963. /**
  79964. * Represents a gamepad
  79965. */
  79966. export class Gamepad {
  79967. /**
  79968. * The id of the gamepad
  79969. */
  79970. id: string;
  79971. /**
  79972. * The index of the gamepad
  79973. */
  79974. index: number;
  79975. /**
  79976. * The browser gamepad
  79977. */
  79978. browserGamepad: any;
  79979. /**
  79980. * Specifies what type of gamepad this represents
  79981. */
  79982. type: number;
  79983. private _leftStick;
  79984. private _rightStick;
  79985. /** @hidden */
  79986. _isConnected: boolean;
  79987. private _leftStickAxisX;
  79988. private _leftStickAxisY;
  79989. private _rightStickAxisX;
  79990. private _rightStickAxisY;
  79991. /**
  79992. * Triggered when the left control stick has been changed
  79993. */
  79994. private _onleftstickchanged;
  79995. /**
  79996. * Triggered when the right control stick has been changed
  79997. */
  79998. private _onrightstickchanged;
  79999. /**
  80000. * Represents a gamepad controller
  80001. */
  80002. static GAMEPAD: number;
  80003. /**
  80004. * Represents a generic controller
  80005. */
  80006. static GENERIC: number;
  80007. /**
  80008. * Represents an XBox controller
  80009. */
  80010. static XBOX: number;
  80011. /**
  80012. * Represents a pose-enabled controller
  80013. */
  80014. static POSE_ENABLED: number;
  80015. /**
  80016. * Represents an Dual Shock controller
  80017. */
  80018. static DUALSHOCK: number;
  80019. /**
  80020. * Specifies whether the left control stick should be Y-inverted
  80021. */
  80022. protected _invertLeftStickY: boolean;
  80023. /**
  80024. * Specifies if the gamepad has been connected
  80025. */
  80026. readonly isConnected: boolean;
  80027. /**
  80028. * Initializes the gamepad
  80029. * @param id The id of the gamepad
  80030. * @param index The index of the gamepad
  80031. * @param browserGamepad The browser gamepad
  80032. * @param leftStickX The x component of the left joystick
  80033. * @param leftStickY The y component of the left joystick
  80034. * @param rightStickX The x component of the right joystick
  80035. * @param rightStickY The y component of the right joystick
  80036. */
  80037. constructor(
  80038. /**
  80039. * The id of the gamepad
  80040. */
  80041. id: string,
  80042. /**
  80043. * The index of the gamepad
  80044. */
  80045. index: number,
  80046. /**
  80047. * The browser gamepad
  80048. */
  80049. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80050. /**
  80051. * Callback triggered when the left joystick has changed
  80052. * @param callback
  80053. */
  80054. onleftstickchanged(callback: (values: StickValues) => void): void;
  80055. /**
  80056. * Callback triggered when the right joystick has changed
  80057. * @param callback
  80058. */
  80059. onrightstickchanged(callback: (values: StickValues) => void): void;
  80060. /**
  80061. * Gets the left joystick
  80062. */
  80063. /**
  80064. * Sets the left joystick values
  80065. */
  80066. leftStick: StickValues;
  80067. /**
  80068. * Gets the right joystick
  80069. */
  80070. /**
  80071. * Sets the right joystick value
  80072. */
  80073. rightStick: StickValues;
  80074. /**
  80075. * Updates the gamepad joystick positions
  80076. */
  80077. update(): void;
  80078. /**
  80079. * Disposes the gamepad
  80080. */
  80081. dispose(): void;
  80082. }
  80083. /**
  80084. * Represents a generic gamepad
  80085. */
  80086. export class GenericPad extends Gamepad {
  80087. private _buttons;
  80088. private _onbuttondown;
  80089. private _onbuttonup;
  80090. /**
  80091. * Observable triggered when a button has been pressed
  80092. */
  80093. onButtonDownObservable: Observable<number>;
  80094. /**
  80095. * Observable triggered when a button has been released
  80096. */
  80097. onButtonUpObservable: Observable<number>;
  80098. /**
  80099. * Callback triggered when a button has been pressed
  80100. * @param callback Called when a button has been pressed
  80101. */
  80102. onbuttondown(callback: (buttonPressed: number) => void): void;
  80103. /**
  80104. * Callback triggered when a button has been released
  80105. * @param callback Called when a button has been released
  80106. */
  80107. onbuttonup(callback: (buttonReleased: number) => void): void;
  80108. /**
  80109. * Initializes the generic gamepad
  80110. * @param id The id of the generic gamepad
  80111. * @param index The index of the generic gamepad
  80112. * @param browserGamepad The browser gamepad
  80113. */
  80114. constructor(id: string, index: number, browserGamepad: any);
  80115. private _setButtonValue;
  80116. /**
  80117. * Updates the generic gamepad
  80118. */
  80119. update(): void;
  80120. /**
  80121. * Disposes the generic gamepad
  80122. */
  80123. dispose(): void;
  80124. }
  80125. }
  80126. declare module BABYLON {
  80127. interface Engine {
  80128. /**
  80129. * Creates a raw texture
  80130. * @param data defines the data to store in the texture
  80131. * @param width defines the width of the texture
  80132. * @param height defines the height of the texture
  80133. * @param format defines the format of the data
  80134. * @param generateMipMaps defines if the engine should generate the mip levels
  80135. * @param invertY defines if data must be stored with Y axis inverted
  80136. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80137. * @param compression defines the compression used (null by default)
  80138. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80139. * @returns the raw texture inside an InternalTexture
  80140. */
  80141. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80142. /**
  80143. * Update a raw texture
  80144. * @param texture defines the texture to update
  80145. * @param data defines the data to store in the texture
  80146. * @param format defines the format of the data
  80147. * @param invertY defines if data must be stored with Y axis inverted
  80148. */
  80149. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80150. /**
  80151. * Update a raw texture
  80152. * @param texture defines the texture to update
  80153. * @param data defines the data to store in the texture
  80154. * @param format defines the format of the data
  80155. * @param invertY defines if data must be stored with Y axis inverted
  80156. * @param compression defines the compression used (null by default)
  80157. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80158. */
  80159. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80160. /**
  80161. * Creates a new raw cube texture
  80162. * @param data defines the array of data to use to create each face
  80163. * @param size defines the size of the textures
  80164. * @param format defines the format of the data
  80165. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80166. * @param generateMipMaps defines if the engine should generate the mip levels
  80167. * @param invertY defines if data must be stored with Y axis inverted
  80168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80169. * @param compression defines the compression used (null by default)
  80170. * @returns the cube texture as an InternalTexture
  80171. */
  80172. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80173. /**
  80174. * Update a raw cube texture
  80175. * @param texture defines the texture to udpdate
  80176. * @param data defines the data to store
  80177. * @param format defines the data format
  80178. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80179. * @param invertY defines if data must be stored with Y axis inverted
  80180. */
  80181. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80182. /**
  80183. * Update a raw cube texture
  80184. * @param texture defines the texture to udpdate
  80185. * @param data defines the data to store
  80186. * @param format defines the data format
  80187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80188. * @param invertY defines if data must be stored with Y axis inverted
  80189. * @param compression defines the compression used (null by default)
  80190. */
  80191. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80192. /**
  80193. * Update a raw cube texture
  80194. * @param texture defines the texture to udpdate
  80195. * @param data defines the data to store
  80196. * @param format defines the data format
  80197. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80198. * @param invertY defines if data must be stored with Y axis inverted
  80199. * @param compression defines the compression used (null by default)
  80200. * @param level defines which level of the texture to update
  80201. */
  80202. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80203. /**
  80204. * Creates a new raw cube texture from a specified url
  80205. * @param url defines the url where the data is located
  80206. * @param scene defines the current scene
  80207. * @param size defines the size of the textures
  80208. * @param format defines the format of the data
  80209. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80210. * @param noMipmap defines if the engine should avoid generating the mip levels
  80211. * @param callback defines a callback used to extract texture data from loaded data
  80212. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80213. * @param onLoad defines a callback called when texture is loaded
  80214. * @param onError defines a callback called if there is an error
  80215. * @returns the cube texture as an InternalTexture
  80216. */
  80217. 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;
  80218. /**
  80219. * Creates a new raw cube texture from a specified url
  80220. * @param url defines the url where the data is located
  80221. * @param scene defines the current scene
  80222. * @param size defines the size of the textures
  80223. * @param format defines the format of the data
  80224. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80225. * @param noMipmap defines if the engine should avoid generating the mip levels
  80226. * @param callback defines a callback used to extract texture data from loaded data
  80227. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80228. * @param onLoad defines a callback called when texture is loaded
  80229. * @param onError defines a callback called if there is an error
  80230. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80231. * @param invertY defines if data must be stored with Y axis inverted
  80232. * @returns the cube texture as an InternalTexture
  80233. */
  80234. 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;
  80235. /**
  80236. * Creates a new raw 3D texture
  80237. * @param data defines the data used to create the texture
  80238. * @param width defines the width of the texture
  80239. * @param height defines the height of the texture
  80240. * @param depth defines the depth of the texture
  80241. * @param format defines the format of the texture
  80242. * @param generateMipMaps defines if the engine must generate mip levels
  80243. * @param invertY defines if data must be stored with Y axis inverted
  80244. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80245. * @param compression defines the compressed used (can be null)
  80246. * @param textureType defines the compressed used (can be null)
  80247. * @returns a new raw 3D texture (stored in an InternalTexture)
  80248. */
  80249. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80250. /**
  80251. * Update a raw 3D texture
  80252. * @param texture defines the texture to update
  80253. * @param data defines the data to store
  80254. * @param format defines the data format
  80255. * @param invertY defines if data must be stored with Y axis inverted
  80256. */
  80257. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80258. /**
  80259. * Update a raw 3D texture
  80260. * @param texture defines the texture to update
  80261. * @param data defines the data to store
  80262. * @param format defines the data format
  80263. * @param invertY defines if data must be stored with Y axis inverted
  80264. * @param compression defines the used compression (can be null)
  80265. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80266. */
  80267. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80268. }
  80269. }
  80270. declare module BABYLON {
  80271. /**
  80272. * Raw texture can help creating a texture directly from an array of data.
  80273. * This can be super useful if you either get the data from an uncompressed source or
  80274. * if you wish to create your texture pixel by pixel.
  80275. */
  80276. export class RawTexture extends Texture {
  80277. /**
  80278. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80279. */
  80280. format: number;
  80281. private _engine;
  80282. /**
  80283. * Instantiates a new RawTexture.
  80284. * Raw texture can help creating a texture directly from an array of data.
  80285. * This can be super useful if you either get the data from an uncompressed source or
  80286. * if you wish to create your texture pixel by pixel.
  80287. * @param data define the array of data to use to create the texture
  80288. * @param width define the width of the texture
  80289. * @param height define the height of the texture
  80290. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80291. * @param scene define the scene the texture belongs to
  80292. * @param generateMipMaps define whether mip maps should be generated or not
  80293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80295. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80296. */
  80297. constructor(data: ArrayBufferView, width: number, height: number,
  80298. /**
  80299. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80300. */
  80301. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80302. /**
  80303. * Updates the texture underlying data.
  80304. * @param data Define the new data of the texture
  80305. */
  80306. update(data: ArrayBufferView): void;
  80307. /**
  80308. * Creates a luminance texture from some data.
  80309. * @param data Define the texture data
  80310. * @param width Define the width of the texture
  80311. * @param height Define the height of the texture
  80312. * @param scene Define the scene the texture belongs to
  80313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80316. * @returns the luminance texture
  80317. */
  80318. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80319. /**
  80320. * Creates a luminance alpha texture from some data.
  80321. * @param data Define the texture data
  80322. * @param width Define the width of the texture
  80323. * @param height Define the height of the texture
  80324. * @param scene Define the scene the texture belongs to
  80325. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80326. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80327. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80328. * @returns the luminance alpha texture
  80329. */
  80330. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80331. /**
  80332. * Creates an alpha texture from some data.
  80333. * @param data Define the texture data
  80334. * @param width Define the width of the texture
  80335. * @param height Define the height of the texture
  80336. * @param scene Define the scene the texture belongs to
  80337. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80338. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80339. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80340. * @returns the alpha texture
  80341. */
  80342. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80343. /**
  80344. * Creates a RGB texture from some data.
  80345. * @param data Define the texture data
  80346. * @param width Define the width of the texture
  80347. * @param height Define the height of the texture
  80348. * @param scene Define the scene the texture belongs to
  80349. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80350. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80351. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80352. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80353. * @returns the RGB alpha texture
  80354. */
  80355. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80356. /**
  80357. * Creates a RGBA texture from some data.
  80358. * @param data Define the texture data
  80359. * @param width Define the width of the texture
  80360. * @param height Define the height of the texture
  80361. * @param scene Define the scene the texture belongs to
  80362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80365. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80366. * @returns the RGBA texture
  80367. */
  80368. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80369. /**
  80370. * Creates a R texture from some data.
  80371. * @param data Define the texture data
  80372. * @param width Define the width of the texture
  80373. * @param height Define the height of the texture
  80374. * @param scene Define the scene the texture belongs to
  80375. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80376. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80377. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80378. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80379. * @returns the R texture
  80380. */
  80381. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80382. }
  80383. }
  80384. declare module BABYLON {
  80385. /**
  80386. * Interface for the size containing width and height
  80387. */
  80388. export interface ISize {
  80389. /**
  80390. * Width
  80391. */
  80392. width: number;
  80393. /**
  80394. * Heighht
  80395. */
  80396. height: number;
  80397. }
  80398. /**
  80399. * Size containing widht and height
  80400. */
  80401. export class Size implements ISize {
  80402. /**
  80403. * Width
  80404. */
  80405. width: number;
  80406. /**
  80407. * Height
  80408. */
  80409. height: number;
  80410. /**
  80411. * Creates a Size object from the given width and height (floats).
  80412. * @param width width of the new size
  80413. * @param height height of the new size
  80414. */
  80415. constructor(width: number, height: number);
  80416. /**
  80417. * Returns a string with the Size width and height
  80418. * @returns a string with the Size width and height
  80419. */
  80420. toString(): string;
  80421. /**
  80422. * "Size"
  80423. * @returns the string "Size"
  80424. */
  80425. getClassName(): string;
  80426. /**
  80427. * Returns the Size hash code.
  80428. * @returns a hash code for a unique width and height
  80429. */
  80430. getHashCode(): number;
  80431. /**
  80432. * Updates the current size from the given one.
  80433. * @param src the given size
  80434. */
  80435. copyFrom(src: Size): void;
  80436. /**
  80437. * Updates in place the current Size from the given floats.
  80438. * @param width width of the new size
  80439. * @param height height of the new size
  80440. * @returns the updated Size.
  80441. */
  80442. copyFromFloats(width: number, height: number): Size;
  80443. /**
  80444. * Updates in place the current Size from the given floats.
  80445. * @param width width to set
  80446. * @param height height to set
  80447. * @returns the updated Size.
  80448. */
  80449. set(width: number, height: number): Size;
  80450. /**
  80451. * Multiplies the width and height by numbers
  80452. * @param w factor to multiple the width by
  80453. * @param h factor to multiple the height by
  80454. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80455. */
  80456. multiplyByFloats(w: number, h: number): Size;
  80457. /**
  80458. * Clones the size
  80459. * @returns a new Size copied from the given one.
  80460. */
  80461. clone(): Size;
  80462. /**
  80463. * True if the current Size and the given one width and height are strictly equal.
  80464. * @param other the other size to compare against
  80465. * @returns True if the current Size and the given one width and height are strictly equal.
  80466. */
  80467. equals(other: Size): boolean;
  80468. /**
  80469. * The surface of the Size : width * height (float).
  80470. */
  80471. readonly surface: number;
  80472. /**
  80473. * Create a new size of zero
  80474. * @returns a new Size set to (0.0, 0.0)
  80475. */
  80476. static Zero(): Size;
  80477. /**
  80478. * Sums the width and height of two sizes
  80479. * @param otherSize size to add to this size
  80480. * @returns a new Size set as the addition result of the current Size and the given one.
  80481. */
  80482. add(otherSize: Size): Size;
  80483. /**
  80484. * Subtracts the width and height of two
  80485. * @param otherSize size to subtract to this size
  80486. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80487. */
  80488. subtract(otherSize: Size): Size;
  80489. /**
  80490. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80491. * @param start starting size to lerp between
  80492. * @param end end size to lerp between
  80493. * @param amount amount to lerp between the start and end values
  80494. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80495. */
  80496. static Lerp(start: Size, end: Size, amount: number): Size;
  80497. }
  80498. }
  80499. declare module BABYLON {
  80500. /**
  80501. * Defines a runtime animation
  80502. */
  80503. export class RuntimeAnimation {
  80504. private _events;
  80505. /**
  80506. * The current frame of the runtime animation
  80507. */
  80508. private _currentFrame;
  80509. /**
  80510. * The animation used by the runtime animation
  80511. */
  80512. private _animation;
  80513. /**
  80514. * The target of the runtime animation
  80515. */
  80516. private _target;
  80517. /**
  80518. * The initiating animatable
  80519. */
  80520. private _host;
  80521. /**
  80522. * The original value of the runtime animation
  80523. */
  80524. private _originalValue;
  80525. /**
  80526. * The original blend value of the runtime animation
  80527. */
  80528. private _originalBlendValue;
  80529. /**
  80530. * The offsets cache of the runtime animation
  80531. */
  80532. private _offsetsCache;
  80533. /**
  80534. * The high limits cache of the runtime animation
  80535. */
  80536. private _highLimitsCache;
  80537. /**
  80538. * Specifies if the runtime animation has been stopped
  80539. */
  80540. private _stopped;
  80541. /**
  80542. * The blending factor of the runtime animation
  80543. */
  80544. private _blendingFactor;
  80545. /**
  80546. * The BabylonJS scene
  80547. */
  80548. private _scene;
  80549. /**
  80550. * The current value of the runtime animation
  80551. */
  80552. private _currentValue;
  80553. /** @hidden */
  80554. _animationState: _IAnimationState;
  80555. /**
  80556. * The active target of the runtime animation
  80557. */
  80558. private _activeTargets;
  80559. private _currentActiveTarget;
  80560. private _directTarget;
  80561. /**
  80562. * The target path of the runtime animation
  80563. */
  80564. private _targetPath;
  80565. /**
  80566. * The weight of the runtime animation
  80567. */
  80568. private _weight;
  80569. /**
  80570. * The ratio offset of the runtime animation
  80571. */
  80572. private _ratioOffset;
  80573. /**
  80574. * The previous delay of the runtime animation
  80575. */
  80576. private _previousDelay;
  80577. /**
  80578. * The previous ratio of the runtime animation
  80579. */
  80580. private _previousRatio;
  80581. private _enableBlending;
  80582. private _keys;
  80583. private _minFrame;
  80584. private _maxFrame;
  80585. private _minValue;
  80586. private _maxValue;
  80587. private _targetIsArray;
  80588. /**
  80589. * Gets the current frame of the runtime animation
  80590. */
  80591. readonly currentFrame: number;
  80592. /**
  80593. * Gets the weight of the runtime animation
  80594. */
  80595. readonly weight: number;
  80596. /**
  80597. * Gets the current value of the runtime animation
  80598. */
  80599. readonly currentValue: any;
  80600. /**
  80601. * Gets the target path of the runtime animation
  80602. */
  80603. readonly targetPath: string;
  80604. /**
  80605. * Gets the actual target of the runtime animation
  80606. */
  80607. readonly target: any;
  80608. /** @hidden */
  80609. _onLoop: () => void;
  80610. /**
  80611. * Create a new RuntimeAnimation object
  80612. * @param target defines the target of the animation
  80613. * @param animation defines the source animation object
  80614. * @param scene defines the hosting scene
  80615. * @param host defines the initiating Animatable
  80616. */
  80617. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80618. private _preparePath;
  80619. /**
  80620. * Gets the animation from the runtime animation
  80621. */
  80622. readonly animation: Animation;
  80623. /**
  80624. * Resets the runtime animation to the beginning
  80625. * @param restoreOriginal defines whether to restore the target property to the original value
  80626. */
  80627. reset(restoreOriginal?: boolean): void;
  80628. /**
  80629. * Specifies if the runtime animation is stopped
  80630. * @returns Boolean specifying if the runtime animation is stopped
  80631. */
  80632. isStopped(): boolean;
  80633. /**
  80634. * Disposes of the runtime animation
  80635. */
  80636. dispose(): void;
  80637. /**
  80638. * Apply the interpolated value to the target
  80639. * @param currentValue defines the value computed by the animation
  80640. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80641. */
  80642. setValue(currentValue: any, weight: number): void;
  80643. private _getOriginalValues;
  80644. private _setValue;
  80645. /**
  80646. * Gets the loop pmode of the runtime animation
  80647. * @returns Loop Mode
  80648. */
  80649. private _getCorrectLoopMode;
  80650. /**
  80651. * Move the current animation to a given frame
  80652. * @param frame defines the frame to move to
  80653. */
  80654. goToFrame(frame: number): void;
  80655. /**
  80656. * @hidden Internal use only
  80657. */
  80658. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80659. /**
  80660. * Execute the current animation
  80661. * @param delay defines the delay to add to the current frame
  80662. * @param from defines the lower bound of the animation range
  80663. * @param to defines the upper bound of the animation range
  80664. * @param loop defines if the current animation must loop
  80665. * @param speedRatio defines the current speed ratio
  80666. * @param weight defines the weight of the animation (default is -1 so no weight)
  80667. * @param onLoop optional callback called when animation loops
  80668. * @returns a boolean indicating if the animation is running
  80669. */
  80670. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80671. }
  80672. }
  80673. declare module BABYLON {
  80674. /**
  80675. * Class used to store an actual running animation
  80676. */
  80677. export class Animatable {
  80678. /** defines the target object */
  80679. target: any;
  80680. /** defines the starting frame number (default is 0) */
  80681. fromFrame: number;
  80682. /** defines the ending frame number (default is 100) */
  80683. toFrame: number;
  80684. /** defines if the animation must loop (default is false) */
  80685. loopAnimation: boolean;
  80686. /** defines a callback to call when animation ends if it is not looping */
  80687. onAnimationEnd?: (() => void) | null | undefined;
  80688. /** defines a callback to call when animation loops */
  80689. onAnimationLoop?: (() => void) | null | undefined;
  80690. private _localDelayOffset;
  80691. private _pausedDelay;
  80692. private _runtimeAnimations;
  80693. private _paused;
  80694. private _scene;
  80695. private _speedRatio;
  80696. private _weight;
  80697. private _syncRoot;
  80698. /**
  80699. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80700. * This will only apply for non looping animation (default is true)
  80701. */
  80702. disposeOnEnd: boolean;
  80703. /**
  80704. * Gets a boolean indicating if the animation has started
  80705. */
  80706. animationStarted: boolean;
  80707. /**
  80708. * Observer raised when the animation ends
  80709. */
  80710. onAnimationEndObservable: Observable<Animatable>;
  80711. /**
  80712. * Observer raised when the animation loops
  80713. */
  80714. onAnimationLoopObservable: Observable<Animatable>;
  80715. /**
  80716. * Gets the root Animatable used to synchronize and normalize animations
  80717. */
  80718. readonly syncRoot: Nullable<Animatable>;
  80719. /**
  80720. * Gets the current frame of the first RuntimeAnimation
  80721. * Used to synchronize Animatables
  80722. */
  80723. readonly masterFrame: number;
  80724. /**
  80725. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80726. */
  80727. weight: number;
  80728. /**
  80729. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80730. */
  80731. speedRatio: number;
  80732. /**
  80733. * Creates a new Animatable
  80734. * @param scene defines the hosting scene
  80735. * @param target defines the target object
  80736. * @param fromFrame defines the starting frame number (default is 0)
  80737. * @param toFrame defines the ending frame number (default is 100)
  80738. * @param loopAnimation defines if the animation must loop (default is false)
  80739. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80740. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80741. * @param animations defines a group of animation to add to the new Animatable
  80742. * @param onAnimationLoop defines a callback to call when animation loops
  80743. */
  80744. constructor(scene: Scene,
  80745. /** defines the target object */
  80746. target: any,
  80747. /** defines the starting frame number (default is 0) */
  80748. fromFrame?: number,
  80749. /** defines the ending frame number (default is 100) */
  80750. toFrame?: number,
  80751. /** defines if the animation must loop (default is false) */
  80752. loopAnimation?: boolean, speedRatio?: number,
  80753. /** defines a callback to call when animation ends if it is not looping */
  80754. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80755. /** defines a callback to call when animation loops */
  80756. onAnimationLoop?: (() => void) | null | undefined);
  80757. /**
  80758. * Synchronize and normalize current Animatable with a source Animatable
  80759. * This is useful when using animation weights and when animations are not of the same length
  80760. * @param root defines the root Animatable to synchronize with
  80761. * @returns the current Animatable
  80762. */
  80763. syncWith(root: Animatable): Animatable;
  80764. /**
  80765. * Gets the list of runtime animations
  80766. * @returns an array of RuntimeAnimation
  80767. */
  80768. getAnimations(): RuntimeAnimation[];
  80769. /**
  80770. * Adds more animations to the current animatable
  80771. * @param target defines the target of the animations
  80772. * @param animations defines the new animations to add
  80773. */
  80774. appendAnimations(target: any, animations: Animation[]): void;
  80775. /**
  80776. * Gets the source animation for a specific property
  80777. * @param property defines the propertyu to look for
  80778. * @returns null or the source animation for the given property
  80779. */
  80780. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80781. /**
  80782. * Gets the runtime animation for a specific property
  80783. * @param property defines the propertyu to look for
  80784. * @returns null or the runtime animation for the given property
  80785. */
  80786. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80787. /**
  80788. * Resets the animatable to its original state
  80789. */
  80790. reset(): void;
  80791. /**
  80792. * Allows the animatable to blend with current running animations
  80793. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80794. * @param blendingSpeed defines the blending speed to use
  80795. */
  80796. enableBlending(blendingSpeed: number): void;
  80797. /**
  80798. * Disable animation blending
  80799. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80800. */
  80801. disableBlending(): void;
  80802. /**
  80803. * Jump directly to a given frame
  80804. * @param frame defines the frame to jump to
  80805. */
  80806. goToFrame(frame: number): void;
  80807. /**
  80808. * Pause the animation
  80809. */
  80810. pause(): void;
  80811. /**
  80812. * Restart the animation
  80813. */
  80814. restart(): void;
  80815. private _raiseOnAnimationEnd;
  80816. /**
  80817. * Stop and delete the current animation
  80818. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80819. * @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)
  80820. */
  80821. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80822. /**
  80823. * Wait asynchronously for the animation to end
  80824. * @returns a promise which will be fullfilled when the animation ends
  80825. */
  80826. waitAsync(): Promise<Animatable>;
  80827. /** @hidden */
  80828. _animate(delay: number): boolean;
  80829. }
  80830. interface Scene {
  80831. /** @hidden */
  80832. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80833. /** @hidden */
  80834. _processLateAnimationBindingsForMatrices(holder: {
  80835. totalWeight: number;
  80836. animations: RuntimeAnimation[];
  80837. originalValue: Matrix;
  80838. }): any;
  80839. /** @hidden */
  80840. _processLateAnimationBindingsForQuaternions(holder: {
  80841. totalWeight: number;
  80842. animations: RuntimeAnimation[];
  80843. originalValue: Quaternion;
  80844. }, refQuaternion: Quaternion): Quaternion;
  80845. /** @hidden */
  80846. _processLateAnimationBindings(): void;
  80847. /**
  80848. * Will start the animation sequence of a given target
  80849. * @param target defines the target
  80850. * @param from defines from which frame should animation start
  80851. * @param to defines until which frame should animation run.
  80852. * @param weight defines the weight to apply to the animation (1.0 by default)
  80853. * @param loop defines if the animation loops
  80854. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80855. * @param onAnimationEnd defines the function to be executed when the animation ends
  80856. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80857. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80858. * @param onAnimationLoop defines the callback to call when an animation loops
  80859. * @returns the animatable object created for this animation
  80860. */
  80861. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80862. /**
  80863. * Will start the animation sequence of a given target
  80864. * @param target defines the target
  80865. * @param from defines from which frame should animation start
  80866. * @param to defines until which frame should animation run.
  80867. * @param loop defines if the animation loops
  80868. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80869. * @param onAnimationEnd defines the function to be executed when the animation ends
  80870. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80871. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80872. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80873. * @param onAnimationLoop defines the callback to call when an animation loops
  80874. * @returns the animatable object created for this animation
  80875. */
  80876. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80877. /**
  80878. * Will start the animation sequence of a given target and its hierarchy
  80879. * @param target defines the target
  80880. * @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.
  80881. * @param from defines from which frame should animation start
  80882. * @param to defines until which frame should animation run.
  80883. * @param loop defines if the animation loops
  80884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80885. * @param onAnimationEnd defines the function to be executed when the animation ends
  80886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80887. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80888. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80889. * @param onAnimationLoop defines the callback to call when an animation loops
  80890. * @returns the list of created animatables
  80891. */
  80892. 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[];
  80893. /**
  80894. * Begin a new animation on a given node
  80895. * @param target defines the target where the animation will take place
  80896. * @param animations defines the list of animations to start
  80897. * @param from defines the initial value
  80898. * @param to defines the final value
  80899. * @param loop defines if you want animation to loop (off by default)
  80900. * @param speedRatio defines the speed ratio to apply to all animations
  80901. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80902. * @param onAnimationLoop defines the callback to call when an animation loops
  80903. * @returns the list of created animatables
  80904. */
  80905. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80906. /**
  80907. * Begin a new animation on a given node and its hierarchy
  80908. * @param target defines the root node where the animation will take place
  80909. * @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.
  80910. * @param animations defines the list of animations to start
  80911. * @param from defines the initial value
  80912. * @param to defines the final value
  80913. * @param loop defines if you want animation to loop (off by default)
  80914. * @param speedRatio defines the speed ratio to apply to all animations
  80915. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80916. * @param onAnimationLoop defines the callback to call when an animation loops
  80917. * @returns the list of animatables created for all nodes
  80918. */
  80919. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80920. /**
  80921. * Gets the animatable associated with a specific target
  80922. * @param target defines the target of the animatable
  80923. * @returns the required animatable if found
  80924. */
  80925. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80926. /**
  80927. * Gets all animatables associated with a given target
  80928. * @param target defines the target to look animatables for
  80929. * @returns an array of Animatables
  80930. */
  80931. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80932. /**
  80933. * Stops and removes all animations that have been applied to the scene
  80934. */
  80935. stopAllAnimations(): void;
  80936. /**
  80937. * Gets the current delta time used by animation engine
  80938. */
  80939. deltaTime: number;
  80940. }
  80941. interface Bone {
  80942. /**
  80943. * Copy an animation range from another bone
  80944. * @param source defines the source bone
  80945. * @param rangeName defines the range name to copy
  80946. * @param frameOffset defines the frame offset
  80947. * @param rescaleAsRequired defines if rescaling must be applied if required
  80948. * @param skelDimensionsRatio defines the scaling ratio
  80949. * @returns true if operation was successful
  80950. */
  80951. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80952. }
  80953. }
  80954. declare module BABYLON {
  80955. /**
  80956. * Class used to override all child animations of a given target
  80957. */
  80958. export class AnimationPropertiesOverride {
  80959. /**
  80960. * Gets or sets a value indicating if animation blending must be used
  80961. */
  80962. enableBlending: boolean;
  80963. /**
  80964. * Gets or sets the blending speed to use when enableBlending is true
  80965. */
  80966. blendingSpeed: number;
  80967. /**
  80968. * Gets or sets the default loop mode to use
  80969. */
  80970. loopMode: number;
  80971. }
  80972. }
  80973. declare module BABYLON {
  80974. /**
  80975. * Class used to handle skinning animations
  80976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80977. */
  80978. export class Skeleton implements IAnimatable {
  80979. /** defines the skeleton name */
  80980. name: string;
  80981. /** defines the skeleton Id */
  80982. id: string;
  80983. /**
  80984. * Defines the list of child bones
  80985. */
  80986. bones: Bone[];
  80987. /**
  80988. * Defines an estimate of the dimension of the skeleton at rest
  80989. */
  80990. dimensionsAtRest: Vector3;
  80991. /**
  80992. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80993. */
  80994. needInitialSkinMatrix: boolean;
  80995. /**
  80996. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80997. */
  80998. overrideMesh: Nullable<AbstractMesh>;
  80999. /**
  81000. * Gets the list of animations attached to this skeleton
  81001. */
  81002. animations: Array<Animation>;
  81003. private _scene;
  81004. private _isDirty;
  81005. private _transformMatrices;
  81006. private _transformMatrixTexture;
  81007. private _meshesWithPoseMatrix;
  81008. private _animatables;
  81009. private _identity;
  81010. private _synchronizedWithMesh;
  81011. private _ranges;
  81012. private _lastAbsoluteTransformsUpdateId;
  81013. private _canUseTextureForBones;
  81014. private _uniqueId;
  81015. /** @hidden */
  81016. _numBonesWithLinkedTransformNode: number;
  81017. /** @hidden */
  81018. _hasWaitingData: Nullable<boolean>;
  81019. /**
  81020. * Specifies if the skeleton should be serialized
  81021. */
  81022. doNotSerialize: boolean;
  81023. private _useTextureToStoreBoneMatrices;
  81024. /**
  81025. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81026. * Please note that this option is not available if the hardware does not support it
  81027. */
  81028. useTextureToStoreBoneMatrices: boolean;
  81029. private _animationPropertiesOverride;
  81030. /**
  81031. * Gets or sets the animation properties override
  81032. */
  81033. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81034. /**
  81035. * List of inspectable custom properties (used by the Inspector)
  81036. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81037. */
  81038. inspectableCustomProperties: IInspectable[];
  81039. /**
  81040. * An observable triggered before computing the skeleton's matrices
  81041. */
  81042. onBeforeComputeObservable: Observable<Skeleton>;
  81043. /**
  81044. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81045. */
  81046. readonly isUsingTextureForMatrices: boolean;
  81047. /**
  81048. * Gets the unique ID of this skeleton
  81049. */
  81050. readonly uniqueId: number;
  81051. /**
  81052. * Creates a new skeleton
  81053. * @param name defines the skeleton name
  81054. * @param id defines the skeleton Id
  81055. * @param scene defines the hosting scene
  81056. */
  81057. constructor(
  81058. /** defines the skeleton name */
  81059. name: string,
  81060. /** defines the skeleton Id */
  81061. id: string, scene: Scene);
  81062. /**
  81063. * Gets the current object class name.
  81064. * @return the class name
  81065. */
  81066. getClassName(): string;
  81067. /**
  81068. * Returns an array containing the root bones
  81069. * @returns an array containing the root bones
  81070. */
  81071. getChildren(): Array<Bone>;
  81072. /**
  81073. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81074. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81075. * @returns a Float32Array containing matrices data
  81076. */
  81077. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81078. /**
  81079. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81080. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81081. * @returns a raw texture containing the data
  81082. */
  81083. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81084. /**
  81085. * Gets the current hosting scene
  81086. * @returns a scene object
  81087. */
  81088. getScene(): Scene;
  81089. /**
  81090. * Gets a string representing the current skeleton data
  81091. * @param fullDetails defines a boolean indicating if we want a verbose version
  81092. * @returns a string representing the current skeleton data
  81093. */
  81094. toString(fullDetails?: boolean): string;
  81095. /**
  81096. * Get bone's index searching by name
  81097. * @param name defines bone's name to search for
  81098. * @return the indice of the bone. Returns -1 if not found
  81099. */
  81100. getBoneIndexByName(name: string): number;
  81101. /**
  81102. * Creater a new animation range
  81103. * @param name defines the name of the range
  81104. * @param from defines the start key
  81105. * @param to defines the end key
  81106. */
  81107. createAnimationRange(name: string, from: number, to: number): void;
  81108. /**
  81109. * Delete a specific animation range
  81110. * @param name defines the name of the range
  81111. * @param deleteFrames defines if frames must be removed as well
  81112. */
  81113. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81114. /**
  81115. * Gets a specific animation range
  81116. * @param name defines the name of the range to look for
  81117. * @returns the requested animation range or null if not found
  81118. */
  81119. getAnimationRange(name: string): Nullable<AnimationRange>;
  81120. /**
  81121. * Gets the list of all animation ranges defined on this skeleton
  81122. * @returns an array
  81123. */
  81124. getAnimationRanges(): Nullable<AnimationRange>[];
  81125. /**
  81126. * Copy animation range from a source skeleton.
  81127. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81128. * @param source defines the source skeleton
  81129. * @param name defines the name of the range to copy
  81130. * @param rescaleAsRequired defines if rescaling must be applied if required
  81131. * @returns true if operation was successful
  81132. */
  81133. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81134. /**
  81135. * Forces the skeleton to go to rest pose
  81136. */
  81137. returnToRest(): void;
  81138. private _getHighestAnimationFrame;
  81139. /**
  81140. * Begin a specific animation range
  81141. * @param name defines the name of the range to start
  81142. * @param loop defines if looping must be turned on (false by default)
  81143. * @param speedRatio defines the speed ratio to apply (1 by default)
  81144. * @param onAnimationEnd defines a callback which will be called when animation will end
  81145. * @returns a new animatable
  81146. */
  81147. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81148. /** @hidden */
  81149. _markAsDirty(): void;
  81150. /** @hidden */
  81151. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81152. /** @hidden */
  81153. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81154. private _computeTransformMatrices;
  81155. /**
  81156. * Build all resources required to render a skeleton
  81157. */
  81158. prepare(): void;
  81159. /**
  81160. * Gets the list of animatables currently running for this skeleton
  81161. * @returns an array of animatables
  81162. */
  81163. getAnimatables(): IAnimatable[];
  81164. /**
  81165. * Clone the current skeleton
  81166. * @param name defines the name of the new skeleton
  81167. * @param id defines the id of the new skeleton
  81168. * @returns the new skeleton
  81169. */
  81170. clone(name: string, id?: string): Skeleton;
  81171. /**
  81172. * Enable animation blending for this skeleton
  81173. * @param blendingSpeed defines the blending speed to apply
  81174. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81175. */
  81176. enableBlending(blendingSpeed?: number): void;
  81177. /**
  81178. * Releases all resources associated with the current skeleton
  81179. */
  81180. dispose(): void;
  81181. /**
  81182. * Serialize the skeleton in a JSON object
  81183. * @returns a JSON object
  81184. */
  81185. serialize(): any;
  81186. /**
  81187. * Creates a new skeleton from serialized data
  81188. * @param parsedSkeleton defines the serialized data
  81189. * @param scene defines the hosting scene
  81190. * @returns a new skeleton
  81191. */
  81192. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81193. /**
  81194. * Compute all node absolute transforms
  81195. * @param forceUpdate defines if computation must be done even if cache is up to date
  81196. */
  81197. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81198. /**
  81199. * Gets the root pose matrix
  81200. * @returns a matrix
  81201. */
  81202. getPoseMatrix(): Nullable<Matrix>;
  81203. /**
  81204. * Sorts bones per internal index
  81205. */
  81206. sortBones(): void;
  81207. private _sortBones;
  81208. }
  81209. }
  81210. declare module BABYLON {
  81211. /**
  81212. * Class used to store bone information
  81213. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81214. */
  81215. export class Bone extends Node {
  81216. /**
  81217. * defines the bone name
  81218. */
  81219. name: string;
  81220. private static _tmpVecs;
  81221. private static _tmpQuat;
  81222. private static _tmpMats;
  81223. /**
  81224. * Gets the list of child bones
  81225. */
  81226. children: Bone[];
  81227. /** Gets the animations associated with this bone */
  81228. animations: Animation[];
  81229. /**
  81230. * Gets or sets bone length
  81231. */
  81232. length: number;
  81233. /**
  81234. * @hidden Internal only
  81235. * Set this value to map this bone to a different index in the transform matrices
  81236. * Set this value to -1 to exclude the bone from the transform matrices
  81237. */
  81238. _index: Nullable<number>;
  81239. private _skeleton;
  81240. private _localMatrix;
  81241. private _restPose;
  81242. private _baseMatrix;
  81243. private _absoluteTransform;
  81244. private _invertedAbsoluteTransform;
  81245. private _parent;
  81246. private _scalingDeterminant;
  81247. private _worldTransform;
  81248. private _localScaling;
  81249. private _localRotation;
  81250. private _localPosition;
  81251. private _needToDecompose;
  81252. private _needToCompose;
  81253. /** @hidden */
  81254. _linkedTransformNode: Nullable<TransformNode>;
  81255. /** @hidden */
  81256. _waitingTransformNodeId: Nullable<string>;
  81257. /** @hidden */
  81258. /** @hidden */
  81259. _matrix: Matrix;
  81260. /**
  81261. * Create a new bone
  81262. * @param name defines the bone name
  81263. * @param skeleton defines the parent skeleton
  81264. * @param parentBone defines the parent (can be null if the bone is the root)
  81265. * @param localMatrix defines the local matrix
  81266. * @param restPose defines the rest pose matrix
  81267. * @param baseMatrix defines the base matrix
  81268. * @param index defines index of the bone in the hiearchy
  81269. */
  81270. constructor(
  81271. /**
  81272. * defines the bone name
  81273. */
  81274. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81275. /**
  81276. * Gets the current object class name.
  81277. * @return the class name
  81278. */
  81279. getClassName(): string;
  81280. /**
  81281. * Gets the parent skeleton
  81282. * @returns a skeleton
  81283. */
  81284. getSkeleton(): Skeleton;
  81285. /**
  81286. * Gets parent bone
  81287. * @returns a bone or null if the bone is the root of the bone hierarchy
  81288. */
  81289. getParent(): Nullable<Bone>;
  81290. /**
  81291. * Returns an array containing the root bones
  81292. * @returns an array containing the root bones
  81293. */
  81294. getChildren(): Array<Bone>;
  81295. /**
  81296. * Gets the node index in matrix array generated for rendering
  81297. * @returns the node index
  81298. */
  81299. getIndex(): number;
  81300. /**
  81301. * Sets the parent bone
  81302. * @param parent defines the parent (can be null if the bone is the root)
  81303. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81304. */
  81305. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81306. /**
  81307. * Gets the local matrix
  81308. * @returns a matrix
  81309. */
  81310. getLocalMatrix(): Matrix;
  81311. /**
  81312. * Gets the base matrix (initial matrix which remains unchanged)
  81313. * @returns a matrix
  81314. */
  81315. getBaseMatrix(): Matrix;
  81316. /**
  81317. * Gets the rest pose matrix
  81318. * @returns a matrix
  81319. */
  81320. getRestPose(): Matrix;
  81321. /**
  81322. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81323. */
  81324. getWorldMatrix(): Matrix;
  81325. /**
  81326. * Sets the local matrix to rest pose matrix
  81327. */
  81328. returnToRest(): void;
  81329. /**
  81330. * Gets the inverse of the absolute transform matrix.
  81331. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81332. * @returns a matrix
  81333. */
  81334. getInvertedAbsoluteTransform(): Matrix;
  81335. /**
  81336. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81337. * @returns a matrix
  81338. */
  81339. getAbsoluteTransform(): Matrix;
  81340. /**
  81341. * Links with the given transform node.
  81342. * The local matrix of this bone is copied from the transform node every frame.
  81343. * @param transformNode defines the transform node to link to
  81344. */
  81345. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81346. /**
  81347. * Gets the node used to drive the bone's transformation
  81348. * @returns a transform node or null
  81349. */
  81350. getTransformNode(): Nullable<TransformNode>;
  81351. /** Gets or sets current position (in local space) */
  81352. position: Vector3;
  81353. /** Gets or sets current rotation (in local space) */
  81354. rotation: Vector3;
  81355. /** Gets or sets current rotation quaternion (in local space) */
  81356. rotationQuaternion: Quaternion;
  81357. /** Gets or sets current scaling (in local space) */
  81358. scaling: Vector3;
  81359. /**
  81360. * Gets the animation properties override
  81361. */
  81362. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81363. private _decompose;
  81364. private _compose;
  81365. /**
  81366. * Update the base and local matrices
  81367. * @param matrix defines the new base or local matrix
  81368. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81369. * @param updateLocalMatrix defines if the local matrix should be updated
  81370. */
  81371. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81372. /** @hidden */
  81373. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81374. /**
  81375. * Flag the bone as dirty (Forcing it to update everything)
  81376. */
  81377. markAsDirty(): void;
  81378. /** @hidden */
  81379. _markAsDirtyAndCompose(): void;
  81380. private _markAsDirtyAndDecompose;
  81381. /**
  81382. * Translate the bone in local or world space
  81383. * @param vec The amount to translate the bone
  81384. * @param space The space that the translation is in
  81385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81386. */
  81387. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81388. /**
  81389. * Set the postion of the bone in local or world space
  81390. * @param position The position to set the bone
  81391. * @param space The space that the position is in
  81392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81393. */
  81394. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81395. /**
  81396. * Set the absolute position of the bone (world space)
  81397. * @param position The position to set the bone
  81398. * @param mesh The mesh that this bone is attached to
  81399. */
  81400. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81401. /**
  81402. * Scale the bone on the x, y and z axes (in local space)
  81403. * @param x The amount to scale the bone on the x axis
  81404. * @param y The amount to scale the bone on the y axis
  81405. * @param z The amount to scale the bone on the z axis
  81406. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81407. */
  81408. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81409. /**
  81410. * Set the bone scaling in local space
  81411. * @param scale defines the scaling vector
  81412. */
  81413. setScale(scale: Vector3): void;
  81414. /**
  81415. * Gets the current scaling in local space
  81416. * @returns the current scaling vector
  81417. */
  81418. getScale(): Vector3;
  81419. /**
  81420. * Gets the current scaling in local space and stores it in a target vector
  81421. * @param result defines the target vector
  81422. */
  81423. getScaleToRef(result: Vector3): void;
  81424. /**
  81425. * Set the yaw, pitch, and roll of the bone in local or world space
  81426. * @param yaw The rotation of the bone on the y axis
  81427. * @param pitch The rotation of the bone on the x axis
  81428. * @param roll The rotation of the bone on the z axis
  81429. * @param space The space that the axes of rotation are in
  81430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81431. */
  81432. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81433. /**
  81434. * Add a rotation to the bone on an axis in local or world space
  81435. * @param axis The axis to rotate the bone on
  81436. * @param amount The amount to rotate the bone
  81437. * @param space The space that the axis is in
  81438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81439. */
  81440. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81441. /**
  81442. * Set the rotation of the bone to a particular axis angle in local or world space
  81443. * @param axis The axis to rotate the bone on
  81444. * @param angle The angle that the bone should be rotated to
  81445. * @param space The space that the axis is in
  81446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81447. */
  81448. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81449. /**
  81450. * Set the euler rotation of the bone in local of world space
  81451. * @param rotation The euler rotation that the bone should be set to
  81452. * @param space The space that the rotation is in
  81453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81454. */
  81455. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81456. /**
  81457. * Set the quaternion rotation of the bone in local of world space
  81458. * @param quat The quaternion rotation that the bone should be set to
  81459. * @param space The space that the rotation is in
  81460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81461. */
  81462. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81463. /**
  81464. * Set the rotation matrix of the bone in local of world space
  81465. * @param rotMat The rotation matrix that the bone should be set to
  81466. * @param space The space that the rotation is in
  81467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81468. */
  81469. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81470. private _rotateWithMatrix;
  81471. private _getNegativeRotationToRef;
  81472. /**
  81473. * Get the position of the bone in local or world space
  81474. * @param space The space that the returned position is in
  81475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81476. * @returns The position of the bone
  81477. */
  81478. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81479. /**
  81480. * Copy the position of the bone to a vector3 in local or world space
  81481. * @param space The space that the returned position is in
  81482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81483. * @param result The vector3 to copy the position to
  81484. */
  81485. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81486. /**
  81487. * Get the absolute position of the bone (world space)
  81488. * @param mesh The mesh that this bone is attached to
  81489. * @returns The absolute position of the bone
  81490. */
  81491. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81492. /**
  81493. * Copy the absolute position of the bone (world space) to the result param
  81494. * @param mesh The mesh that this bone is attached to
  81495. * @param result The vector3 to copy the absolute position to
  81496. */
  81497. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81498. /**
  81499. * Compute the absolute transforms of this bone and its children
  81500. */
  81501. computeAbsoluteTransforms(): void;
  81502. /**
  81503. * Get the world direction from an axis that is in the local space of the bone
  81504. * @param localAxis The local direction that is used to compute the world direction
  81505. * @param mesh The mesh that this bone is attached to
  81506. * @returns The world direction
  81507. */
  81508. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81509. /**
  81510. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81511. * @param localAxis The local direction that is used to compute the world direction
  81512. * @param mesh The mesh that this bone is attached to
  81513. * @param result The vector3 that the world direction will be copied to
  81514. */
  81515. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81516. /**
  81517. * Get the euler rotation of the bone in local or world space
  81518. * @param space The space that the rotation should be in
  81519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81520. * @returns The euler rotation
  81521. */
  81522. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81523. /**
  81524. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81525. * @param space The space that the rotation should be in
  81526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81527. * @param result The vector3 that the rotation should be copied to
  81528. */
  81529. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81530. /**
  81531. * Get the quaternion rotation of the bone in either local or world space
  81532. * @param space The space that the rotation should be in
  81533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81534. * @returns The quaternion rotation
  81535. */
  81536. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81537. /**
  81538. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81539. * @param space The space that the rotation should be in
  81540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81541. * @param result The quaternion that the rotation should be copied to
  81542. */
  81543. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81544. /**
  81545. * Get the rotation matrix of the bone in local or world space
  81546. * @param space The space that the rotation should be in
  81547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81548. * @returns The rotation matrix
  81549. */
  81550. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81551. /**
  81552. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81553. * @param space The space that the rotation should be in
  81554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81555. * @param result The quaternion that the rotation should be copied to
  81556. */
  81557. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81558. /**
  81559. * Get the world position of a point that is in the local space of the bone
  81560. * @param position The local position
  81561. * @param mesh The mesh that this bone is attached to
  81562. * @returns The world position
  81563. */
  81564. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81565. /**
  81566. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81567. * @param position The local position
  81568. * @param mesh The mesh that this bone is attached to
  81569. * @param result The vector3 that the world position should be copied to
  81570. */
  81571. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81572. /**
  81573. * Get the local position of a point that is in world space
  81574. * @param position The world position
  81575. * @param mesh The mesh that this bone is attached to
  81576. * @returns The local position
  81577. */
  81578. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81579. /**
  81580. * Get the local position of a point that is in world space and copy it to the result param
  81581. * @param position The world position
  81582. * @param mesh The mesh that this bone is attached to
  81583. * @param result The vector3 that the local position should be copied to
  81584. */
  81585. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81586. }
  81587. }
  81588. declare module BABYLON {
  81589. /**
  81590. * 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.
  81591. * @see https://doc.babylonjs.com/how_to/transformnode
  81592. */
  81593. export class TransformNode extends Node {
  81594. /**
  81595. * Object will not rotate to face the camera
  81596. */
  81597. static BILLBOARDMODE_NONE: number;
  81598. /**
  81599. * Object will rotate to face the camera but only on the x axis
  81600. */
  81601. static BILLBOARDMODE_X: number;
  81602. /**
  81603. * Object will rotate to face the camera but only on the y axis
  81604. */
  81605. static BILLBOARDMODE_Y: number;
  81606. /**
  81607. * Object will rotate to face the camera but only on the z axis
  81608. */
  81609. static BILLBOARDMODE_Z: number;
  81610. /**
  81611. * Object will rotate to face the camera
  81612. */
  81613. static BILLBOARDMODE_ALL: number;
  81614. /**
  81615. * Object will rotate to face the camera's position instead of orientation
  81616. */
  81617. static BILLBOARDMODE_USE_POSITION: number;
  81618. private _forward;
  81619. private _forwardInverted;
  81620. private _up;
  81621. private _right;
  81622. private _rightInverted;
  81623. private _position;
  81624. private _rotation;
  81625. private _rotationQuaternion;
  81626. protected _scaling: Vector3;
  81627. protected _isDirty: boolean;
  81628. private _transformToBoneReferal;
  81629. private _isAbsoluteSynced;
  81630. private _billboardMode;
  81631. /**
  81632. * Gets or sets the billboard mode. Default is 0.
  81633. *
  81634. * | Value | Type | Description |
  81635. * | --- | --- | --- |
  81636. * | 0 | BILLBOARDMODE_NONE | |
  81637. * | 1 | BILLBOARDMODE_X | |
  81638. * | 2 | BILLBOARDMODE_Y | |
  81639. * | 4 | BILLBOARDMODE_Z | |
  81640. * | 7 | BILLBOARDMODE_ALL | |
  81641. *
  81642. */
  81643. billboardMode: number;
  81644. private _preserveParentRotationForBillboard;
  81645. /**
  81646. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81647. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81648. */
  81649. preserveParentRotationForBillboard: boolean;
  81650. /**
  81651. * 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
  81652. */
  81653. scalingDeterminant: number;
  81654. private _infiniteDistance;
  81655. /**
  81656. * Gets or sets the distance of the object to max, often used by skybox
  81657. */
  81658. infiniteDistance: boolean;
  81659. /**
  81660. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81661. * By default the system will update normals to compensate
  81662. */
  81663. ignoreNonUniformScaling: boolean;
  81664. /**
  81665. * 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
  81666. */
  81667. reIntegrateRotationIntoRotationQuaternion: boolean;
  81668. /** @hidden */
  81669. _poseMatrix: Nullable<Matrix>;
  81670. /** @hidden */
  81671. _localMatrix: Matrix;
  81672. private _usePivotMatrix;
  81673. private _absolutePosition;
  81674. private _absoluteScaling;
  81675. private _absoluteRotationQuaternion;
  81676. private _pivotMatrix;
  81677. private _pivotMatrixInverse;
  81678. protected _postMultiplyPivotMatrix: boolean;
  81679. protected _isWorldMatrixFrozen: boolean;
  81680. /** @hidden */
  81681. _indexInSceneTransformNodesArray: number;
  81682. /**
  81683. * An event triggered after the world matrix is updated
  81684. */
  81685. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81686. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81687. /**
  81688. * Gets a string identifying the name of the class
  81689. * @returns "TransformNode" string
  81690. */
  81691. getClassName(): string;
  81692. /**
  81693. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81694. */
  81695. position: Vector3;
  81696. /**
  81697. * 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)).
  81698. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81699. */
  81700. rotation: Vector3;
  81701. /**
  81702. * 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)).
  81703. */
  81704. scaling: Vector3;
  81705. /**
  81706. * 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).
  81707. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81708. */
  81709. rotationQuaternion: Nullable<Quaternion>;
  81710. /**
  81711. * The forward direction of that transform in world space.
  81712. */
  81713. readonly forward: Vector3;
  81714. /**
  81715. * The up direction of that transform in world space.
  81716. */
  81717. readonly up: Vector3;
  81718. /**
  81719. * The right direction of that transform in world space.
  81720. */
  81721. readonly right: Vector3;
  81722. /**
  81723. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81724. * @param matrix the matrix to copy the pose from
  81725. * @returns this TransformNode.
  81726. */
  81727. updatePoseMatrix(matrix: Matrix): TransformNode;
  81728. /**
  81729. * Returns the mesh Pose matrix.
  81730. * @returns the pose matrix
  81731. */
  81732. getPoseMatrix(): Matrix;
  81733. /** @hidden */
  81734. _isSynchronized(): boolean;
  81735. /** @hidden */
  81736. _initCache(): void;
  81737. /**
  81738. * Flag the transform node as dirty (Forcing it to update everything)
  81739. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81740. * @returns this transform node
  81741. */
  81742. markAsDirty(property: string): TransformNode;
  81743. /**
  81744. * Returns the current mesh absolute position.
  81745. * Returns a Vector3.
  81746. */
  81747. readonly absolutePosition: Vector3;
  81748. /**
  81749. * Returns the current mesh absolute scaling.
  81750. * Returns a Vector3.
  81751. */
  81752. readonly absoluteScaling: Vector3;
  81753. /**
  81754. * Returns the current mesh absolute rotation.
  81755. * Returns a Quaternion.
  81756. */
  81757. readonly absoluteRotationQuaternion: Quaternion;
  81758. /**
  81759. * Sets a new matrix to apply before all other transformation
  81760. * @param matrix defines the transform matrix
  81761. * @returns the current TransformNode
  81762. */
  81763. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81764. /**
  81765. * Sets a new pivot matrix to the current node
  81766. * @param matrix defines the new pivot matrix to use
  81767. * @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
  81768. * @returns the current TransformNode
  81769. */
  81770. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81771. /**
  81772. * Returns the mesh pivot matrix.
  81773. * Default : Identity.
  81774. * @returns the matrix
  81775. */
  81776. getPivotMatrix(): Matrix;
  81777. /**
  81778. * Instantiate (when possible) or clone that node with its hierarchy
  81779. * @param newParent defines the new parent to use for the instance (or clone)
  81780. * @param options defines options to configure how copy is done
  81781. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  81782. * @returns an instance (or a clone) of the current node with its hiearchy
  81783. */
  81784. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  81785. doNotInstantiate: boolean;
  81786. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  81787. /**
  81788. * Prevents the World matrix to be computed any longer
  81789. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81790. * @returns the TransformNode.
  81791. */
  81792. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81793. /**
  81794. * Allows back the World matrix computation.
  81795. * @returns the TransformNode.
  81796. */
  81797. unfreezeWorldMatrix(): this;
  81798. /**
  81799. * True if the World matrix has been frozen.
  81800. */
  81801. readonly isWorldMatrixFrozen: boolean;
  81802. /**
  81803. * Retuns the mesh absolute position in the World.
  81804. * @returns a Vector3.
  81805. */
  81806. getAbsolutePosition(): Vector3;
  81807. /**
  81808. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81809. * @param absolutePosition the absolute position to set
  81810. * @returns the TransformNode.
  81811. */
  81812. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81813. /**
  81814. * Sets the mesh position in its local space.
  81815. * @param vector3 the position to set in localspace
  81816. * @returns the TransformNode.
  81817. */
  81818. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81819. /**
  81820. * Returns the mesh position in the local space from the current World matrix values.
  81821. * @returns a new Vector3.
  81822. */
  81823. getPositionExpressedInLocalSpace(): Vector3;
  81824. /**
  81825. * Translates the mesh along the passed Vector3 in its local space.
  81826. * @param vector3 the distance to translate in localspace
  81827. * @returns the TransformNode.
  81828. */
  81829. locallyTranslate(vector3: Vector3): TransformNode;
  81830. private static _lookAtVectorCache;
  81831. /**
  81832. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81833. * @param targetPoint the position (must be in same space as current mesh) to look at
  81834. * @param yawCor optional yaw (y-axis) correction in radians
  81835. * @param pitchCor optional pitch (x-axis) correction in radians
  81836. * @param rollCor optional roll (z-axis) correction in radians
  81837. * @param space the choosen space of the target
  81838. * @returns the TransformNode.
  81839. */
  81840. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81841. /**
  81842. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81843. * This Vector3 is expressed in the World space.
  81844. * @param localAxis axis to rotate
  81845. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81846. */
  81847. getDirection(localAxis: Vector3): Vector3;
  81848. /**
  81849. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81850. * localAxis is expressed in the mesh local space.
  81851. * result is computed in the Wordl space from the mesh World matrix.
  81852. * @param localAxis axis to rotate
  81853. * @param result the resulting transformnode
  81854. * @returns this TransformNode.
  81855. */
  81856. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81857. /**
  81858. * Sets this transform node rotation to the given local axis.
  81859. * @param localAxis the axis in local space
  81860. * @param yawCor optional yaw (y-axis) correction in radians
  81861. * @param pitchCor optional pitch (x-axis) correction in radians
  81862. * @param rollCor optional roll (z-axis) correction in radians
  81863. * @returns this TransformNode
  81864. */
  81865. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81866. /**
  81867. * Sets a new pivot point to the current node
  81868. * @param point defines the new pivot point to use
  81869. * @param space defines if the point is in world or local space (local by default)
  81870. * @returns the current TransformNode
  81871. */
  81872. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81873. /**
  81874. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81875. * @returns the pivot point
  81876. */
  81877. getPivotPoint(): Vector3;
  81878. /**
  81879. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81880. * @param result the vector3 to store the result
  81881. * @returns this TransformNode.
  81882. */
  81883. getPivotPointToRef(result: Vector3): TransformNode;
  81884. /**
  81885. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81886. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81887. */
  81888. getAbsolutePivotPoint(): Vector3;
  81889. /**
  81890. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81891. * @param result vector3 to store the result
  81892. * @returns this TransformNode.
  81893. */
  81894. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81895. /**
  81896. * Defines the passed node as the parent of the current node.
  81897. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81898. * @see https://doc.babylonjs.com/how_to/parenting
  81899. * @param node the node ot set as the parent
  81900. * @returns this TransformNode.
  81901. */
  81902. setParent(node: Nullable<Node>): TransformNode;
  81903. private _nonUniformScaling;
  81904. /**
  81905. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81906. */
  81907. readonly nonUniformScaling: boolean;
  81908. /** @hidden */
  81909. _updateNonUniformScalingState(value: boolean): boolean;
  81910. /**
  81911. * Attach the current TransformNode to another TransformNode associated with a bone
  81912. * @param bone Bone affecting the TransformNode
  81913. * @param affectedTransformNode TransformNode associated with the bone
  81914. * @returns this object
  81915. */
  81916. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81917. /**
  81918. * Detach the transform node if its associated with a bone
  81919. * @returns this object
  81920. */
  81921. detachFromBone(): TransformNode;
  81922. private static _rotationAxisCache;
  81923. /**
  81924. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81925. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81926. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81927. * The passed axis is also normalized.
  81928. * @param axis the axis to rotate around
  81929. * @param amount the amount to rotate in radians
  81930. * @param space Space to rotate in (Default: local)
  81931. * @returns the TransformNode.
  81932. */
  81933. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81934. /**
  81935. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81936. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81937. * The passed axis is also normalized. .
  81938. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81939. * @param point the point to rotate around
  81940. * @param axis the axis to rotate around
  81941. * @param amount the amount to rotate in radians
  81942. * @returns the TransformNode
  81943. */
  81944. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81945. /**
  81946. * Translates the mesh along the axis vector for the passed distance in the given space.
  81947. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81948. * @param axis the axis to translate in
  81949. * @param distance the distance to translate
  81950. * @param space Space to rotate in (Default: local)
  81951. * @returns the TransformNode.
  81952. */
  81953. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81954. /**
  81955. * Adds a rotation step to the mesh current rotation.
  81956. * x, y, z are Euler angles expressed in radians.
  81957. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81958. * This means this rotation is made in the mesh local space only.
  81959. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81960. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81961. * ```javascript
  81962. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81963. * ```
  81964. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81965. * 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.
  81966. * @param x Rotation to add
  81967. * @param y Rotation to add
  81968. * @param z Rotation to add
  81969. * @returns the TransformNode.
  81970. */
  81971. addRotation(x: number, y: number, z: number): TransformNode;
  81972. /**
  81973. * @hidden
  81974. */
  81975. protected _getEffectiveParent(): Nullable<Node>;
  81976. /**
  81977. * Computes the world matrix of the node
  81978. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81979. * @returns the world matrix
  81980. */
  81981. computeWorldMatrix(force?: boolean): Matrix;
  81982. protected _afterComputeWorldMatrix(): void;
  81983. /**
  81984. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81985. * @param func callback function to add
  81986. *
  81987. * @returns the TransformNode.
  81988. */
  81989. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81990. /**
  81991. * Removes a registered callback function.
  81992. * @param func callback function to remove
  81993. * @returns the TransformNode.
  81994. */
  81995. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81996. /**
  81997. * Gets the position of the current mesh in camera space
  81998. * @param camera defines the camera to use
  81999. * @returns a position
  82000. */
  82001. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82002. /**
  82003. * Returns the distance from the mesh to the active camera
  82004. * @param camera defines the camera to use
  82005. * @returns the distance
  82006. */
  82007. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82008. /**
  82009. * Clone the current transform node
  82010. * @param name Name of the new clone
  82011. * @param newParent New parent for the clone
  82012. * @param doNotCloneChildren Do not clone children hierarchy
  82013. * @returns the new transform node
  82014. */
  82015. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82016. /**
  82017. * Serializes the objects information.
  82018. * @param currentSerializationObject defines the object to serialize in
  82019. * @returns the serialized object
  82020. */
  82021. serialize(currentSerializationObject?: any): any;
  82022. /**
  82023. * Returns a new TransformNode object parsed from the source provided.
  82024. * @param parsedTransformNode is the source.
  82025. * @param scene the scne the object belongs to
  82026. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82027. * @returns a new TransformNode object parsed from the source provided.
  82028. */
  82029. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82030. /**
  82031. * Get all child-transformNodes of this node
  82032. * @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
  82033. * @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
  82034. * @returns an array of TransformNode
  82035. */
  82036. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82037. /**
  82038. * Releases resources associated with this transform node.
  82039. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82040. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82041. */
  82042. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82043. /**
  82044. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82045. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82046. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82047. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82048. * @returns the current mesh
  82049. */
  82050. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82051. private _syncAbsoluteScalingAndRotation;
  82052. }
  82053. }
  82054. declare module BABYLON {
  82055. /**
  82056. * Defines the types of pose enabled controllers that are supported
  82057. */
  82058. export enum PoseEnabledControllerType {
  82059. /**
  82060. * HTC Vive
  82061. */
  82062. VIVE = 0,
  82063. /**
  82064. * Oculus Rift
  82065. */
  82066. OCULUS = 1,
  82067. /**
  82068. * Windows mixed reality
  82069. */
  82070. WINDOWS = 2,
  82071. /**
  82072. * Samsung gear VR
  82073. */
  82074. GEAR_VR = 3,
  82075. /**
  82076. * Google Daydream
  82077. */
  82078. DAYDREAM = 4,
  82079. /**
  82080. * Generic
  82081. */
  82082. GENERIC = 5
  82083. }
  82084. /**
  82085. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82086. */
  82087. export interface MutableGamepadButton {
  82088. /**
  82089. * Value of the button/trigger
  82090. */
  82091. value: number;
  82092. /**
  82093. * If the button/trigger is currently touched
  82094. */
  82095. touched: boolean;
  82096. /**
  82097. * If the button/trigger is currently pressed
  82098. */
  82099. pressed: boolean;
  82100. }
  82101. /**
  82102. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82103. * @hidden
  82104. */
  82105. export interface ExtendedGamepadButton extends GamepadButton {
  82106. /**
  82107. * If the button/trigger is currently pressed
  82108. */
  82109. readonly pressed: boolean;
  82110. /**
  82111. * If the button/trigger is currently touched
  82112. */
  82113. readonly touched: boolean;
  82114. /**
  82115. * Value of the button/trigger
  82116. */
  82117. readonly value: number;
  82118. }
  82119. /** @hidden */
  82120. export interface _GamePadFactory {
  82121. /**
  82122. * Returns wether or not the current gamepad can be created for this type of controller.
  82123. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82124. * @returns true if it can be created, otherwise false
  82125. */
  82126. canCreate(gamepadInfo: any): boolean;
  82127. /**
  82128. * Creates a new instance of the Gamepad.
  82129. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82130. * @returns the new gamepad instance
  82131. */
  82132. create(gamepadInfo: any): Gamepad;
  82133. }
  82134. /**
  82135. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82136. */
  82137. export class PoseEnabledControllerHelper {
  82138. /** @hidden */
  82139. static _ControllerFactories: _GamePadFactory[];
  82140. /** @hidden */
  82141. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82142. /**
  82143. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82144. * @param vrGamepad the gamepad to initialized
  82145. * @returns a vr controller of the type the gamepad identified as
  82146. */
  82147. static InitiateController(vrGamepad: any): Gamepad;
  82148. }
  82149. /**
  82150. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82151. */
  82152. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82153. /**
  82154. * If the controller is used in a webXR session
  82155. */
  82156. isXR: boolean;
  82157. private _deviceRoomPosition;
  82158. private _deviceRoomRotationQuaternion;
  82159. /**
  82160. * The device position in babylon space
  82161. */
  82162. devicePosition: Vector3;
  82163. /**
  82164. * The device rotation in babylon space
  82165. */
  82166. deviceRotationQuaternion: Quaternion;
  82167. /**
  82168. * The scale factor of the device in babylon space
  82169. */
  82170. deviceScaleFactor: number;
  82171. /**
  82172. * (Likely devicePosition should be used instead) The device position in its room space
  82173. */
  82174. position: Vector3;
  82175. /**
  82176. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82177. */
  82178. rotationQuaternion: Quaternion;
  82179. /**
  82180. * The type of controller (Eg. Windows mixed reality)
  82181. */
  82182. controllerType: PoseEnabledControllerType;
  82183. protected _calculatedPosition: Vector3;
  82184. private _calculatedRotation;
  82185. /**
  82186. * The raw pose from the device
  82187. */
  82188. rawPose: DevicePose;
  82189. private _trackPosition;
  82190. private _maxRotationDistFromHeadset;
  82191. private _draggedRoomRotation;
  82192. /**
  82193. * @hidden
  82194. */
  82195. _disableTrackPosition(fixedPosition: Vector3): void;
  82196. /**
  82197. * Internal, the mesh attached to the controller
  82198. * @hidden
  82199. */
  82200. _mesh: Nullable<AbstractMesh>;
  82201. private _poseControlledCamera;
  82202. private _leftHandSystemQuaternion;
  82203. /**
  82204. * Internal, matrix used to convert room space to babylon space
  82205. * @hidden
  82206. */
  82207. _deviceToWorld: Matrix;
  82208. /**
  82209. * Node to be used when casting a ray from the controller
  82210. * @hidden
  82211. */
  82212. _pointingPoseNode: Nullable<TransformNode>;
  82213. /**
  82214. * Name of the child mesh that can be used to cast a ray from the controller
  82215. */
  82216. static readonly POINTING_POSE: string;
  82217. /**
  82218. * Creates a new PoseEnabledController from a gamepad
  82219. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82220. */
  82221. constructor(browserGamepad: any);
  82222. private _workingMatrix;
  82223. /**
  82224. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82225. */
  82226. update(): void;
  82227. /**
  82228. * Updates only the pose device and mesh without doing any button event checking
  82229. */
  82230. protected _updatePoseAndMesh(): void;
  82231. /**
  82232. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82233. * @param poseData raw pose fromthe device
  82234. */
  82235. updateFromDevice(poseData: DevicePose): void;
  82236. /**
  82237. * @hidden
  82238. */
  82239. _meshAttachedObservable: Observable<AbstractMesh>;
  82240. /**
  82241. * Attaches a mesh to the controller
  82242. * @param mesh the mesh to be attached
  82243. */
  82244. attachToMesh(mesh: AbstractMesh): void;
  82245. /**
  82246. * Attaches the controllers mesh to a camera
  82247. * @param camera the camera the mesh should be attached to
  82248. */
  82249. attachToPoseControlledCamera(camera: TargetCamera): void;
  82250. /**
  82251. * Disposes of the controller
  82252. */
  82253. dispose(): void;
  82254. /**
  82255. * The mesh that is attached to the controller
  82256. */
  82257. readonly mesh: Nullable<AbstractMesh>;
  82258. /**
  82259. * Gets the ray of the controller in the direction the controller is pointing
  82260. * @param length the length the resulting ray should be
  82261. * @returns a ray in the direction the controller is pointing
  82262. */
  82263. getForwardRay(length?: number): Ray;
  82264. }
  82265. }
  82266. declare module BABYLON {
  82267. /**
  82268. * Defines the WebVRController object that represents controllers tracked in 3D space
  82269. */
  82270. export abstract class WebVRController extends PoseEnabledController {
  82271. /**
  82272. * Internal, the default controller model for the controller
  82273. */
  82274. protected _defaultModel: Nullable<AbstractMesh>;
  82275. /**
  82276. * Fired when the trigger state has changed
  82277. */
  82278. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82279. /**
  82280. * Fired when the main button state has changed
  82281. */
  82282. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82283. /**
  82284. * Fired when the secondary button state has changed
  82285. */
  82286. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82287. /**
  82288. * Fired when the pad state has changed
  82289. */
  82290. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82291. /**
  82292. * Fired when controllers stick values have changed
  82293. */
  82294. onPadValuesChangedObservable: Observable<StickValues>;
  82295. /**
  82296. * Array of button availible on the controller
  82297. */
  82298. protected _buttons: Array<MutableGamepadButton>;
  82299. private _onButtonStateChange;
  82300. /**
  82301. * Fired when a controller button's state has changed
  82302. * @param callback the callback containing the button that was modified
  82303. */
  82304. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82305. /**
  82306. * X and Y axis corresponding to the controllers joystick
  82307. */
  82308. pad: StickValues;
  82309. /**
  82310. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82311. */
  82312. hand: string;
  82313. /**
  82314. * The default controller model for the controller
  82315. */
  82316. readonly defaultModel: Nullable<AbstractMesh>;
  82317. /**
  82318. * Creates a new WebVRController from a gamepad
  82319. * @param vrGamepad the gamepad that the WebVRController should be created from
  82320. */
  82321. constructor(vrGamepad: any);
  82322. /**
  82323. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82324. */
  82325. update(): void;
  82326. /**
  82327. * Function to be called when a button is modified
  82328. */
  82329. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82330. /**
  82331. * Loads a mesh and attaches it to the controller
  82332. * @param scene the scene the mesh should be added to
  82333. * @param meshLoaded callback for when the mesh has been loaded
  82334. */
  82335. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82336. private _setButtonValue;
  82337. private _changes;
  82338. private _checkChanges;
  82339. /**
  82340. * Disposes of th webVRCOntroller
  82341. */
  82342. dispose(): void;
  82343. }
  82344. }
  82345. declare module BABYLON {
  82346. /**
  82347. * The HemisphericLight simulates the ambient environment light,
  82348. * so the passed direction is the light reflection direction, not the incoming direction.
  82349. */
  82350. export class HemisphericLight extends Light {
  82351. /**
  82352. * The groundColor is the light in the opposite direction to the one specified during creation.
  82353. * 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.
  82354. */
  82355. groundColor: Color3;
  82356. /**
  82357. * The light reflection direction, not the incoming direction.
  82358. */
  82359. direction: Vector3;
  82360. /**
  82361. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82362. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82363. * The HemisphericLight can't cast shadows.
  82364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82365. * @param name The friendly name of the light
  82366. * @param direction The direction of the light reflection
  82367. * @param scene The scene the light belongs to
  82368. */
  82369. constructor(name: string, direction: Vector3, scene: Scene);
  82370. protected _buildUniformLayout(): void;
  82371. /**
  82372. * Returns the string "HemisphericLight".
  82373. * @return The class name
  82374. */
  82375. getClassName(): string;
  82376. /**
  82377. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82378. * Returns the updated direction.
  82379. * @param target The target the direction should point to
  82380. * @return The computed direction
  82381. */
  82382. setDirectionToTarget(target: Vector3): Vector3;
  82383. /**
  82384. * Returns the shadow generator associated to the light.
  82385. * @returns Always null for hemispheric lights because it does not support shadows.
  82386. */
  82387. getShadowGenerator(): Nullable<IShadowGenerator>;
  82388. /**
  82389. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82390. * @param effect The effect to update
  82391. * @param lightIndex The index of the light in the effect to update
  82392. * @returns The hemispheric light
  82393. */
  82394. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82395. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82396. /**
  82397. * Computes the world matrix of the node
  82398. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82399. * @param useWasUpdatedFlag defines a reserved property
  82400. * @returns the world matrix
  82401. */
  82402. computeWorldMatrix(): Matrix;
  82403. /**
  82404. * Returns the integer 3.
  82405. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82406. */
  82407. getTypeID(): number;
  82408. /**
  82409. * Prepares the list of defines specific to the light type.
  82410. * @param defines the list of defines
  82411. * @param lightIndex defines the index of the light for the effect
  82412. */
  82413. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82414. }
  82415. }
  82416. declare module BABYLON {
  82417. /** @hidden */
  82418. export var vrMultiviewToSingleviewPixelShader: {
  82419. name: string;
  82420. shader: string;
  82421. };
  82422. }
  82423. declare module BABYLON {
  82424. /**
  82425. * Renders to multiple views with a single draw call
  82426. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82427. */
  82428. export class MultiviewRenderTarget extends RenderTargetTexture {
  82429. /**
  82430. * Creates a multiview render target
  82431. * @param scene scene used with the render target
  82432. * @param size the size of the render target (used for each view)
  82433. */
  82434. constructor(scene: Scene, size?: number | {
  82435. width: number;
  82436. height: number;
  82437. } | {
  82438. ratio: number;
  82439. });
  82440. /**
  82441. * @hidden
  82442. * @param faceIndex the face index, if its a cube texture
  82443. */
  82444. _bindFrameBuffer(faceIndex?: number): void;
  82445. /**
  82446. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82447. * @returns the view count
  82448. */
  82449. getViewCount(): number;
  82450. }
  82451. }
  82452. declare module BABYLON {
  82453. /**
  82454. * Represents a camera frustum
  82455. */
  82456. export class Frustum {
  82457. /**
  82458. * Gets the planes representing the frustum
  82459. * @param transform matrix to be applied to the returned planes
  82460. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82461. */
  82462. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82463. /**
  82464. * Gets the near frustum plane transformed by the transform matrix
  82465. * @param transform transformation matrix to be applied to the resulting frustum plane
  82466. * @param frustumPlane the resuling frustum plane
  82467. */
  82468. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82469. /**
  82470. * Gets the far frustum plane transformed by the transform matrix
  82471. * @param transform transformation matrix to be applied to the resulting frustum plane
  82472. * @param frustumPlane the resuling frustum plane
  82473. */
  82474. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82475. /**
  82476. * Gets the left frustum plane transformed by the transform matrix
  82477. * @param transform transformation matrix to be applied to the resulting frustum plane
  82478. * @param frustumPlane the resuling frustum plane
  82479. */
  82480. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82481. /**
  82482. * Gets the right frustum plane transformed by the transform matrix
  82483. * @param transform transformation matrix to be applied to the resulting frustum plane
  82484. * @param frustumPlane the resuling frustum plane
  82485. */
  82486. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82487. /**
  82488. * Gets the top frustum plane transformed by the transform matrix
  82489. * @param transform transformation matrix to be applied to the resulting frustum plane
  82490. * @param frustumPlane the resuling frustum plane
  82491. */
  82492. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82493. /**
  82494. * Gets the bottom frustum plane transformed by the transform matrix
  82495. * @param transform transformation matrix to be applied to the resulting frustum plane
  82496. * @param frustumPlane the resuling frustum plane
  82497. */
  82498. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82499. /**
  82500. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82501. * @param transform transformation matrix to be applied to the resulting frustum planes
  82502. * @param frustumPlanes the resuling frustum planes
  82503. */
  82504. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82505. }
  82506. }
  82507. declare module BABYLON {
  82508. interface Engine {
  82509. /**
  82510. * Creates a new multiview render target
  82511. * @param width defines the width of the texture
  82512. * @param height defines the height of the texture
  82513. * @returns the created multiview texture
  82514. */
  82515. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82516. /**
  82517. * Binds a multiview framebuffer to be drawn to
  82518. * @param multiviewTexture texture to bind
  82519. */
  82520. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82521. }
  82522. interface Camera {
  82523. /**
  82524. * @hidden
  82525. * 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)
  82526. */
  82527. _useMultiviewToSingleView: boolean;
  82528. /**
  82529. * @hidden
  82530. * 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)
  82531. */
  82532. _multiviewTexture: Nullable<RenderTargetTexture>;
  82533. /**
  82534. * @hidden
  82535. * ensures the multiview texture of the camera exists and has the specified width/height
  82536. * @param width height to set on the multiview texture
  82537. * @param height width to set on the multiview texture
  82538. */
  82539. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82540. }
  82541. interface Scene {
  82542. /** @hidden */
  82543. _transformMatrixR: Matrix;
  82544. /** @hidden */
  82545. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82546. /** @hidden */
  82547. _createMultiviewUbo(): void;
  82548. /** @hidden */
  82549. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82550. /** @hidden */
  82551. _renderMultiviewToSingleView(camera: Camera): void;
  82552. }
  82553. }
  82554. declare module BABYLON {
  82555. /**
  82556. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82557. * This will not be used for webXR as it supports displaying texture arrays directly
  82558. */
  82559. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82560. /**
  82561. * Initializes a VRMultiviewToSingleview
  82562. * @param name name of the post process
  82563. * @param camera camera to be applied to
  82564. * @param scaleFactor scaling factor to the size of the output texture
  82565. */
  82566. constructor(name: string, camera: Camera, scaleFactor: number);
  82567. }
  82568. }
  82569. declare module BABYLON {
  82570. /**
  82571. * Interface used to define additional presentation attributes
  82572. */
  82573. export interface IVRPresentationAttributes {
  82574. /**
  82575. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82576. */
  82577. highRefreshRate: boolean;
  82578. /**
  82579. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82580. */
  82581. foveationLevel: number;
  82582. }
  82583. interface Engine {
  82584. /** @hidden */
  82585. _vrDisplay: any;
  82586. /** @hidden */
  82587. _vrSupported: boolean;
  82588. /** @hidden */
  82589. _oldSize: Size;
  82590. /** @hidden */
  82591. _oldHardwareScaleFactor: number;
  82592. /** @hidden */
  82593. _vrExclusivePointerMode: boolean;
  82594. /** @hidden */
  82595. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82596. /** @hidden */
  82597. _onVRDisplayPointerRestricted: () => void;
  82598. /** @hidden */
  82599. _onVRDisplayPointerUnrestricted: () => void;
  82600. /** @hidden */
  82601. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82602. /** @hidden */
  82603. _onVrDisplayDisconnect: Nullable<() => void>;
  82604. /** @hidden */
  82605. _onVrDisplayPresentChange: Nullable<() => void>;
  82606. /**
  82607. * Observable signaled when VR display mode changes
  82608. */
  82609. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82610. /**
  82611. * Observable signaled when VR request present is complete
  82612. */
  82613. onVRRequestPresentComplete: Observable<boolean>;
  82614. /**
  82615. * Observable signaled when VR request present starts
  82616. */
  82617. onVRRequestPresentStart: Observable<Engine>;
  82618. /**
  82619. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82620. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82621. */
  82622. isInVRExclusivePointerMode: boolean;
  82623. /**
  82624. * Gets a boolean indicating if a webVR device was detected
  82625. * @returns true if a webVR device was detected
  82626. */
  82627. isVRDevicePresent(): boolean;
  82628. /**
  82629. * Gets the current webVR device
  82630. * @returns the current webVR device (or null)
  82631. */
  82632. getVRDevice(): any;
  82633. /**
  82634. * Initializes a webVR display and starts listening to display change events
  82635. * The onVRDisplayChangedObservable will be notified upon these changes
  82636. * @returns A promise containing a VRDisplay and if vr is supported
  82637. */
  82638. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82639. /** @hidden */
  82640. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82641. /**
  82642. * Gets or sets the presentation attributes used to configure VR rendering
  82643. */
  82644. vrPresentationAttributes?: IVRPresentationAttributes;
  82645. /**
  82646. * Call this function to switch to webVR mode
  82647. * Will do nothing if webVR is not supported or if there is no webVR device
  82648. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82649. */
  82650. enableVR(): void;
  82651. /** @hidden */
  82652. _onVRFullScreenTriggered(): void;
  82653. }
  82654. }
  82655. declare module BABYLON {
  82656. /**
  82657. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82658. * IMPORTANT!! The data is right-hand data.
  82659. * @export
  82660. * @interface DevicePose
  82661. */
  82662. export interface DevicePose {
  82663. /**
  82664. * The position of the device, values in array are [x,y,z].
  82665. */
  82666. readonly position: Nullable<Float32Array>;
  82667. /**
  82668. * The linearVelocity of the device, values in array are [x,y,z].
  82669. */
  82670. readonly linearVelocity: Nullable<Float32Array>;
  82671. /**
  82672. * The linearAcceleration of the device, values in array are [x,y,z].
  82673. */
  82674. readonly linearAcceleration: Nullable<Float32Array>;
  82675. /**
  82676. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82677. */
  82678. readonly orientation: Nullable<Float32Array>;
  82679. /**
  82680. * The angularVelocity of the device, values in array are [x,y,z].
  82681. */
  82682. readonly angularVelocity: Nullable<Float32Array>;
  82683. /**
  82684. * The angularAcceleration of the device, values in array are [x,y,z].
  82685. */
  82686. readonly angularAcceleration: Nullable<Float32Array>;
  82687. }
  82688. /**
  82689. * Interface representing a pose controlled object in Babylon.
  82690. * A pose controlled object has both regular pose values as well as pose values
  82691. * from an external device such as a VR head mounted display
  82692. */
  82693. export interface PoseControlled {
  82694. /**
  82695. * The position of the object in babylon space.
  82696. */
  82697. position: Vector3;
  82698. /**
  82699. * The rotation quaternion of the object in babylon space.
  82700. */
  82701. rotationQuaternion: Quaternion;
  82702. /**
  82703. * The position of the device in babylon space.
  82704. */
  82705. devicePosition?: Vector3;
  82706. /**
  82707. * The rotation quaternion of the device in babylon space.
  82708. */
  82709. deviceRotationQuaternion: Quaternion;
  82710. /**
  82711. * The raw pose coming from the device.
  82712. */
  82713. rawPose: Nullable<DevicePose>;
  82714. /**
  82715. * The scale of the device to be used when translating from device space to babylon space.
  82716. */
  82717. deviceScaleFactor: number;
  82718. /**
  82719. * Updates the poseControlled values based on the input device pose.
  82720. * @param poseData the pose data to update the object with
  82721. */
  82722. updateFromDevice(poseData: DevicePose): void;
  82723. }
  82724. /**
  82725. * Set of options to customize the webVRCamera
  82726. */
  82727. export interface WebVROptions {
  82728. /**
  82729. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82730. */
  82731. trackPosition?: boolean;
  82732. /**
  82733. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82734. */
  82735. positionScale?: number;
  82736. /**
  82737. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82738. */
  82739. displayName?: string;
  82740. /**
  82741. * Should the native controller meshes be initialized. (default: true)
  82742. */
  82743. controllerMeshes?: boolean;
  82744. /**
  82745. * Creating a default HemiLight only on controllers. (default: true)
  82746. */
  82747. defaultLightingOnControllers?: boolean;
  82748. /**
  82749. * If you don't want to use the default VR button of the helper. (default: false)
  82750. */
  82751. useCustomVRButton?: boolean;
  82752. /**
  82753. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82754. */
  82755. customVRButton?: HTMLButtonElement;
  82756. /**
  82757. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82758. */
  82759. rayLength?: number;
  82760. /**
  82761. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82762. */
  82763. defaultHeight?: number;
  82764. /**
  82765. * If multiview should be used if availible (default: false)
  82766. */
  82767. useMultiview?: boolean;
  82768. }
  82769. /**
  82770. * This represents a WebVR camera.
  82771. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82772. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82773. */
  82774. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82775. private webVROptions;
  82776. /**
  82777. * @hidden
  82778. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82779. */
  82780. _vrDevice: any;
  82781. /**
  82782. * The rawPose of the vrDevice.
  82783. */
  82784. rawPose: Nullable<DevicePose>;
  82785. private _onVREnabled;
  82786. private _specsVersion;
  82787. private _attached;
  82788. private _frameData;
  82789. protected _descendants: Array<Node>;
  82790. private _deviceRoomPosition;
  82791. /** @hidden */
  82792. _deviceRoomRotationQuaternion: Quaternion;
  82793. private _standingMatrix;
  82794. /**
  82795. * Represents device position in babylon space.
  82796. */
  82797. devicePosition: Vector3;
  82798. /**
  82799. * Represents device rotation in babylon space.
  82800. */
  82801. deviceRotationQuaternion: Quaternion;
  82802. /**
  82803. * The scale of the device to be used when translating from device space to babylon space.
  82804. */
  82805. deviceScaleFactor: number;
  82806. private _deviceToWorld;
  82807. private _worldToDevice;
  82808. /**
  82809. * References to the webVR controllers for the vrDevice.
  82810. */
  82811. controllers: Array<WebVRController>;
  82812. /**
  82813. * Emits an event when a controller is attached.
  82814. */
  82815. onControllersAttachedObservable: Observable<WebVRController[]>;
  82816. /**
  82817. * Emits an event when a controller's mesh has been loaded;
  82818. */
  82819. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82820. /**
  82821. * Emits an event when the HMD's pose has been updated.
  82822. */
  82823. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82824. private _poseSet;
  82825. /**
  82826. * If the rig cameras be used as parent instead of this camera.
  82827. */
  82828. rigParenting: boolean;
  82829. private _lightOnControllers;
  82830. private _defaultHeight?;
  82831. /**
  82832. * Instantiates a WebVRFreeCamera.
  82833. * @param name The name of the WebVRFreeCamera
  82834. * @param position The starting anchor position for the camera
  82835. * @param scene The scene the camera belongs to
  82836. * @param webVROptions a set of customizable options for the webVRCamera
  82837. */
  82838. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82839. /**
  82840. * Gets the device distance from the ground in meters.
  82841. * @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.
  82842. */
  82843. deviceDistanceToRoomGround(): number;
  82844. /**
  82845. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82846. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82847. */
  82848. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82849. /**
  82850. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82851. * @returns A promise with a boolean set to if the standing matrix is supported.
  82852. */
  82853. useStandingMatrixAsync(): Promise<boolean>;
  82854. /**
  82855. * Disposes the camera
  82856. */
  82857. dispose(): void;
  82858. /**
  82859. * Gets a vrController by name.
  82860. * @param name The name of the controller to retreive
  82861. * @returns the controller matching the name specified or null if not found
  82862. */
  82863. getControllerByName(name: string): Nullable<WebVRController>;
  82864. private _leftController;
  82865. /**
  82866. * The controller corresponding to the users left hand.
  82867. */
  82868. readonly leftController: Nullable<WebVRController>;
  82869. private _rightController;
  82870. /**
  82871. * The controller corresponding to the users right hand.
  82872. */
  82873. readonly rightController: Nullable<WebVRController>;
  82874. /**
  82875. * Casts a ray forward from the vrCamera's gaze.
  82876. * @param length Length of the ray (default: 100)
  82877. * @returns the ray corresponding to the gaze
  82878. */
  82879. getForwardRay(length?: number): Ray;
  82880. /**
  82881. * @hidden
  82882. * Updates the camera based on device's frame data
  82883. */
  82884. _checkInputs(): void;
  82885. /**
  82886. * Updates the poseControlled values based on the input device pose.
  82887. * @param poseData Pose coming from the device
  82888. */
  82889. updateFromDevice(poseData: DevicePose): void;
  82890. private _htmlElementAttached;
  82891. private _detachIfAttached;
  82892. /**
  82893. * WebVR's attach control will start broadcasting frames to the device.
  82894. * Note that in certain browsers (chrome for example) this function must be called
  82895. * within a user-interaction callback. Example:
  82896. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82897. *
  82898. * @param element html element to attach the vrDevice to
  82899. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82900. */
  82901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82902. /**
  82903. * Detaches the camera from the html element and disables VR
  82904. *
  82905. * @param element html element to detach from
  82906. */
  82907. detachControl(element: HTMLElement): void;
  82908. /**
  82909. * @returns the name of this class
  82910. */
  82911. getClassName(): string;
  82912. /**
  82913. * Calls resetPose on the vrDisplay
  82914. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82915. */
  82916. resetToCurrentRotation(): void;
  82917. /**
  82918. * @hidden
  82919. * Updates the rig cameras (left and right eye)
  82920. */
  82921. _updateRigCameras(): void;
  82922. private _workingVector;
  82923. private _oneVector;
  82924. private _workingMatrix;
  82925. private updateCacheCalled;
  82926. private _correctPositionIfNotTrackPosition;
  82927. /**
  82928. * @hidden
  82929. * Updates the cached values of the camera
  82930. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82931. */
  82932. _updateCache(ignoreParentClass?: boolean): void;
  82933. /**
  82934. * @hidden
  82935. * Get current device position in babylon world
  82936. */
  82937. _computeDevicePosition(): void;
  82938. /**
  82939. * Updates the current device position and rotation in the babylon world
  82940. */
  82941. update(): void;
  82942. /**
  82943. * @hidden
  82944. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82945. * @returns an identity matrix
  82946. */
  82947. _getViewMatrix(): Matrix;
  82948. private _tmpMatrix;
  82949. /**
  82950. * This function is called by the two RIG cameras.
  82951. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82952. * @hidden
  82953. */
  82954. _getWebVRViewMatrix(): Matrix;
  82955. /** @hidden */
  82956. _getWebVRProjectionMatrix(): Matrix;
  82957. private _onGamepadConnectedObserver;
  82958. private _onGamepadDisconnectedObserver;
  82959. private _updateCacheWhenTrackingDisabledObserver;
  82960. /**
  82961. * Initializes the controllers and their meshes
  82962. */
  82963. initControllers(): void;
  82964. }
  82965. }
  82966. declare module BABYLON {
  82967. /**
  82968. * Size options for a post process
  82969. */
  82970. export type PostProcessOptions = {
  82971. width: number;
  82972. height: number;
  82973. };
  82974. /**
  82975. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82976. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82977. */
  82978. export class PostProcess {
  82979. /** Name of the PostProcess. */
  82980. name: string;
  82981. /**
  82982. * Gets or sets the unique id of the post process
  82983. */
  82984. uniqueId: number;
  82985. /**
  82986. * Width of the texture to apply the post process on
  82987. */
  82988. width: number;
  82989. /**
  82990. * Height of the texture to apply the post process on
  82991. */
  82992. height: number;
  82993. /**
  82994. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82995. * @hidden
  82996. */
  82997. _outputTexture: Nullable<InternalTexture>;
  82998. /**
  82999. * Sampling mode used by the shader
  83000. * See https://doc.babylonjs.com/classes/3.1/texture
  83001. */
  83002. renderTargetSamplingMode: number;
  83003. /**
  83004. * Clear color to use when screen clearing
  83005. */
  83006. clearColor: Color4;
  83007. /**
  83008. * If the buffer needs to be cleared before applying the post process. (default: true)
  83009. * Should be set to false if shader will overwrite all previous pixels.
  83010. */
  83011. autoClear: boolean;
  83012. /**
  83013. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83014. */
  83015. alphaMode: number;
  83016. /**
  83017. * Sets the setAlphaBlendConstants of the babylon engine
  83018. */
  83019. alphaConstants: Color4;
  83020. /**
  83021. * Animations to be used for the post processing
  83022. */
  83023. animations: Animation[];
  83024. /**
  83025. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83026. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83027. */
  83028. enablePixelPerfectMode: boolean;
  83029. /**
  83030. * Force the postprocess to be applied without taking in account viewport
  83031. */
  83032. forceFullscreenViewport: boolean;
  83033. /**
  83034. * List of inspectable custom properties (used by the Inspector)
  83035. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83036. */
  83037. inspectableCustomProperties: IInspectable[];
  83038. /**
  83039. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83040. *
  83041. * | Value | Type | Description |
  83042. * | ----- | ----------------------------------- | ----------- |
  83043. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83044. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83045. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83046. *
  83047. */
  83048. scaleMode: number;
  83049. /**
  83050. * Force textures to be a power of two (default: false)
  83051. */
  83052. alwaysForcePOT: boolean;
  83053. private _samples;
  83054. /**
  83055. * Number of sample textures (default: 1)
  83056. */
  83057. samples: number;
  83058. /**
  83059. * Modify the scale of the post process to be the same as the viewport (default: false)
  83060. */
  83061. adaptScaleToCurrentViewport: boolean;
  83062. private _camera;
  83063. private _scene;
  83064. private _engine;
  83065. private _options;
  83066. private _reusable;
  83067. private _textureType;
  83068. /**
  83069. * Smart array of input and output textures for the post process.
  83070. * @hidden
  83071. */
  83072. _textures: SmartArray<InternalTexture>;
  83073. /**
  83074. * The index in _textures that corresponds to the output texture.
  83075. * @hidden
  83076. */
  83077. _currentRenderTextureInd: number;
  83078. private _effect;
  83079. private _samplers;
  83080. private _fragmentUrl;
  83081. private _vertexUrl;
  83082. private _parameters;
  83083. private _scaleRatio;
  83084. protected _indexParameters: any;
  83085. private _shareOutputWithPostProcess;
  83086. private _texelSize;
  83087. private _forcedOutputTexture;
  83088. /**
  83089. * Returns the fragment url or shader name used in the post process.
  83090. * @returns the fragment url or name in the shader store.
  83091. */
  83092. getEffectName(): string;
  83093. /**
  83094. * An event triggered when the postprocess is activated.
  83095. */
  83096. onActivateObservable: Observable<Camera>;
  83097. private _onActivateObserver;
  83098. /**
  83099. * A function that is added to the onActivateObservable
  83100. */
  83101. onActivate: Nullable<(camera: Camera) => void>;
  83102. /**
  83103. * An event triggered when the postprocess changes its size.
  83104. */
  83105. onSizeChangedObservable: Observable<PostProcess>;
  83106. private _onSizeChangedObserver;
  83107. /**
  83108. * A function that is added to the onSizeChangedObservable
  83109. */
  83110. onSizeChanged: (postProcess: PostProcess) => void;
  83111. /**
  83112. * An event triggered when the postprocess applies its effect.
  83113. */
  83114. onApplyObservable: Observable<Effect>;
  83115. private _onApplyObserver;
  83116. /**
  83117. * A function that is added to the onApplyObservable
  83118. */
  83119. onApply: (effect: Effect) => void;
  83120. /**
  83121. * An event triggered before rendering the postprocess
  83122. */
  83123. onBeforeRenderObservable: Observable<Effect>;
  83124. private _onBeforeRenderObserver;
  83125. /**
  83126. * A function that is added to the onBeforeRenderObservable
  83127. */
  83128. onBeforeRender: (effect: Effect) => void;
  83129. /**
  83130. * An event triggered after rendering the postprocess
  83131. */
  83132. onAfterRenderObservable: Observable<Effect>;
  83133. private _onAfterRenderObserver;
  83134. /**
  83135. * A function that is added to the onAfterRenderObservable
  83136. */
  83137. onAfterRender: (efect: Effect) => void;
  83138. /**
  83139. * 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
  83140. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83141. */
  83142. inputTexture: InternalTexture;
  83143. /**
  83144. * Gets the camera which post process is applied to.
  83145. * @returns The camera the post process is applied to.
  83146. */
  83147. getCamera(): Camera;
  83148. /**
  83149. * Gets the texel size of the postprocess.
  83150. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83151. */
  83152. readonly texelSize: Vector2;
  83153. /**
  83154. * Creates a new instance PostProcess
  83155. * @param name The name of the PostProcess.
  83156. * @param fragmentUrl The url of the fragment shader to be used.
  83157. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83158. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83159. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83160. * @param camera The camera to apply the render pass to.
  83161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83162. * @param engine The engine which the post process will be applied. (default: current engine)
  83163. * @param reusable If the post process can be reused on the same frame. (default: false)
  83164. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83165. * @param textureType Type of textures used when performing the post process. (default: 0)
  83166. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83167. * @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
  83168. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83169. */
  83170. constructor(
  83171. /** Name of the PostProcess. */
  83172. 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);
  83173. /**
  83174. * Gets a string idenfifying the name of the class
  83175. * @returns "PostProcess" string
  83176. */
  83177. getClassName(): string;
  83178. /**
  83179. * Gets the engine which this post process belongs to.
  83180. * @returns The engine the post process was enabled with.
  83181. */
  83182. getEngine(): Engine;
  83183. /**
  83184. * The effect that is created when initializing the post process.
  83185. * @returns The created effect corresponding the the postprocess.
  83186. */
  83187. getEffect(): Effect;
  83188. /**
  83189. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83190. * @param postProcess The post process to share the output with.
  83191. * @returns This post process.
  83192. */
  83193. shareOutputWith(postProcess: PostProcess): PostProcess;
  83194. /**
  83195. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83196. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83197. */
  83198. useOwnOutput(): void;
  83199. /**
  83200. * Updates the effect with the current post process compile time values and recompiles the shader.
  83201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83204. * @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
  83205. * @param onCompiled Called when the shader has been compiled.
  83206. * @param onError Called if there is an error when compiling a shader.
  83207. */
  83208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83209. /**
  83210. * The post process is reusable if it can be used multiple times within one frame.
  83211. * @returns If the post process is reusable
  83212. */
  83213. isReusable(): boolean;
  83214. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83215. markTextureDirty(): void;
  83216. /**
  83217. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83218. * 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.
  83219. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83220. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83221. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83222. * @returns The target texture that was bound to be written to.
  83223. */
  83224. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83225. /**
  83226. * If the post process is supported.
  83227. */
  83228. readonly isSupported: boolean;
  83229. /**
  83230. * The aspect ratio of the output texture.
  83231. */
  83232. readonly aspectRatio: number;
  83233. /**
  83234. * Get a value indicating if the post-process is ready to be used
  83235. * @returns true if the post-process is ready (shader is compiled)
  83236. */
  83237. isReady(): boolean;
  83238. /**
  83239. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83240. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83241. */
  83242. apply(): Nullable<Effect>;
  83243. private _disposeTextures;
  83244. /**
  83245. * Disposes the post process.
  83246. * @param camera The camera to dispose the post process on.
  83247. */
  83248. dispose(camera?: Camera): void;
  83249. }
  83250. }
  83251. declare module BABYLON {
  83252. /** @hidden */
  83253. export var kernelBlurVaryingDeclaration: {
  83254. name: string;
  83255. shader: string;
  83256. };
  83257. }
  83258. declare module BABYLON {
  83259. /** @hidden */
  83260. export var kernelBlurFragment: {
  83261. name: string;
  83262. shader: string;
  83263. };
  83264. }
  83265. declare module BABYLON {
  83266. /** @hidden */
  83267. export var kernelBlurFragment2: {
  83268. name: string;
  83269. shader: string;
  83270. };
  83271. }
  83272. declare module BABYLON {
  83273. /** @hidden */
  83274. export var kernelBlurPixelShader: {
  83275. name: string;
  83276. shader: string;
  83277. };
  83278. }
  83279. declare module BABYLON {
  83280. /** @hidden */
  83281. export var kernelBlurVertex: {
  83282. name: string;
  83283. shader: string;
  83284. };
  83285. }
  83286. declare module BABYLON {
  83287. /** @hidden */
  83288. export var kernelBlurVertexShader: {
  83289. name: string;
  83290. shader: string;
  83291. };
  83292. }
  83293. declare module BABYLON {
  83294. /**
  83295. * The Blur Post Process which blurs an image based on a kernel and direction.
  83296. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83297. */
  83298. export class BlurPostProcess extends PostProcess {
  83299. /** The direction in which to blur the image. */
  83300. direction: Vector2;
  83301. private blockCompilation;
  83302. protected _kernel: number;
  83303. protected _idealKernel: number;
  83304. protected _packedFloat: boolean;
  83305. private _staticDefines;
  83306. /**
  83307. * Sets the length in pixels of the blur sample region
  83308. */
  83309. /**
  83310. * Gets the length in pixels of the blur sample region
  83311. */
  83312. kernel: number;
  83313. /**
  83314. * Sets wether or not the blur needs to unpack/repack floats
  83315. */
  83316. /**
  83317. * Gets wether or not the blur is unpacking/repacking floats
  83318. */
  83319. packedFloat: boolean;
  83320. /**
  83321. * Creates a new instance BlurPostProcess
  83322. * @param name The name of the effect.
  83323. * @param direction The direction in which to blur the image.
  83324. * @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.
  83325. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83326. * @param camera The camera to apply the render pass to.
  83327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83328. * @param engine The engine which the post process will be applied. (default: current engine)
  83329. * @param reusable If the post process can be reused on the same frame. (default: false)
  83330. * @param textureType Type of textures used when performing the post process. (default: 0)
  83331. * @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)
  83332. */
  83333. constructor(name: string,
  83334. /** The direction in which to blur the image. */
  83335. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83336. /**
  83337. * Updates the effect with the current post process compile time values and recompiles the shader.
  83338. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83339. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83340. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83341. * @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
  83342. * @param onCompiled Called when the shader has been compiled.
  83343. * @param onError Called if there is an error when compiling a shader.
  83344. */
  83345. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83346. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83347. /**
  83348. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83349. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83350. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83351. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83352. * The gaps between physical kernels are compensated for in the weighting of the samples
  83353. * @param idealKernel Ideal blur kernel.
  83354. * @return Nearest best kernel.
  83355. */
  83356. protected _nearestBestKernel(idealKernel: number): number;
  83357. /**
  83358. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83359. * @param x The point on the Gaussian distribution to sample.
  83360. * @return the value of the Gaussian function at x.
  83361. */
  83362. protected _gaussianWeight(x: number): number;
  83363. /**
  83364. * Generates a string that can be used as a floating point number in GLSL.
  83365. * @param x Value to print.
  83366. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83367. * @return GLSL float string.
  83368. */
  83369. protected _glslFloat(x: number, decimalFigures?: number): string;
  83370. }
  83371. }
  83372. declare module BABYLON {
  83373. /**
  83374. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83375. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83376. * You can then easily use it as a reflectionTexture on a flat surface.
  83377. * In case the surface is not a plane, please consider relying on reflection probes.
  83378. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83379. */
  83380. export class MirrorTexture extends RenderTargetTexture {
  83381. private scene;
  83382. /**
  83383. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83384. * 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.
  83385. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83386. */
  83387. mirrorPlane: Plane;
  83388. /**
  83389. * Define the blur ratio used to blur the reflection if needed.
  83390. */
  83391. blurRatio: number;
  83392. /**
  83393. * Define the adaptive blur kernel used to blur the reflection if needed.
  83394. * This will autocompute the closest best match for the `blurKernel`
  83395. */
  83396. adaptiveBlurKernel: number;
  83397. /**
  83398. * Define the blur kernel used to blur the reflection if needed.
  83399. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83400. */
  83401. blurKernel: number;
  83402. /**
  83403. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83404. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83405. */
  83406. blurKernelX: number;
  83407. /**
  83408. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83409. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83410. */
  83411. blurKernelY: number;
  83412. private _autoComputeBlurKernel;
  83413. protected _onRatioRescale(): void;
  83414. private _updateGammaSpace;
  83415. private _imageProcessingConfigChangeObserver;
  83416. private _transformMatrix;
  83417. private _mirrorMatrix;
  83418. private _savedViewMatrix;
  83419. private _blurX;
  83420. private _blurY;
  83421. private _adaptiveBlurKernel;
  83422. private _blurKernelX;
  83423. private _blurKernelY;
  83424. private _blurRatio;
  83425. /**
  83426. * Instantiates a Mirror Texture.
  83427. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83428. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83429. * You can then easily use it as a reflectionTexture on a flat surface.
  83430. * In case the surface is not a plane, please consider relying on reflection probes.
  83431. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83432. * @param name
  83433. * @param size
  83434. * @param scene
  83435. * @param generateMipMaps
  83436. * @param type
  83437. * @param samplingMode
  83438. * @param generateDepthBuffer
  83439. */
  83440. constructor(name: string, size: number | {
  83441. width: number;
  83442. height: number;
  83443. } | {
  83444. ratio: number;
  83445. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83446. private _preparePostProcesses;
  83447. /**
  83448. * Clone the mirror texture.
  83449. * @returns the cloned texture
  83450. */
  83451. clone(): MirrorTexture;
  83452. /**
  83453. * Serialize the texture to a JSON representation you could use in Parse later on
  83454. * @returns the serialized JSON representation
  83455. */
  83456. serialize(): any;
  83457. /**
  83458. * Dispose the texture and release its associated resources.
  83459. */
  83460. dispose(): void;
  83461. }
  83462. }
  83463. declare module BABYLON {
  83464. /**
  83465. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83466. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83467. */
  83468. export class Texture extends BaseTexture {
  83469. /**
  83470. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83471. */
  83472. static SerializeBuffers: boolean;
  83473. /** @hidden */
  83474. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83475. /** @hidden */
  83476. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83477. /** @hidden */
  83478. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83479. /** nearest is mag = nearest and min = nearest and mip = linear */
  83480. static readonly NEAREST_SAMPLINGMODE: number;
  83481. /** nearest is mag = nearest and min = nearest and mip = linear */
  83482. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83483. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83484. static readonly BILINEAR_SAMPLINGMODE: number;
  83485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83486. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83487. /** Trilinear is mag = linear and min = linear and mip = linear */
  83488. static readonly TRILINEAR_SAMPLINGMODE: number;
  83489. /** Trilinear is mag = linear and min = linear and mip = linear */
  83490. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83491. /** mag = nearest and min = nearest and mip = nearest */
  83492. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83493. /** mag = nearest and min = linear and mip = nearest */
  83494. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83495. /** mag = nearest and min = linear and mip = linear */
  83496. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83497. /** mag = nearest and min = linear and mip = none */
  83498. static readonly NEAREST_LINEAR: number;
  83499. /** mag = nearest and min = nearest and mip = none */
  83500. static readonly NEAREST_NEAREST: number;
  83501. /** mag = linear and min = nearest and mip = nearest */
  83502. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83503. /** mag = linear and min = nearest and mip = linear */
  83504. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83505. /** mag = linear and min = linear and mip = none */
  83506. static readonly LINEAR_LINEAR: number;
  83507. /** mag = linear and min = nearest and mip = none */
  83508. static readonly LINEAR_NEAREST: number;
  83509. /** Explicit coordinates mode */
  83510. static readonly EXPLICIT_MODE: number;
  83511. /** Spherical coordinates mode */
  83512. static readonly SPHERICAL_MODE: number;
  83513. /** Planar coordinates mode */
  83514. static readonly PLANAR_MODE: number;
  83515. /** Cubic coordinates mode */
  83516. static readonly CUBIC_MODE: number;
  83517. /** Projection coordinates mode */
  83518. static readonly PROJECTION_MODE: number;
  83519. /** Inverse Cubic coordinates mode */
  83520. static readonly SKYBOX_MODE: number;
  83521. /** Inverse Cubic coordinates mode */
  83522. static readonly INVCUBIC_MODE: number;
  83523. /** Equirectangular coordinates mode */
  83524. static readonly EQUIRECTANGULAR_MODE: number;
  83525. /** Equirectangular Fixed coordinates mode */
  83526. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83527. /** Equirectangular Fixed Mirrored coordinates mode */
  83528. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83529. /** Texture is not repeating outside of 0..1 UVs */
  83530. static readonly CLAMP_ADDRESSMODE: number;
  83531. /** Texture is repeating outside of 0..1 UVs */
  83532. static readonly WRAP_ADDRESSMODE: number;
  83533. /** Texture is repeating and mirrored */
  83534. static readonly MIRROR_ADDRESSMODE: number;
  83535. /**
  83536. * 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
  83537. */
  83538. static UseSerializedUrlIfAny: boolean;
  83539. /**
  83540. * Define the url of the texture.
  83541. */
  83542. url: Nullable<string>;
  83543. /**
  83544. * Define an offset on the texture to offset the u coordinates of the UVs
  83545. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83546. */
  83547. uOffset: number;
  83548. /**
  83549. * Define an offset on the texture to offset the v coordinates of the UVs
  83550. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83551. */
  83552. vOffset: number;
  83553. /**
  83554. * Define an offset on the texture to scale the u coordinates of the UVs
  83555. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83556. */
  83557. uScale: number;
  83558. /**
  83559. * Define an offset on the texture to scale the v coordinates of the UVs
  83560. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83561. */
  83562. vScale: number;
  83563. /**
  83564. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83565. * @see http://doc.babylonjs.com/how_to/more_materials
  83566. */
  83567. uAng: number;
  83568. /**
  83569. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83570. * @see http://doc.babylonjs.com/how_to/more_materials
  83571. */
  83572. vAng: number;
  83573. /**
  83574. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83575. * @see http://doc.babylonjs.com/how_to/more_materials
  83576. */
  83577. wAng: number;
  83578. /**
  83579. * Defines the center of rotation (U)
  83580. */
  83581. uRotationCenter: number;
  83582. /**
  83583. * Defines the center of rotation (V)
  83584. */
  83585. vRotationCenter: number;
  83586. /**
  83587. * Defines the center of rotation (W)
  83588. */
  83589. wRotationCenter: number;
  83590. /**
  83591. * Are mip maps generated for this texture or not.
  83592. */
  83593. readonly noMipmap: boolean;
  83594. /**
  83595. * List of inspectable custom properties (used by the Inspector)
  83596. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83597. */
  83598. inspectableCustomProperties: Nullable<IInspectable[]>;
  83599. private _noMipmap;
  83600. /** @hidden */
  83601. _invertY: boolean;
  83602. private _rowGenerationMatrix;
  83603. private _cachedTextureMatrix;
  83604. private _projectionModeMatrix;
  83605. private _t0;
  83606. private _t1;
  83607. private _t2;
  83608. private _cachedUOffset;
  83609. private _cachedVOffset;
  83610. private _cachedUScale;
  83611. private _cachedVScale;
  83612. private _cachedUAng;
  83613. private _cachedVAng;
  83614. private _cachedWAng;
  83615. private _cachedProjectionMatrixId;
  83616. private _cachedCoordinatesMode;
  83617. /** @hidden */
  83618. protected _initialSamplingMode: number;
  83619. /** @hidden */
  83620. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83621. private _deleteBuffer;
  83622. protected _format: Nullable<number>;
  83623. private _delayedOnLoad;
  83624. private _delayedOnError;
  83625. private _mimeType?;
  83626. /**
  83627. * Observable triggered once the texture has been loaded.
  83628. */
  83629. onLoadObservable: Observable<Texture>;
  83630. protected _isBlocking: boolean;
  83631. /**
  83632. * Is the texture preventing material to render while loading.
  83633. * If false, a default texture will be used instead of the loading one during the preparation step.
  83634. */
  83635. isBlocking: boolean;
  83636. /**
  83637. * Get the current sampling mode associated with the texture.
  83638. */
  83639. readonly samplingMode: number;
  83640. /**
  83641. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83642. */
  83643. readonly invertY: boolean;
  83644. /**
  83645. * Instantiates a new texture.
  83646. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83647. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83648. * @param url defines the url of the picture to load as a texture
  83649. * @param scene defines the scene or engine the texture will belong to
  83650. * @param noMipmap defines if the texture will require mip maps or not
  83651. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83652. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83653. * @param onLoad defines a callback triggered when the texture has been loaded
  83654. * @param onError defines a callback triggered when an error occurred during the loading session
  83655. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83656. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83657. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83658. * @param mimeType defines an optional mime type information
  83659. */
  83660. 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);
  83661. /**
  83662. * Update the url (and optional buffer) of this texture if url was null during construction.
  83663. * @param url the url of the texture
  83664. * @param buffer the buffer of the texture (defaults to null)
  83665. * @param onLoad callback called when the texture is loaded (defaults to null)
  83666. */
  83667. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83668. /**
  83669. * Finish the loading sequence of a texture flagged as delayed load.
  83670. * @hidden
  83671. */
  83672. delayLoad(): void;
  83673. private _prepareRowForTextureGeneration;
  83674. /**
  83675. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83676. * @returns the transform matrix of the texture.
  83677. */
  83678. getTextureMatrix(): Matrix;
  83679. /**
  83680. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83681. * @returns The reflection texture transform
  83682. */
  83683. getReflectionTextureMatrix(): Matrix;
  83684. /**
  83685. * Clones the texture.
  83686. * @returns the cloned texture
  83687. */
  83688. clone(): Texture;
  83689. /**
  83690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83691. * @returns The JSON representation of the texture
  83692. */
  83693. serialize(): any;
  83694. /**
  83695. * Get the current class name of the texture useful for serialization or dynamic coding.
  83696. * @returns "Texture"
  83697. */
  83698. getClassName(): string;
  83699. /**
  83700. * Dispose the texture and release its associated resources.
  83701. */
  83702. dispose(): void;
  83703. /**
  83704. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83705. * @param parsedTexture Define the JSON representation of the texture
  83706. * @param scene Define the scene the parsed texture should be instantiated in
  83707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83708. * @returns The parsed texture if successful
  83709. */
  83710. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83711. /**
  83712. * Creates a texture from its base 64 representation.
  83713. * @param data Define the base64 payload without the data: prefix
  83714. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83715. * @param scene Define the scene the texture should belong to
  83716. * @param noMipmap Forces the texture to not create mip map information if true
  83717. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83718. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83719. * @param onLoad define a callback triggered when the texture has been loaded
  83720. * @param onError define a callback triggered when an error occurred during the loading session
  83721. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83722. * @returns the created texture
  83723. */
  83724. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83725. /**
  83726. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83727. * @param data Define the base64 payload without the data: prefix
  83728. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83729. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83730. * @param scene Define the scene the texture should belong to
  83731. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83732. * @param noMipmap Forces the texture to not create mip map information if true
  83733. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83734. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83735. * @param onLoad define a callback triggered when the texture has been loaded
  83736. * @param onError define a callback triggered when an error occurred during the loading session
  83737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83738. * @returns the created texture
  83739. */
  83740. 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;
  83741. }
  83742. }
  83743. declare module BABYLON {
  83744. /**
  83745. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83746. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83747. */
  83748. export class PostProcessManager {
  83749. private _scene;
  83750. private _indexBuffer;
  83751. private _vertexBuffers;
  83752. /**
  83753. * Creates a new instance PostProcess
  83754. * @param scene The scene that the post process is associated with.
  83755. */
  83756. constructor(scene: Scene);
  83757. private _prepareBuffers;
  83758. private _buildIndexBuffer;
  83759. /**
  83760. * Rebuilds the vertex buffers of the manager.
  83761. * @hidden
  83762. */
  83763. _rebuild(): void;
  83764. /**
  83765. * Prepares a frame to be run through a post process.
  83766. * @param sourceTexture The input texture to the post procesess. (default: null)
  83767. * @param postProcesses An array of post processes to be run. (default: null)
  83768. * @returns True if the post processes were able to be run.
  83769. * @hidden
  83770. */
  83771. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83772. /**
  83773. * Manually render a set of post processes to a texture.
  83774. * @param postProcesses An array of post processes to be run.
  83775. * @param targetTexture The target texture to render to.
  83776. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83777. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83778. * @param lodLevel defines which lod of the texture to render to
  83779. */
  83780. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83781. /**
  83782. * Finalize the result of the output of the postprocesses.
  83783. * @param doNotPresent If true the result will not be displayed to the screen.
  83784. * @param targetTexture The target texture to render to.
  83785. * @param faceIndex The index of the face to bind the target texture to.
  83786. * @param postProcesses The array of post processes to render.
  83787. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83788. * @hidden
  83789. */
  83790. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83791. /**
  83792. * Disposes of the post process manager.
  83793. */
  83794. dispose(): void;
  83795. }
  83796. }
  83797. declare module BABYLON {
  83798. /** Interface used by value gradients (color, factor, ...) */
  83799. export interface IValueGradient {
  83800. /**
  83801. * Gets or sets the gradient value (between 0 and 1)
  83802. */
  83803. gradient: number;
  83804. }
  83805. /** Class used to store color4 gradient */
  83806. export class ColorGradient implements IValueGradient {
  83807. /**
  83808. * Gets or sets the gradient value (between 0 and 1)
  83809. */
  83810. gradient: number;
  83811. /**
  83812. * Gets or sets first associated color
  83813. */
  83814. color1: Color4;
  83815. /**
  83816. * Gets or sets second associated color
  83817. */
  83818. color2?: Color4;
  83819. /**
  83820. * Will get a color picked randomly between color1 and color2.
  83821. * If color2 is undefined then color1 will be used
  83822. * @param result defines the target Color4 to store the result in
  83823. */
  83824. getColorToRef(result: Color4): void;
  83825. }
  83826. /** Class used to store color 3 gradient */
  83827. export class Color3Gradient implements IValueGradient {
  83828. /**
  83829. * Gets or sets the gradient value (between 0 and 1)
  83830. */
  83831. gradient: number;
  83832. /**
  83833. * Gets or sets the associated color
  83834. */
  83835. color: Color3;
  83836. }
  83837. /** Class used to store factor gradient */
  83838. export class FactorGradient implements IValueGradient {
  83839. /**
  83840. * Gets or sets the gradient value (between 0 and 1)
  83841. */
  83842. gradient: number;
  83843. /**
  83844. * Gets or sets first associated factor
  83845. */
  83846. factor1: number;
  83847. /**
  83848. * Gets or sets second associated factor
  83849. */
  83850. factor2?: number;
  83851. /**
  83852. * Will get a number picked randomly between factor1 and factor2.
  83853. * If factor2 is undefined then factor1 will be used
  83854. * @returns the picked number
  83855. */
  83856. getFactor(): number;
  83857. }
  83858. /**
  83859. * Helper used to simplify some generic gradient tasks
  83860. */
  83861. export class GradientHelper {
  83862. /**
  83863. * Gets the current gradient from an array of IValueGradient
  83864. * @param ratio defines the current ratio to get
  83865. * @param gradients defines the array of IValueGradient
  83866. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83867. */
  83868. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83869. }
  83870. }
  83871. declare module BABYLON {
  83872. interface ThinEngine {
  83873. /**
  83874. * Creates a dynamic texture
  83875. * @param width defines the width of the texture
  83876. * @param height defines the height of the texture
  83877. * @param generateMipMaps defines if the engine should generate the mip levels
  83878. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83879. * @returns the dynamic texture inside an InternalTexture
  83880. */
  83881. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83882. /**
  83883. * Update the content of a dynamic texture
  83884. * @param texture defines the texture to update
  83885. * @param canvas defines the canvas containing the source
  83886. * @param invertY defines if data must be stored with Y axis inverted
  83887. * @param premulAlpha defines if alpha is stored as premultiplied
  83888. * @param format defines the format of the data
  83889. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83890. */
  83891. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83892. }
  83893. }
  83894. declare module BABYLON {
  83895. /**
  83896. * Helper class used to generate a canvas to manipulate images
  83897. */
  83898. export class CanvasGenerator {
  83899. /**
  83900. * Create a new canvas (or offscreen canvas depending on the context)
  83901. * @param width defines the expected width
  83902. * @param height defines the expected height
  83903. * @return a new canvas or offscreen canvas
  83904. */
  83905. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * A class extending Texture allowing drawing on a texture
  83911. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83912. */
  83913. export class DynamicTexture extends Texture {
  83914. private _generateMipMaps;
  83915. private _canvas;
  83916. private _context;
  83917. private _engine;
  83918. /**
  83919. * Creates a DynamicTexture
  83920. * @param name defines the name of the texture
  83921. * @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
  83922. * @param scene defines the scene where you want the texture
  83923. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83924. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83925. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83926. */
  83927. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83928. /**
  83929. * Get the current class name of the texture useful for serialization or dynamic coding.
  83930. * @returns "DynamicTexture"
  83931. */
  83932. getClassName(): string;
  83933. /**
  83934. * Gets the current state of canRescale
  83935. */
  83936. readonly canRescale: boolean;
  83937. private _recreate;
  83938. /**
  83939. * Scales the texture
  83940. * @param ratio the scale factor to apply to both width and height
  83941. */
  83942. scale(ratio: number): void;
  83943. /**
  83944. * Resizes the texture
  83945. * @param width the new width
  83946. * @param height the new height
  83947. */
  83948. scaleTo(width: number, height: number): void;
  83949. /**
  83950. * Gets the context of the canvas used by the texture
  83951. * @returns the canvas context of the dynamic texture
  83952. */
  83953. getContext(): CanvasRenderingContext2D;
  83954. /**
  83955. * Clears the texture
  83956. */
  83957. clear(): void;
  83958. /**
  83959. * Updates the texture
  83960. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83961. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83962. */
  83963. update(invertY?: boolean, premulAlpha?: boolean): void;
  83964. /**
  83965. * Draws text onto the texture
  83966. * @param text defines the text to be drawn
  83967. * @param x defines the placement of the text from the left
  83968. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83969. * @param font defines the font to be used with font-style, font-size, font-name
  83970. * @param color defines the color used for the text
  83971. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83972. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83973. * @param update defines whether texture is immediately update (default is true)
  83974. */
  83975. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83976. /**
  83977. * Clones the texture
  83978. * @returns the clone of the texture.
  83979. */
  83980. clone(): DynamicTexture;
  83981. /**
  83982. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83983. * @returns a serialized dynamic texture object
  83984. */
  83985. serialize(): any;
  83986. /** @hidden */
  83987. _rebuild(): void;
  83988. }
  83989. }
  83990. declare module BABYLON {
  83991. interface AbstractScene {
  83992. /**
  83993. * The list of procedural textures added to the scene
  83994. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83995. */
  83996. proceduralTextures: Array<ProceduralTexture>;
  83997. }
  83998. /**
  83999. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84000. * in a given scene.
  84001. */
  84002. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84003. /**
  84004. * The component name helpfull to identify the component in the list of scene components.
  84005. */
  84006. readonly name: string;
  84007. /**
  84008. * The scene the component belongs to.
  84009. */
  84010. scene: Scene;
  84011. /**
  84012. * Creates a new instance of the component for the given scene
  84013. * @param scene Defines the scene to register the component in
  84014. */
  84015. constructor(scene: Scene);
  84016. /**
  84017. * Registers the component in a given scene
  84018. */
  84019. register(): void;
  84020. /**
  84021. * Rebuilds the elements related to this component in case of
  84022. * context lost for instance.
  84023. */
  84024. rebuild(): void;
  84025. /**
  84026. * Disposes the component and the associated ressources.
  84027. */
  84028. dispose(): void;
  84029. private _beforeClear;
  84030. }
  84031. }
  84032. declare module BABYLON {
  84033. interface ThinEngine {
  84034. /**
  84035. * Creates a new render target cube texture
  84036. * @param size defines the size of the texture
  84037. * @param options defines the options used to create the texture
  84038. * @returns a new render target cube texture stored in an InternalTexture
  84039. */
  84040. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84041. }
  84042. }
  84043. declare module BABYLON {
  84044. /** @hidden */
  84045. export var proceduralVertexShader: {
  84046. name: string;
  84047. shader: string;
  84048. };
  84049. }
  84050. declare module BABYLON {
  84051. /**
  84052. * 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.
  84053. * This is the base class of any Procedural texture and contains most of the shareable code.
  84054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84055. */
  84056. export class ProceduralTexture extends Texture {
  84057. isCube: boolean;
  84058. /**
  84059. * Define if the texture is enabled or not (disabled texture will not render)
  84060. */
  84061. isEnabled: boolean;
  84062. /**
  84063. * Define if the texture must be cleared before rendering (default is true)
  84064. */
  84065. autoClear: boolean;
  84066. /**
  84067. * Callback called when the texture is generated
  84068. */
  84069. onGenerated: () => void;
  84070. /**
  84071. * Event raised when the texture is generated
  84072. */
  84073. onGeneratedObservable: Observable<ProceduralTexture>;
  84074. /** @hidden */
  84075. _generateMipMaps: boolean;
  84076. /** @hidden **/
  84077. _effect: Effect;
  84078. /** @hidden */
  84079. _textures: {
  84080. [key: string]: Texture;
  84081. };
  84082. private _size;
  84083. private _currentRefreshId;
  84084. private _refreshRate;
  84085. private _vertexBuffers;
  84086. private _indexBuffer;
  84087. private _uniforms;
  84088. private _samplers;
  84089. private _fragment;
  84090. private _floats;
  84091. private _ints;
  84092. private _floatsArrays;
  84093. private _colors3;
  84094. private _colors4;
  84095. private _vectors2;
  84096. private _vectors3;
  84097. private _matrices;
  84098. private _fallbackTexture;
  84099. private _fallbackTextureUsed;
  84100. private _engine;
  84101. private _cachedDefines;
  84102. private _contentUpdateId;
  84103. private _contentData;
  84104. /**
  84105. * Instantiates a new procedural texture.
  84106. * 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.
  84107. * This is the base class of any Procedural texture and contains most of the shareable code.
  84108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84109. * @param name Define the name of the texture
  84110. * @param size Define the size of the texture to create
  84111. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84112. * @param scene Define the scene the texture belongs to
  84113. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84114. * @param generateMipMaps Define if the texture should creates mip maps or not
  84115. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84116. */
  84117. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84118. /**
  84119. * The effect that is created when initializing the post process.
  84120. * @returns The created effect corresponding the the postprocess.
  84121. */
  84122. getEffect(): Effect;
  84123. /**
  84124. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84125. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84126. */
  84127. getContent(): Nullable<ArrayBufferView>;
  84128. private _createIndexBuffer;
  84129. /** @hidden */
  84130. _rebuild(): void;
  84131. /**
  84132. * Resets the texture in order to recreate its associated resources.
  84133. * This can be called in case of context loss
  84134. */
  84135. reset(): void;
  84136. protected _getDefines(): string;
  84137. /**
  84138. * Is the texture ready to be used ? (rendered at least once)
  84139. * @returns true if ready, otherwise, false.
  84140. */
  84141. isReady(): boolean;
  84142. /**
  84143. * Resets the refresh counter of the texture and start bak from scratch.
  84144. * Could be useful to regenerate the texture if it is setup to render only once.
  84145. */
  84146. resetRefreshCounter(): void;
  84147. /**
  84148. * Set the fragment shader to use in order to render the texture.
  84149. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84150. */
  84151. setFragment(fragment: any): void;
  84152. /**
  84153. * Define the refresh rate of the texture or the rendering frequency.
  84154. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84155. */
  84156. refreshRate: number;
  84157. /** @hidden */
  84158. _shouldRender(): boolean;
  84159. /**
  84160. * Get the size the texture is rendering at.
  84161. * @returns the size (texture is always squared)
  84162. */
  84163. getRenderSize(): number;
  84164. /**
  84165. * Resize the texture to new value.
  84166. * @param size Define the new size the texture should have
  84167. * @param generateMipMaps Define whether the new texture should create mip maps
  84168. */
  84169. resize(size: number, generateMipMaps: boolean): void;
  84170. private _checkUniform;
  84171. /**
  84172. * Set a texture in the shader program used to render.
  84173. * @param name Define the name of the uniform samplers as defined in the shader
  84174. * @param texture Define the texture to bind to this sampler
  84175. * @return the texture itself allowing "fluent" like uniform updates
  84176. */
  84177. setTexture(name: string, texture: Texture): ProceduralTexture;
  84178. /**
  84179. * Set a float in the shader.
  84180. * @param name Define the name of the uniform as defined in the shader
  84181. * @param value Define the value to give to the uniform
  84182. * @return the texture itself allowing "fluent" like uniform updates
  84183. */
  84184. setFloat(name: string, value: number): ProceduralTexture;
  84185. /**
  84186. * Set a int in the shader.
  84187. * @param name Define the name of the uniform as defined in the shader
  84188. * @param value Define the value to give to the uniform
  84189. * @return the texture itself allowing "fluent" like uniform updates
  84190. */
  84191. setInt(name: string, value: number): ProceduralTexture;
  84192. /**
  84193. * Set an array of floats in the shader.
  84194. * @param name Define the name of the uniform as defined in the shader
  84195. * @param value Define the value to give to the uniform
  84196. * @return the texture itself allowing "fluent" like uniform updates
  84197. */
  84198. setFloats(name: string, value: number[]): ProceduralTexture;
  84199. /**
  84200. * Set a vec3 in the shader from a Color3.
  84201. * @param name Define the name of the uniform as defined in the shader
  84202. * @param value Define the value to give to the uniform
  84203. * @return the texture itself allowing "fluent" like uniform updates
  84204. */
  84205. setColor3(name: string, value: Color3): ProceduralTexture;
  84206. /**
  84207. * Set a vec4 in the shader from a Color4.
  84208. * @param name Define the name of the uniform as defined in the shader
  84209. * @param value Define the value to give to the uniform
  84210. * @return the texture itself allowing "fluent" like uniform updates
  84211. */
  84212. setColor4(name: string, value: Color4): ProceduralTexture;
  84213. /**
  84214. * Set a vec2 in the shader from a Vector2.
  84215. * @param name Define the name of the uniform as defined in the shader
  84216. * @param value Define the value to give to the uniform
  84217. * @return the texture itself allowing "fluent" like uniform updates
  84218. */
  84219. setVector2(name: string, value: Vector2): ProceduralTexture;
  84220. /**
  84221. * Set a vec3 in the shader from a Vector3.
  84222. * @param name Define the name of the uniform as defined in the shader
  84223. * @param value Define the value to give to the uniform
  84224. * @return the texture itself allowing "fluent" like uniform updates
  84225. */
  84226. setVector3(name: string, value: Vector3): ProceduralTexture;
  84227. /**
  84228. * Set a mat4 in the shader from a MAtrix.
  84229. * @param name Define the name of the uniform as defined in the shader
  84230. * @param value Define the value to give to the uniform
  84231. * @return the texture itself allowing "fluent" like uniform updates
  84232. */
  84233. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84234. /**
  84235. * Render the texture to its associated render target.
  84236. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84237. */
  84238. render(useCameraPostProcess?: boolean): void;
  84239. /**
  84240. * Clone the texture.
  84241. * @returns the cloned texture
  84242. */
  84243. clone(): ProceduralTexture;
  84244. /**
  84245. * Dispose the texture and release its asoociated resources.
  84246. */
  84247. dispose(): void;
  84248. }
  84249. }
  84250. declare module BABYLON {
  84251. /**
  84252. * This represents the base class for particle system in Babylon.
  84253. * 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.
  84254. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84255. * @example https://doc.babylonjs.com/babylon101/particles
  84256. */
  84257. export class BaseParticleSystem {
  84258. /**
  84259. * Source color is added to the destination color without alpha affecting the result
  84260. */
  84261. static BLENDMODE_ONEONE: number;
  84262. /**
  84263. * Blend current color and particle color using particle’s alpha
  84264. */
  84265. static BLENDMODE_STANDARD: number;
  84266. /**
  84267. * Add current color and particle color multiplied by particle’s alpha
  84268. */
  84269. static BLENDMODE_ADD: number;
  84270. /**
  84271. * Multiply current color with particle color
  84272. */
  84273. static BLENDMODE_MULTIPLY: number;
  84274. /**
  84275. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84276. */
  84277. static BLENDMODE_MULTIPLYADD: number;
  84278. /**
  84279. * List of animations used by the particle system.
  84280. */
  84281. animations: Animation[];
  84282. /**
  84283. * The id of the Particle system.
  84284. */
  84285. id: string;
  84286. /**
  84287. * The friendly name of the Particle system.
  84288. */
  84289. name: string;
  84290. /**
  84291. * The rendering group used by the Particle system to chose when to render.
  84292. */
  84293. renderingGroupId: number;
  84294. /**
  84295. * The emitter represents the Mesh or position we are attaching the particle system to.
  84296. */
  84297. emitter: Nullable<AbstractMesh | Vector3>;
  84298. /**
  84299. * The maximum number of particles to emit per frame
  84300. */
  84301. emitRate: number;
  84302. /**
  84303. * If you want to launch only a few particles at once, that can be done, as well.
  84304. */
  84305. manualEmitCount: number;
  84306. /**
  84307. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84308. */
  84309. updateSpeed: number;
  84310. /**
  84311. * The amount of time the particle system is running (depends of the overall update speed).
  84312. */
  84313. targetStopDuration: number;
  84314. /**
  84315. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84316. */
  84317. disposeOnStop: boolean;
  84318. /**
  84319. * Minimum power of emitting particles.
  84320. */
  84321. minEmitPower: number;
  84322. /**
  84323. * Maximum power of emitting particles.
  84324. */
  84325. maxEmitPower: number;
  84326. /**
  84327. * Minimum life time of emitting particles.
  84328. */
  84329. minLifeTime: number;
  84330. /**
  84331. * Maximum life time of emitting particles.
  84332. */
  84333. maxLifeTime: number;
  84334. /**
  84335. * Minimum Size of emitting particles.
  84336. */
  84337. minSize: number;
  84338. /**
  84339. * Maximum Size of emitting particles.
  84340. */
  84341. maxSize: number;
  84342. /**
  84343. * Minimum scale of emitting particles on X axis.
  84344. */
  84345. minScaleX: number;
  84346. /**
  84347. * Maximum scale of emitting particles on X axis.
  84348. */
  84349. maxScaleX: number;
  84350. /**
  84351. * Minimum scale of emitting particles on Y axis.
  84352. */
  84353. minScaleY: number;
  84354. /**
  84355. * Maximum scale of emitting particles on Y axis.
  84356. */
  84357. maxScaleY: number;
  84358. /**
  84359. * Gets or sets the minimal initial rotation in radians.
  84360. */
  84361. minInitialRotation: number;
  84362. /**
  84363. * Gets or sets the maximal initial rotation in radians.
  84364. */
  84365. maxInitialRotation: number;
  84366. /**
  84367. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84368. */
  84369. minAngularSpeed: number;
  84370. /**
  84371. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84372. */
  84373. maxAngularSpeed: number;
  84374. /**
  84375. * The texture used to render each particle. (this can be a spritesheet)
  84376. */
  84377. particleTexture: Nullable<Texture>;
  84378. /**
  84379. * The layer mask we are rendering the particles through.
  84380. */
  84381. layerMask: number;
  84382. /**
  84383. * This can help using your own shader to render the particle system.
  84384. * The according effect will be created
  84385. */
  84386. customShader: any;
  84387. /**
  84388. * By default particle system starts as soon as they are created. This prevents the
  84389. * automatic start to happen and let you decide when to start emitting particles.
  84390. */
  84391. preventAutoStart: boolean;
  84392. private _noiseTexture;
  84393. /**
  84394. * Gets or sets a texture used to add random noise to particle positions
  84395. */
  84396. noiseTexture: Nullable<ProceduralTexture>;
  84397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84398. noiseStrength: Vector3;
  84399. /**
  84400. * Callback triggered when the particle animation is ending.
  84401. */
  84402. onAnimationEnd: Nullable<() => void>;
  84403. /**
  84404. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84405. */
  84406. blendMode: number;
  84407. /**
  84408. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84409. * to override the particles.
  84410. */
  84411. forceDepthWrite: boolean;
  84412. /** 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 */
  84413. preWarmCycles: number;
  84414. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84415. preWarmStepOffset: number;
  84416. /**
  84417. * 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)
  84418. */
  84419. spriteCellChangeSpeed: number;
  84420. /**
  84421. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84422. */
  84423. startSpriteCellID: number;
  84424. /**
  84425. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84426. */
  84427. endSpriteCellID: number;
  84428. /**
  84429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84430. */
  84431. spriteCellWidth: number;
  84432. /**
  84433. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84434. */
  84435. spriteCellHeight: number;
  84436. /**
  84437. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84438. */
  84439. spriteRandomStartCell: boolean;
  84440. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84441. translationPivot: Vector2;
  84442. /** @hidden */
  84443. protected _isAnimationSheetEnabled: boolean;
  84444. /**
  84445. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84446. */
  84447. beginAnimationOnStart: boolean;
  84448. /**
  84449. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84450. */
  84451. beginAnimationFrom: number;
  84452. /**
  84453. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84454. */
  84455. beginAnimationTo: number;
  84456. /**
  84457. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84458. */
  84459. beginAnimationLoop: boolean;
  84460. /**
  84461. * Gets or sets a world offset applied to all particles
  84462. */
  84463. worldOffset: Vector3;
  84464. /**
  84465. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84466. */
  84467. isAnimationSheetEnabled: boolean;
  84468. /**
  84469. * Get hosting scene
  84470. * @returns the scene
  84471. */
  84472. getScene(): Scene;
  84473. /**
  84474. * You can use gravity if you want to give an orientation to your particles.
  84475. */
  84476. gravity: Vector3;
  84477. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84478. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84479. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84480. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84481. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84482. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84483. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84484. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84485. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84486. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84487. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84488. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84489. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84490. /**
  84491. * Defines the delay in milliseconds before starting the system (0 by default)
  84492. */
  84493. startDelay: number;
  84494. /**
  84495. * Gets the current list of drag gradients.
  84496. * You must use addDragGradient and removeDragGradient to udpate this list
  84497. * @returns the list of drag gradients
  84498. */
  84499. getDragGradients(): Nullable<Array<FactorGradient>>;
  84500. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84501. limitVelocityDamping: number;
  84502. /**
  84503. * Gets the current list of limit velocity gradients.
  84504. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84505. * @returns the list of limit velocity gradients
  84506. */
  84507. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84508. /**
  84509. * Gets the current list of color gradients.
  84510. * You must use addColorGradient and removeColorGradient to udpate this list
  84511. * @returns the list of color gradients
  84512. */
  84513. getColorGradients(): Nullable<Array<ColorGradient>>;
  84514. /**
  84515. * Gets the current list of size gradients.
  84516. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84517. * @returns the list of size gradients
  84518. */
  84519. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84520. /**
  84521. * Gets the current list of color remap gradients.
  84522. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84523. * @returns the list of color remap gradients
  84524. */
  84525. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84526. /**
  84527. * Gets the current list of alpha remap gradients.
  84528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84529. * @returns the list of alpha remap gradients
  84530. */
  84531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84532. /**
  84533. * Gets the current list of life time gradients.
  84534. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84535. * @returns the list of life time gradients
  84536. */
  84537. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84538. /**
  84539. * Gets the current list of angular speed gradients.
  84540. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84541. * @returns the list of angular speed gradients
  84542. */
  84543. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84544. /**
  84545. * Gets the current list of velocity gradients.
  84546. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84547. * @returns the list of velocity gradients
  84548. */
  84549. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84550. /**
  84551. * Gets the current list of start size gradients.
  84552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84553. * @returns the list of start size gradients
  84554. */
  84555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84556. /**
  84557. * Gets the current list of emit rate gradients.
  84558. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84559. * @returns the list of emit rate gradients
  84560. */
  84561. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84562. /**
  84563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84564. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84565. */
  84566. direction1: Vector3;
  84567. /**
  84568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84570. */
  84571. direction2: Vector3;
  84572. /**
  84573. * 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.
  84574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84575. */
  84576. minEmitBox: Vector3;
  84577. /**
  84578. * 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.
  84579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84580. */
  84581. maxEmitBox: Vector3;
  84582. /**
  84583. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84584. */
  84585. color1: Color4;
  84586. /**
  84587. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84588. */
  84589. color2: Color4;
  84590. /**
  84591. * Color the particle will have at the end of its lifetime
  84592. */
  84593. colorDead: Color4;
  84594. /**
  84595. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84596. */
  84597. textureMask: Color4;
  84598. /**
  84599. * The particle emitter type defines the emitter used by the particle system.
  84600. * It can be for example box, sphere, or cone...
  84601. */
  84602. particleEmitterType: IParticleEmitterType;
  84603. /** @hidden */
  84604. _isSubEmitter: boolean;
  84605. /**
  84606. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84607. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84608. */
  84609. billboardMode: number;
  84610. protected _isBillboardBased: boolean;
  84611. /**
  84612. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84613. */
  84614. isBillboardBased: boolean;
  84615. /**
  84616. * The scene the particle system belongs to.
  84617. */
  84618. protected _scene: Scene;
  84619. /**
  84620. * Local cache of defines for image processing.
  84621. */
  84622. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84623. /**
  84624. * Default configuration related to image processing available in the standard Material.
  84625. */
  84626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84627. /**
  84628. * Gets the image processing configuration used either in this material.
  84629. */
  84630. /**
  84631. * Sets the Default image processing configuration used either in the this material.
  84632. *
  84633. * If sets to null, the scene one is in use.
  84634. */
  84635. imageProcessingConfiguration: ImageProcessingConfiguration;
  84636. /**
  84637. * Attaches a new image processing configuration to the Standard Material.
  84638. * @param configuration
  84639. */
  84640. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84641. /** @hidden */
  84642. protected _reset(): void;
  84643. /** @hidden */
  84644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84645. /**
  84646. * Instantiates a particle system.
  84647. * 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.
  84648. * @param name The name of the particle system
  84649. */
  84650. constructor(name: string);
  84651. /**
  84652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84655. * @returns the emitter
  84656. */
  84657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84658. /**
  84659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84660. * @param radius The radius of the hemisphere to emit from
  84661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84662. * @returns the emitter
  84663. */
  84664. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84665. /**
  84666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84667. * @param radius The radius of the sphere to emit from
  84668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84669. * @returns the emitter
  84670. */
  84671. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84672. /**
  84673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84674. * @param radius The radius of the sphere to emit from
  84675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84677. * @returns the emitter
  84678. */
  84679. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84680. /**
  84681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84682. * @param radius The radius of the emission cylinder
  84683. * @param height The height of the emission cylinder
  84684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84686. * @returns the emitter
  84687. */
  84688. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84689. /**
  84690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84691. * @param radius The radius of the cylinder to emit from
  84692. * @param height The height of the emission cylinder
  84693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84696. * @returns the emitter
  84697. */
  84698. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84699. /**
  84700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84701. * @param radius The radius of the cone to emit from
  84702. * @param angle The base angle of the cone
  84703. * @returns the emitter
  84704. */
  84705. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84706. /**
  84707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84712. * @returns the emitter
  84713. */
  84714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84715. }
  84716. }
  84717. declare module BABYLON {
  84718. /**
  84719. * Type of sub emitter
  84720. */
  84721. export enum SubEmitterType {
  84722. /**
  84723. * Attached to the particle over it's lifetime
  84724. */
  84725. ATTACHED = 0,
  84726. /**
  84727. * Created when the particle dies
  84728. */
  84729. END = 1
  84730. }
  84731. /**
  84732. * Sub emitter class used to emit particles from an existing particle
  84733. */
  84734. export class SubEmitter {
  84735. /**
  84736. * the particle system to be used by the sub emitter
  84737. */
  84738. particleSystem: ParticleSystem;
  84739. /**
  84740. * Type of the submitter (Default: END)
  84741. */
  84742. type: SubEmitterType;
  84743. /**
  84744. * 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)
  84745. * Note: This only is supported when using an emitter of type Mesh
  84746. */
  84747. inheritDirection: boolean;
  84748. /**
  84749. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84750. */
  84751. inheritedVelocityAmount: number;
  84752. /**
  84753. * Creates a sub emitter
  84754. * @param particleSystem the particle system to be used by the sub emitter
  84755. */
  84756. constructor(
  84757. /**
  84758. * the particle system to be used by the sub emitter
  84759. */
  84760. particleSystem: ParticleSystem);
  84761. /**
  84762. * Clones the sub emitter
  84763. * @returns the cloned sub emitter
  84764. */
  84765. clone(): SubEmitter;
  84766. /**
  84767. * Serialize current object to a JSON object
  84768. * @returns the serialized object
  84769. */
  84770. serialize(): any;
  84771. /** @hidden */
  84772. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84773. /**
  84774. * Creates a new SubEmitter from a serialized JSON version
  84775. * @param serializationObject defines the JSON object to read from
  84776. * @param scene defines the hosting scene
  84777. * @param rootUrl defines the rootUrl for data loading
  84778. * @returns a new SubEmitter
  84779. */
  84780. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84781. /** Release associated resources */
  84782. dispose(): void;
  84783. }
  84784. }
  84785. declare module BABYLON {
  84786. /** @hidden */
  84787. export var clipPlaneFragmentDeclaration: {
  84788. name: string;
  84789. shader: string;
  84790. };
  84791. }
  84792. declare module BABYLON {
  84793. /** @hidden */
  84794. export var imageProcessingDeclaration: {
  84795. name: string;
  84796. shader: string;
  84797. };
  84798. }
  84799. declare module BABYLON {
  84800. /** @hidden */
  84801. export var imageProcessingFunctions: {
  84802. name: string;
  84803. shader: string;
  84804. };
  84805. }
  84806. declare module BABYLON {
  84807. /** @hidden */
  84808. export var clipPlaneFragment: {
  84809. name: string;
  84810. shader: string;
  84811. };
  84812. }
  84813. declare module BABYLON {
  84814. /** @hidden */
  84815. export var particlesPixelShader: {
  84816. name: string;
  84817. shader: string;
  84818. };
  84819. }
  84820. declare module BABYLON {
  84821. /** @hidden */
  84822. export var clipPlaneVertexDeclaration: {
  84823. name: string;
  84824. shader: string;
  84825. };
  84826. }
  84827. declare module BABYLON {
  84828. /** @hidden */
  84829. export var clipPlaneVertex: {
  84830. name: string;
  84831. shader: string;
  84832. };
  84833. }
  84834. declare module BABYLON {
  84835. /** @hidden */
  84836. export var particlesVertexShader: {
  84837. name: string;
  84838. shader: string;
  84839. };
  84840. }
  84841. declare module BABYLON {
  84842. /**
  84843. * This represents a particle system in Babylon.
  84844. * 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.
  84845. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84846. * @example https://doc.babylonjs.com/babylon101/particles
  84847. */
  84848. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84849. /**
  84850. * Billboard mode will only apply to Y axis
  84851. */
  84852. static readonly BILLBOARDMODE_Y: number;
  84853. /**
  84854. * Billboard mode will apply to all axes
  84855. */
  84856. static readonly BILLBOARDMODE_ALL: number;
  84857. /**
  84858. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84859. */
  84860. static readonly BILLBOARDMODE_STRETCHED: number;
  84861. /**
  84862. * This function can be defined to provide custom update for active particles.
  84863. * This function will be called instead of regular update (age, position, color, etc.).
  84864. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84865. */
  84866. updateFunction: (particles: Particle[]) => void;
  84867. private _emitterWorldMatrix;
  84868. /**
  84869. * This function can be defined to specify initial direction for every new particle.
  84870. * It by default use the emitterType defined function
  84871. */
  84872. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84873. /**
  84874. * This function can be defined to specify initial position for every new particle.
  84875. * It by default use the emitterType defined function
  84876. */
  84877. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84878. /**
  84879. * @hidden
  84880. */
  84881. _inheritedVelocityOffset: Vector3;
  84882. /**
  84883. * An event triggered when the system is disposed
  84884. */
  84885. onDisposeObservable: Observable<ParticleSystem>;
  84886. private _onDisposeObserver;
  84887. /**
  84888. * Sets a callback that will be triggered when the system is disposed
  84889. */
  84890. onDispose: () => void;
  84891. private _particles;
  84892. private _epsilon;
  84893. private _capacity;
  84894. private _stockParticles;
  84895. private _newPartsExcess;
  84896. private _vertexData;
  84897. private _vertexBuffer;
  84898. private _vertexBuffers;
  84899. private _spriteBuffer;
  84900. private _indexBuffer;
  84901. private _effect;
  84902. private _customEffect;
  84903. private _cachedDefines;
  84904. private _scaledColorStep;
  84905. private _colorDiff;
  84906. private _scaledDirection;
  84907. private _scaledGravity;
  84908. private _currentRenderId;
  84909. private _alive;
  84910. private _useInstancing;
  84911. private _started;
  84912. private _stopped;
  84913. private _actualFrame;
  84914. private _scaledUpdateSpeed;
  84915. private _vertexBufferSize;
  84916. /** @hidden */
  84917. _currentEmitRateGradient: Nullable<FactorGradient>;
  84918. /** @hidden */
  84919. _currentEmitRate1: number;
  84920. /** @hidden */
  84921. _currentEmitRate2: number;
  84922. /** @hidden */
  84923. _currentStartSizeGradient: Nullable<FactorGradient>;
  84924. /** @hidden */
  84925. _currentStartSize1: number;
  84926. /** @hidden */
  84927. _currentStartSize2: number;
  84928. private readonly _rawTextureWidth;
  84929. private _rampGradientsTexture;
  84930. private _useRampGradients;
  84931. /** Gets or sets a boolean indicating that ramp gradients must be used
  84932. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84933. */
  84934. useRampGradients: boolean;
  84935. /**
  84936. * 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.
  84937. * 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: [])
  84938. */
  84939. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84940. private _subEmitters;
  84941. /**
  84942. * @hidden
  84943. * If the particle systems emitter should be disposed when the particle system is disposed
  84944. */
  84945. _disposeEmitterOnDispose: boolean;
  84946. /**
  84947. * The current active Sub-systems, this property is used by the root particle system only.
  84948. */
  84949. activeSubSystems: Array<ParticleSystem>;
  84950. private _rootParticleSystem;
  84951. /**
  84952. * Gets the current list of active particles
  84953. */
  84954. readonly particles: Particle[];
  84955. /**
  84956. * Returns the string "ParticleSystem"
  84957. * @returns a string containing the class name
  84958. */
  84959. getClassName(): string;
  84960. /**
  84961. * Instantiates a particle system.
  84962. * 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.
  84963. * @param name The name of the particle system
  84964. * @param capacity The max number of particles alive at the same time
  84965. * @param scene The scene the particle system belongs to
  84966. * @param customEffect a custom effect used to change the way particles are rendered by default
  84967. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84968. * @param epsilon Offset used to render the particles
  84969. */
  84970. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84971. private _addFactorGradient;
  84972. private _removeFactorGradient;
  84973. /**
  84974. * Adds a new life time gradient
  84975. * @param gradient defines the gradient to use (between 0 and 1)
  84976. * @param factor defines the life time factor to affect to the specified gradient
  84977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84978. * @returns the current particle system
  84979. */
  84980. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84981. /**
  84982. * Remove a specific life time gradient
  84983. * @param gradient defines the gradient to remove
  84984. * @returns the current particle system
  84985. */
  84986. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84987. /**
  84988. * Adds a new size gradient
  84989. * @param gradient defines the gradient to use (between 0 and 1)
  84990. * @param factor defines the size factor to affect to the specified gradient
  84991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84992. * @returns the current particle system
  84993. */
  84994. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84995. /**
  84996. * Remove a specific size gradient
  84997. * @param gradient defines the gradient to remove
  84998. * @returns the current particle system
  84999. */
  85000. removeSizeGradient(gradient: number): IParticleSystem;
  85001. /**
  85002. * Adds a new color remap gradient
  85003. * @param gradient defines the gradient to use (between 0 and 1)
  85004. * @param min defines the color remap minimal range
  85005. * @param max defines the color remap maximal range
  85006. * @returns the current particle system
  85007. */
  85008. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85009. /**
  85010. * Remove a specific color remap gradient
  85011. * @param gradient defines the gradient to remove
  85012. * @returns the current particle system
  85013. */
  85014. removeColorRemapGradient(gradient: number): IParticleSystem;
  85015. /**
  85016. * Adds a new alpha remap gradient
  85017. * @param gradient defines the gradient to use (between 0 and 1)
  85018. * @param min defines the alpha remap minimal range
  85019. * @param max defines the alpha remap maximal range
  85020. * @returns the current particle system
  85021. */
  85022. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85023. /**
  85024. * Remove a specific alpha remap gradient
  85025. * @param gradient defines the gradient to remove
  85026. * @returns the current particle system
  85027. */
  85028. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85029. /**
  85030. * Adds a new angular speed gradient
  85031. * @param gradient defines the gradient to use (between 0 and 1)
  85032. * @param factor defines the angular speed to affect to the specified gradient
  85033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85034. * @returns the current particle system
  85035. */
  85036. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85037. /**
  85038. * Remove a specific angular speed gradient
  85039. * @param gradient defines the gradient to remove
  85040. * @returns the current particle system
  85041. */
  85042. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85043. /**
  85044. * Adds a new velocity gradient
  85045. * @param gradient defines the gradient to use (between 0 and 1)
  85046. * @param factor defines the velocity to affect to the specified gradient
  85047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85048. * @returns the current particle system
  85049. */
  85050. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85051. /**
  85052. * Remove a specific velocity gradient
  85053. * @param gradient defines the gradient to remove
  85054. * @returns the current particle system
  85055. */
  85056. removeVelocityGradient(gradient: number): IParticleSystem;
  85057. /**
  85058. * Adds a new limit velocity gradient
  85059. * @param gradient defines the gradient to use (between 0 and 1)
  85060. * @param factor defines the limit velocity value to affect to the specified gradient
  85061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85062. * @returns the current particle system
  85063. */
  85064. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85065. /**
  85066. * Remove a specific limit velocity gradient
  85067. * @param gradient defines the gradient to remove
  85068. * @returns the current particle system
  85069. */
  85070. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85071. /**
  85072. * Adds a new drag gradient
  85073. * @param gradient defines the gradient to use (between 0 and 1)
  85074. * @param factor defines the drag value to affect to the specified gradient
  85075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85076. * @returns the current particle system
  85077. */
  85078. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85079. /**
  85080. * Remove a specific drag gradient
  85081. * @param gradient defines the gradient to remove
  85082. * @returns the current particle system
  85083. */
  85084. removeDragGradient(gradient: number): IParticleSystem;
  85085. /**
  85086. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85087. * @param gradient defines the gradient to use (between 0 and 1)
  85088. * @param factor defines the emit rate value to affect to the specified gradient
  85089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85090. * @returns the current particle system
  85091. */
  85092. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85093. /**
  85094. * Remove a specific emit rate gradient
  85095. * @param gradient defines the gradient to remove
  85096. * @returns the current particle system
  85097. */
  85098. removeEmitRateGradient(gradient: number): IParticleSystem;
  85099. /**
  85100. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85101. * @param gradient defines the gradient to use (between 0 and 1)
  85102. * @param factor defines the start size value to affect to the specified gradient
  85103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85104. * @returns the current particle system
  85105. */
  85106. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85107. /**
  85108. * Remove a specific start size gradient
  85109. * @param gradient defines the gradient to remove
  85110. * @returns the current particle system
  85111. */
  85112. removeStartSizeGradient(gradient: number): IParticleSystem;
  85113. private _createRampGradientTexture;
  85114. /**
  85115. * Gets the current list of ramp gradients.
  85116. * You must use addRampGradient and removeRampGradient to udpate this list
  85117. * @returns the list of ramp gradients
  85118. */
  85119. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85120. /**
  85121. * Adds a new ramp gradient used to remap particle colors
  85122. * @param gradient defines the gradient to use (between 0 and 1)
  85123. * @param color defines the color to affect to the specified gradient
  85124. * @returns the current particle system
  85125. */
  85126. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85127. /**
  85128. * Remove a specific ramp gradient
  85129. * @param gradient defines the gradient to remove
  85130. * @returns the current particle system
  85131. */
  85132. removeRampGradient(gradient: number): ParticleSystem;
  85133. /**
  85134. * Adds a new color gradient
  85135. * @param gradient defines the gradient to use (between 0 and 1)
  85136. * @param color1 defines the color to affect to the specified gradient
  85137. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85138. * @returns this particle system
  85139. */
  85140. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85141. /**
  85142. * Remove a specific color gradient
  85143. * @param gradient defines the gradient to remove
  85144. * @returns this particle system
  85145. */
  85146. removeColorGradient(gradient: number): IParticleSystem;
  85147. private _fetchR;
  85148. protected _reset(): void;
  85149. private _resetEffect;
  85150. private _createVertexBuffers;
  85151. private _createIndexBuffer;
  85152. /**
  85153. * Gets the maximum number of particles active at the same time.
  85154. * @returns The max number of active particles.
  85155. */
  85156. getCapacity(): number;
  85157. /**
  85158. * Gets whether there are still active particles in the system.
  85159. * @returns True if it is alive, otherwise false.
  85160. */
  85161. isAlive(): boolean;
  85162. /**
  85163. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85164. * @returns True if it has been started, otherwise false.
  85165. */
  85166. isStarted(): boolean;
  85167. private _prepareSubEmitterInternalArray;
  85168. /**
  85169. * Starts the particle system and begins to emit
  85170. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85171. */
  85172. start(delay?: number): void;
  85173. /**
  85174. * Stops the particle system.
  85175. * @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.
  85176. */
  85177. stop(stopSubEmitters?: boolean): void;
  85178. /**
  85179. * Remove all active particles
  85180. */
  85181. reset(): void;
  85182. /**
  85183. * @hidden (for internal use only)
  85184. */
  85185. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85186. /**
  85187. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85188. * Its lifetime will start back at 0.
  85189. */
  85190. recycleParticle: (particle: Particle) => void;
  85191. private _stopSubEmitters;
  85192. private _createParticle;
  85193. private _removeFromRoot;
  85194. private _emitFromParticle;
  85195. private _update;
  85196. /** @hidden */
  85197. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85198. /** @hidden */
  85199. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85200. /** @hidden */
  85201. private _getEffect;
  85202. /**
  85203. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85204. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85205. */
  85206. animate(preWarmOnly?: boolean): void;
  85207. private _appendParticleVertices;
  85208. /**
  85209. * Rebuilds the particle system.
  85210. */
  85211. rebuild(): void;
  85212. /**
  85213. * Is this system ready to be used/rendered
  85214. * @return true if the system is ready
  85215. */
  85216. isReady(): boolean;
  85217. private _render;
  85218. /**
  85219. * Renders the particle system in its current state.
  85220. * @returns the current number of particles
  85221. */
  85222. render(): number;
  85223. /**
  85224. * Disposes the particle system and free the associated resources
  85225. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85226. */
  85227. dispose(disposeTexture?: boolean): void;
  85228. /**
  85229. * Clones the particle system.
  85230. * @param name The name of the cloned object
  85231. * @param newEmitter The new emitter to use
  85232. * @returns the cloned particle system
  85233. */
  85234. clone(name: string, newEmitter: any): ParticleSystem;
  85235. /**
  85236. * Serializes the particle system to a JSON object.
  85237. * @returns the JSON object
  85238. */
  85239. serialize(): any;
  85240. /** @hidden */
  85241. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85242. /** @hidden */
  85243. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85244. /**
  85245. * Parses a JSON object to create a particle system.
  85246. * @param parsedParticleSystem The JSON object to parse
  85247. * @param scene The scene to create the particle system in
  85248. * @param rootUrl The root url to use to load external dependencies like texture
  85249. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85250. * @returns the Parsed particle system
  85251. */
  85252. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85253. }
  85254. }
  85255. declare module BABYLON {
  85256. /**
  85257. * A particle represents one of the element emitted by a particle system.
  85258. * This is mainly define by its coordinates, direction, velocity and age.
  85259. */
  85260. export class Particle {
  85261. /**
  85262. * The particle system the particle belongs to.
  85263. */
  85264. particleSystem: ParticleSystem;
  85265. private static _Count;
  85266. /**
  85267. * Unique ID of the particle
  85268. */
  85269. id: number;
  85270. /**
  85271. * The world position of the particle in the scene.
  85272. */
  85273. position: Vector3;
  85274. /**
  85275. * The world direction of the particle in the scene.
  85276. */
  85277. direction: Vector3;
  85278. /**
  85279. * The color of the particle.
  85280. */
  85281. color: Color4;
  85282. /**
  85283. * The color change of the particle per step.
  85284. */
  85285. colorStep: Color4;
  85286. /**
  85287. * Defines how long will the life of the particle be.
  85288. */
  85289. lifeTime: number;
  85290. /**
  85291. * The current age of the particle.
  85292. */
  85293. age: number;
  85294. /**
  85295. * The current size of the particle.
  85296. */
  85297. size: number;
  85298. /**
  85299. * The current scale of the particle.
  85300. */
  85301. scale: Vector2;
  85302. /**
  85303. * The current angle of the particle.
  85304. */
  85305. angle: number;
  85306. /**
  85307. * Defines how fast is the angle changing.
  85308. */
  85309. angularSpeed: number;
  85310. /**
  85311. * Defines the cell index used by the particle to be rendered from a sprite.
  85312. */
  85313. cellIndex: number;
  85314. /**
  85315. * The information required to support color remapping
  85316. */
  85317. remapData: Vector4;
  85318. /** @hidden */
  85319. _randomCellOffset?: number;
  85320. /** @hidden */
  85321. _initialDirection: Nullable<Vector3>;
  85322. /** @hidden */
  85323. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85324. /** @hidden */
  85325. _initialStartSpriteCellID: number;
  85326. /** @hidden */
  85327. _initialEndSpriteCellID: number;
  85328. /** @hidden */
  85329. _currentColorGradient: Nullable<ColorGradient>;
  85330. /** @hidden */
  85331. _currentColor1: Color4;
  85332. /** @hidden */
  85333. _currentColor2: Color4;
  85334. /** @hidden */
  85335. _currentSizeGradient: Nullable<FactorGradient>;
  85336. /** @hidden */
  85337. _currentSize1: number;
  85338. /** @hidden */
  85339. _currentSize2: number;
  85340. /** @hidden */
  85341. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85342. /** @hidden */
  85343. _currentAngularSpeed1: number;
  85344. /** @hidden */
  85345. _currentAngularSpeed2: number;
  85346. /** @hidden */
  85347. _currentVelocityGradient: Nullable<FactorGradient>;
  85348. /** @hidden */
  85349. _currentVelocity1: number;
  85350. /** @hidden */
  85351. _currentVelocity2: number;
  85352. /** @hidden */
  85353. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85354. /** @hidden */
  85355. _currentLimitVelocity1: number;
  85356. /** @hidden */
  85357. _currentLimitVelocity2: number;
  85358. /** @hidden */
  85359. _currentDragGradient: Nullable<FactorGradient>;
  85360. /** @hidden */
  85361. _currentDrag1: number;
  85362. /** @hidden */
  85363. _currentDrag2: number;
  85364. /** @hidden */
  85365. _randomNoiseCoordinates1: Vector3;
  85366. /** @hidden */
  85367. _randomNoiseCoordinates2: Vector3;
  85368. /**
  85369. * Creates a new instance Particle
  85370. * @param particleSystem the particle system the particle belongs to
  85371. */
  85372. constructor(
  85373. /**
  85374. * The particle system the particle belongs to.
  85375. */
  85376. particleSystem: ParticleSystem);
  85377. private updateCellInfoFromSystem;
  85378. /**
  85379. * Defines how the sprite cell index is updated for the particle
  85380. */
  85381. updateCellIndex(): void;
  85382. /** @hidden */
  85383. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85384. /** @hidden */
  85385. _inheritParticleInfoToSubEmitters(): void;
  85386. /** @hidden */
  85387. _reset(): void;
  85388. /**
  85389. * Copy the properties of particle to another one.
  85390. * @param other the particle to copy the information to.
  85391. */
  85392. copyTo(other: Particle): void;
  85393. }
  85394. }
  85395. declare module BABYLON {
  85396. /**
  85397. * Particle emitter represents a volume emitting particles.
  85398. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85399. */
  85400. export interface IParticleEmitterType {
  85401. /**
  85402. * Called by the particle System when the direction is computed for the created particle.
  85403. * @param worldMatrix is the world matrix of the particle system
  85404. * @param directionToUpdate is the direction vector to update with the result
  85405. * @param particle is the particle we are computed the direction for
  85406. */
  85407. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85408. /**
  85409. * Called by the particle System when the position is computed for the created particle.
  85410. * @param worldMatrix is the world matrix of the particle system
  85411. * @param positionToUpdate is the position vector to update with the result
  85412. * @param particle is the particle we are computed the position for
  85413. */
  85414. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85415. /**
  85416. * Clones the current emitter and returns a copy of it
  85417. * @returns the new emitter
  85418. */
  85419. clone(): IParticleEmitterType;
  85420. /**
  85421. * Called by the GPUParticleSystem to setup the update shader
  85422. * @param effect defines the update shader
  85423. */
  85424. applyToShader(effect: Effect): void;
  85425. /**
  85426. * Returns a string to use to update the GPU particles update shader
  85427. * @returns the effect defines string
  85428. */
  85429. getEffectDefines(): string;
  85430. /**
  85431. * Returns a string representing the class name
  85432. * @returns a string containing the class name
  85433. */
  85434. getClassName(): string;
  85435. /**
  85436. * Serializes the particle system to a JSON object.
  85437. * @returns the JSON object
  85438. */
  85439. serialize(): any;
  85440. /**
  85441. * Parse properties from a JSON object
  85442. * @param serializationObject defines the JSON object
  85443. */
  85444. parse(serializationObject: any): void;
  85445. }
  85446. }
  85447. declare module BABYLON {
  85448. /**
  85449. * Particle emitter emitting particles from the inside of a box.
  85450. * It emits the particles randomly between 2 given directions.
  85451. */
  85452. export class BoxParticleEmitter implements IParticleEmitterType {
  85453. /**
  85454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85455. */
  85456. direction1: Vector3;
  85457. /**
  85458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85459. */
  85460. direction2: Vector3;
  85461. /**
  85462. * 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.
  85463. */
  85464. minEmitBox: Vector3;
  85465. /**
  85466. * 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.
  85467. */
  85468. maxEmitBox: Vector3;
  85469. /**
  85470. * Creates a new instance BoxParticleEmitter
  85471. */
  85472. constructor();
  85473. /**
  85474. * Called by the particle System when the direction is computed for the created particle.
  85475. * @param worldMatrix is the world matrix of the particle system
  85476. * @param directionToUpdate is the direction vector to update with the result
  85477. * @param particle is the particle we are computed the direction for
  85478. */
  85479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85480. /**
  85481. * Called by the particle System when the position is computed for the created particle.
  85482. * @param worldMatrix is the world matrix of the particle system
  85483. * @param positionToUpdate is the position vector to update with the result
  85484. * @param particle is the particle we are computed the position for
  85485. */
  85486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85487. /**
  85488. * Clones the current emitter and returns a copy of it
  85489. * @returns the new emitter
  85490. */
  85491. clone(): BoxParticleEmitter;
  85492. /**
  85493. * Called by the GPUParticleSystem to setup the update shader
  85494. * @param effect defines the update shader
  85495. */
  85496. applyToShader(effect: Effect): void;
  85497. /**
  85498. * Returns a string to use to update the GPU particles update shader
  85499. * @returns a string containng the defines string
  85500. */
  85501. getEffectDefines(): string;
  85502. /**
  85503. * Returns the string "BoxParticleEmitter"
  85504. * @returns a string containing the class name
  85505. */
  85506. getClassName(): string;
  85507. /**
  85508. * Serializes the particle system to a JSON object.
  85509. * @returns the JSON object
  85510. */
  85511. serialize(): any;
  85512. /**
  85513. * Parse properties from a JSON object
  85514. * @param serializationObject defines the JSON object
  85515. */
  85516. parse(serializationObject: any): void;
  85517. }
  85518. }
  85519. declare module BABYLON {
  85520. /**
  85521. * Particle emitter emitting particles from the inside of a cone.
  85522. * It emits the particles alongside the cone volume from the base to the particle.
  85523. * The emission direction might be randomized.
  85524. */
  85525. export class ConeParticleEmitter implements IParticleEmitterType {
  85526. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85527. directionRandomizer: number;
  85528. private _radius;
  85529. private _angle;
  85530. private _height;
  85531. /**
  85532. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85533. */
  85534. radiusRange: number;
  85535. /**
  85536. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85537. */
  85538. heightRange: number;
  85539. /**
  85540. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85541. */
  85542. emitFromSpawnPointOnly: boolean;
  85543. /**
  85544. * Gets or sets the radius of the emission cone
  85545. */
  85546. radius: number;
  85547. /**
  85548. * Gets or sets the angle of the emission cone
  85549. */
  85550. angle: number;
  85551. private _buildHeight;
  85552. /**
  85553. * Creates a new instance ConeParticleEmitter
  85554. * @param radius the radius of the emission cone (1 by default)
  85555. * @param angle the cone base angle (PI by default)
  85556. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85557. */
  85558. constructor(radius?: number, angle?: number,
  85559. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85560. directionRandomizer?: number);
  85561. /**
  85562. * Called by the particle System when the direction is computed for the created particle.
  85563. * @param worldMatrix is the world matrix of the particle system
  85564. * @param directionToUpdate is the direction vector to update with the result
  85565. * @param particle is the particle we are computed the direction for
  85566. */
  85567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85568. /**
  85569. * Called by the particle System when the position is computed for the created particle.
  85570. * @param worldMatrix is the world matrix of the particle system
  85571. * @param positionToUpdate is the position vector to update with the result
  85572. * @param particle is the particle we are computed the position for
  85573. */
  85574. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85575. /**
  85576. * Clones the current emitter and returns a copy of it
  85577. * @returns the new emitter
  85578. */
  85579. clone(): ConeParticleEmitter;
  85580. /**
  85581. * Called by the GPUParticleSystem to setup the update shader
  85582. * @param effect defines the update shader
  85583. */
  85584. applyToShader(effect: Effect): void;
  85585. /**
  85586. * Returns a string to use to update the GPU particles update shader
  85587. * @returns a string containng the defines string
  85588. */
  85589. getEffectDefines(): string;
  85590. /**
  85591. * Returns the string "ConeParticleEmitter"
  85592. * @returns a string containing the class name
  85593. */
  85594. getClassName(): string;
  85595. /**
  85596. * Serializes the particle system to a JSON object.
  85597. * @returns the JSON object
  85598. */
  85599. serialize(): any;
  85600. /**
  85601. * Parse properties from a JSON object
  85602. * @param serializationObject defines the JSON object
  85603. */
  85604. parse(serializationObject: any): void;
  85605. }
  85606. }
  85607. declare module BABYLON {
  85608. /**
  85609. * Particle emitter emitting particles from the inside of a cylinder.
  85610. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85611. */
  85612. export class CylinderParticleEmitter implements IParticleEmitterType {
  85613. /**
  85614. * The radius of the emission cylinder.
  85615. */
  85616. radius: number;
  85617. /**
  85618. * The height of the emission cylinder.
  85619. */
  85620. height: number;
  85621. /**
  85622. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85623. */
  85624. radiusRange: number;
  85625. /**
  85626. * How much to randomize the particle direction [0-1].
  85627. */
  85628. directionRandomizer: number;
  85629. /**
  85630. * Creates a new instance CylinderParticleEmitter
  85631. * @param radius the radius of the emission cylinder (1 by default)
  85632. * @param height the height of the emission cylinder (1 by default)
  85633. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85634. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85635. */
  85636. constructor(
  85637. /**
  85638. * The radius of the emission cylinder.
  85639. */
  85640. radius?: number,
  85641. /**
  85642. * The height of the emission cylinder.
  85643. */
  85644. height?: number,
  85645. /**
  85646. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85647. */
  85648. radiusRange?: number,
  85649. /**
  85650. * How much to randomize the particle direction [0-1].
  85651. */
  85652. directionRandomizer?: number);
  85653. /**
  85654. * Called by the particle System when the direction is computed for the created particle.
  85655. * @param worldMatrix is the world matrix of the particle system
  85656. * @param directionToUpdate is the direction vector to update with the result
  85657. * @param particle is the particle we are computed the direction for
  85658. */
  85659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85660. /**
  85661. * Called by the particle System when the position is computed for the created particle.
  85662. * @param worldMatrix is the world matrix of the particle system
  85663. * @param positionToUpdate is the position vector to update with the result
  85664. * @param particle is the particle we are computed the position for
  85665. */
  85666. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85667. /**
  85668. * Clones the current emitter and returns a copy of it
  85669. * @returns the new emitter
  85670. */
  85671. clone(): CylinderParticleEmitter;
  85672. /**
  85673. * Called by the GPUParticleSystem to setup the update shader
  85674. * @param effect defines the update shader
  85675. */
  85676. applyToShader(effect: Effect): void;
  85677. /**
  85678. * Returns a string to use to update the GPU particles update shader
  85679. * @returns a string containng the defines string
  85680. */
  85681. getEffectDefines(): string;
  85682. /**
  85683. * Returns the string "CylinderParticleEmitter"
  85684. * @returns a string containing the class name
  85685. */
  85686. getClassName(): string;
  85687. /**
  85688. * Serializes the particle system to a JSON object.
  85689. * @returns the JSON object
  85690. */
  85691. serialize(): any;
  85692. /**
  85693. * Parse properties from a JSON object
  85694. * @param serializationObject defines the JSON object
  85695. */
  85696. parse(serializationObject: any): void;
  85697. }
  85698. /**
  85699. * Particle emitter emitting particles from the inside of a cylinder.
  85700. * It emits the particles randomly between two vectors.
  85701. */
  85702. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85703. /**
  85704. * The min limit of the emission direction.
  85705. */
  85706. direction1: Vector3;
  85707. /**
  85708. * The max limit of the emission direction.
  85709. */
  85710. direction2: Vector3;
  85711. /**
  85712. * Creates a new instance CylinderDirectedParticleEmitter
  85713. * @param radius the radius of the emission cylinder (1 by default)
  85714. * @param height the height of the emission cylinder (1 by default)
  85715. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85716. * @param direction1 the min limit of the emission direction (up vector by default)
  85717. * @param direction2 the max limit of the emission direction (up vector by default)
  85718. */
  85719. constructor(radius?: number, height?: number, radiusRange?: number,
  85720. /**
  85721. * The min limit of the emission direction.
  85722. */
  85723. direction1?: Vector3,
  85724. /**
  85725. * The max limit of the emission direction.
  85726. */
  85727. direction2?: Vector3);
  85728. /**
  85729. * Called by the particle System when the direction is computed for the created particle.
  85730. * @param worldMatrix is the world matrix of the particle system
  85731. * @param directionToUpdate is the direction vector to update with the result
  85732. * @param particle is the particle we are computed the direction for
  85733. */
  85734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85735. /**
  85736. * Clones the current emitter and returns a copy of it
  85737. * @returns the new emitter
  85738. */
  85739. clone(): CylinderDirectedParticleEmitter;
  85740. /**
  85741. * Called by the GPUParticleSystem to setup the update shader
  85742. * @param effect defines the update shader
  85743. */
  85744. applyToShader(effect: Effect): void;
  85745. /**
  85746. * Returns a string to use to update the GPU particles update shader
  85747. * @returns a string containng the defines string
  85748. */
  85749. getEffectDefines(): string;
  85750. /**
  85751. * Returns the string "CylinderDirectedParticleEmitter"
  85752. * @returns a string containing the class name
  85753. */
  85754. getClassName(): string;
  85755. /**
  85756. * Serializes the particle system to a JSON object.
  85757. * @returns the JSON object
  85758. */
  85759. serialize(): any;
  85760. /**
  85761. * Parse properties from a JSON object
  85762. * @param serializationObject defines the JSON object
  85763. */
  85764. parse(serializationObject: any): void;
  85765. }
  85766. }
  85767. declare module BABYLON {
  85768. /**
  85769. * Particle emitter emitting particles from the inside of a hemisphere.
  85770. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85771. */
  85772. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85773. /**
  85774. * The radius of the emission hemisphere.
  85775. */
  85776. radius: number;
  85777. /**
  85778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85779. */
  85780. radiusRange: number;
  85781. /**
  85782. * How much to randomize the particle direction [0-1].
  85783. */
  85784. directionRandomizer: number;
  85785. /**
  85786. * Creates a new instance HemisphericParticleEmitter
  85787. * @param radius the radius of the emission hemisphere (1 by default)
  85788. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85790. */
  85791. constructor(
  85792. /**
  85793. * The radius of the emission hemisphere.
  85794. */
  85795. radius?: number,
  85796. /**
  85797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85798. */
  85799. radiusRange?: number,
  85800. /**
  85801. * How much to randomize the particle direction [0-1].
  85802. */
  85803. directionRandomizer?: number);
  85804. /**
  85805. * Called by the particle System when the direction is computed for the created particle.
  85806. * @param worldMatrix is the world matrix of the particle system
  85807. * @param directionToUpdate is the direction vector to update with the result
  85808. * @param particle is the particle we are computed the direction for
  85809. */
  85810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85811. /**
  85812. * Called by the particle System when the position is computed for the created particle.
  85813. * @param worldMatrix is the world matrix of the particle system
  85814. * @param positionToUpdate is the position vector to update with the result
  85815. * @param particle is the particle we are computed the position for
  85816. */
  85817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85818. /**
  85819. * Clones the current emitter and returns a copy of it
  85820. * @returns the new emitter
  85821. */
  85822. clone(): HemisphericParticleEmitter;
  85823. /**
  85824. * Called by the GPUParticleSystem to setup the update shader
  85825. * @param effect defines the update shader
  85826. */
  85827. applyToShader(effect: Effect): void;
  85828. /**
  85829. * Returns a string to use to update the GPU particles update shader
  85830. * @returns a string containng the defines string
  85831. */
  85832. getEffectDefines(): string;
  85833. /**
  85834. * Returns the string "HemisphericParticleEmitter"
  85835. * @returns a string containing the class name
  85836. */
  85837. getClassName(): string;
  85838. /**
  85839. * Serializes the particle system to a JSON object.
  85840. * @returns the JSON object
  85841. */
  85842. serialize(): any;
  85843. /**
  85844. * Parse properties from a JSON object
  85845. * @param serializationObject defines the JSON object
  85846. */
  85847. parse(serializationObject: any): void;
  85848. }
  85849. }
  85850. declare module BABYLON {
  85851. /**
  85852. * Particle emitter emitting particles from a point.
  85853. * It emits the particles randomly between 2 given directions.
  85854. */
  85855. export class PointParticleEmitter implements IParticleEmitterType {
  85856. /**
  85857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85858. */
  85859. direction1: Vector3;
  85860. /**
  85861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85862. */
  85863. direction2: Vector3;
  85864. /**
  85865. * Creates a new instance PointParticleEmitter
  85866. */
  85867. constructor();
  85868. /**
  85869. * Called by the particle System when the direction is computed for the created particle.
  85870. * @param worldMatrix is the world matrix of the particle system
  85871. * @param directionToUpdate is the direction vector to update with the result
  85872. * @param particle is the particle we are computed the direction for
  85873. */
  85874. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85875. /**
  85876. * Called by the particle System when the position is computed for the created particle.
  85877. * @param worldMatrix is the world matrix of the particle system
  85878. * @param positionToUpdate is the position vector to update with the result
  85879. * @param particle is the particle we are computed the position for
  85880. */
  85881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85882. /**
  85883. * Clones the current emitter and returns a copy of it
  85884. * @returns the new emitter
  85885. */
  85886. clone(): PointParticleEmitter;
  85887. /**
  85888. * Called by the GPUParticleSystem to setup the update shader
  85889. * @param effect defines the update shader
  85890. */
  85891. applyToShader(effect: Effect): void;
  85892. /**
  85893. * Returns a string to use to update the GPU particles update shader
  85894. * @returns a string containng the defines string
  85895. */
  85896. getEffectDefines(): string;
  85897. /**
  85898. * Returns the string "PointParticleEmitter"
  85899. * @returns a string containing the class name
  85900. */
  85901. getClassName(): string;
  85902. /**
  85903. * Serializes the particle system to a JSON object.
  85904. * @returns the JSON object
  85905. */
  85906. serialize(): any;
  85907. /**
  85908. * Parse properties from a JSON object
  85909. * @param serializationObject defines the JSON object
  85910. */
  85911. parse(serializationObject: any): void;
  85912. }
  85913. }
  85914. declare module BABYLON {
  85915. /**
  85916. * Particle emitter emitting particles from the inside of a sphere.
  85917. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85918. */
  85919. export class SphereParticleEmitter implements IParticleEmitterType {
  85920. /**
  85921. * The radius of the emission sphere.
  85922. */
  85923. radius: number;
  85924. /**
  85925. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85926. */
  85927. radiusRange: number;
  85928. /**
  85929. * How much to randomize the particle direction [0-1].
  85930. */
  85931. directionRandomizer: number;
  85932. /**
  85933. * Creates a new instance SphereParticleEmitter
  85934. * @param radius the radius of the emission sphere (1 by default)
  85935. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85936. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85937. */
  85938. constructor(
  85939. /**
  85940. * The radius of the emission sphere.
  85941. */
  85942. radius?: number,
  85943. /**
  85944. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85945. */
  85946. radiusRange?: number,
  85947. /**
  85948. * How much to randomize the particle direction [0-1].
  85949. */
  85950. directionRandomizer?: number);
  85951. /**
  85952. * Called by the particle System when the direction is computed for the created particle.
  85953. * @param worldMatrix is the world matrix of the particle system
  85954. * @param directionToUpdate is the direction vector to update with the result
  85955. * @param particle is the particle we are computed the direction for
  85956. */
  85957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85958. /**
  85959. * Called by the particle System when the position is computed for the created particle.
  85960. * @param worldMatrix is the world matrix of the particle system
  85961. * @param positionToUpdate is the position vector to update with the result
  85962. * @param particle is the particle we are computed the position for
  85963. */
  85964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85965. /**
  85966. * Clones the current emitter and returns a copy of it
  85967. * @returns the new emitter
  85968. */
  85969. clone(): SphereParticleEmitter;
  85970. /**
  85971. * Called by the GPUParticleSystem to setup the update shader
  85972. * @param effect defines the update shader
  85973. */
  85974. applyToShader(effect: Effect): void;
  85975. /**
  85976. * Returns a string to use to update the GPU particles update shader
  85977. * @returns a string containng the defines string
  85978. */
  85979. getEffectDefines(): string;
  85980. /**
  85981. * Returns the string "SphereParticleEmitter"
  85982. * @returns a string containing the class name
  85983. */
  85984. getClassName(): string;
  85985. /**
  85986. * Serializes the particle system to a JSON object.
  85987. * @returns the JSON object
  85988. */
  85989. serialize(): any;
  85990. /**
  85991. * Parse properties from a JSON object
  85992. * @param serializationObject defines the JSON object
  85993. */
  85994. parse(serializationObject: any): void;
  85995. }
  85996. /**
  85997. * Particle emitter emitting particles from the inside of a sphere.
  85998. * It emits the particles randomly between two vectors.
  85999. */
  86000. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86001. /**
  86002. * The min limit of the emission direction.
  86003. */
  86004. direction1: Vector3;
  86005. /**
  86006. * The max limit of the emission direction.
  86007. */
  86008. direction2: Vector3;
  86009. /**
  86010. * Creates a new instance SphereDirectedParticleEmitter
  86011. * @param radius the radius of the emission sphere (1 by default)
  86012. * @param direction1 the min limit of the emission direction (up vector by default)
  86013. * @param direction2 the max limit of the emission direction (up vector by default)
  86014. */
  86015. constructor(radius?: number,
  86016. /**
  86017. * The min limit of the emission direction.
  86018. */
  86019. direction1?: Vector3,
  86020. /**
  86021. * The max limit of the emission direction.
  86022. */
  86023. direction2?: Vector3);
  86024. /**
  86025. * Called by the particle System when the direction is computed for the created particle.
  86026. * @param worldMatrix is the world matrix of the particle system
  86027. * @param directionToUpdate is the direction vector to update with the result
  86028. * @param particle is the particle we are computed the direction for
  86029. */
  86030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86031. /**
  86032. * Clones the current emitter and returns a copy of it
  86033. * @returns the new emitter
  86034. */
  86035. clone(): SphereDirectedParticleEmitter;
  86036. /**
  86037. * Called by the GPUParticleSystem to setup the update shader
  86038. * @param effect defines the update shader
  86039. */
  86040. applyToShader(effect: Effect): void;
  86041. /**
  86042. * Returns a string to use to update the GPU particles update shader
  86043. * @returns a string containng the defines string
  86044. */
  86045. getEffectDefines(): string;
  86046. /**
  86047. * Returns the string "SphereDirectedParticleEmitter"
  86048. * @returns a string containing the class name
  86049. */
  86050. getClassName(): string;
  86051. /**
  86052. * Serializes the particle system to a JSON object.
  86053. * @returns the JSON object
  86054. */
  86055. serialize(): any;
  86056. /**
  86057. * Parse properties from a JSON object
  86058. * @param serializationObject defines the JSON object
  86059. */
  86060. parse(serializationObject: any): void;
  86061. }
  86062. }
  86063. declare module BABYLON {
  86064. /**
  86065. * Interface representing a particle system in Babylon.js.
  86066. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86067. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86068. */
  86069. export interface IParticleSystem {
  86070. /**
  86071. * List of animations used by the particle system.
  86072. */
  86073. animations: Animation[];
  86074. /**
  86075. * The id of the Particle system.
  86076. */
  86077. id: string;
  86078. /**
  86079. * The name of the Particle system.
  86080. */
  86081. name: string;
  86082. /**
  86083. * The emitter represents the Mesh or position we are attaching the particle system to.
  86084. */
  86085. emitter: Nullable<AbstractMesh | Vector3>;
  86086. /**
  86087. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86088. */
  86089. isBillboardBased: boolean;
  86090. /**
  86091. * The rendering group used by the Particle system to chose when to render.
  86092. */
  86093. renderingGroupId: number;
  86094. /**
  86095. * The layer mask we are rendering the particles through.
  86096. */
  86097. layerMask: number;
  86098. /**
  86099. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86100. */
  86101. updateSpeed: number;
  86102. /**
  86103. * The amount of time the particle system is running (depends of the overall update speed).
  86104. */
  86105. targetStopDuration: number;
  86106. /**
  86107. * The texture used to render each particle. (this can be a spritesheet)
  86108. */
  86109. particleTexture: Nullable<Texture>;
  86110. /**
  86111. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86112. */
  86113. blendMode: number;
  86114. /**
  86115. * Minimum life time of emitting particles.
  86116. */
  86117. minLifeTime: number;
  86118. /**
  86119. * Maximum life time of emitting particles.
  86120. */
  86121. maxLifeTime: number;
  86122. /**
  86123. * Minimum Size of emitting particles.
  86124. */
  86125. minSize: number;
  86126. /**
  86127. * Maximum Size of emitting particles.
  86128. */
  86129. maxSize: number;
  86130. /**
  86131. * Minimum scale of emitting particles on X axis.
  86132. */
  86133. minScaleX: number;
  86134. /**
  86135. * Maximum scale of emitting particles on X axis.
  86136. */
  86137. maxScaleX: number;
  86138. /**
  86139. * Minimum scale of emitting particles on Y axis.
  86140. */
  86141. minScaleY: number;
  86142. /**
  86143. * Maximum scale of emitting particles on Y axis.
  86144. */
  86145. maxScaleY: number;
  86146. /**
  86147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86148. */
  86149. color1: Color4;
  86150. /**
  86151. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86152. */
  86153. color2: Color4;
  86154. /**
  86155. * Color the particle will have at the end of its lifetime.
  86156. */
  86157. colorDead: Color4;
  86158. /**
  86159. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86160. */
  86161. emitRate: number;
  86162. /**
  86163. * You can use gravity if you want to give an orientation to your particles.
  86164. */
  86165. gravity: Vector3;
  86166. /**
  86167. * Minimum power of emitting particles.
  86168. */
  86169. minEmitPower: number;
  86170. /**
  86171. * Maximum power of emitting particles.
  86172. */
  86173. maxEmitPower: number;
  86174. /**
  86175. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86176. */
  86177. minAngularSpeed: number;
  86178. /**
  86179. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86180. */
  86181. maxAngularSpeed: number;
  86182. /**
  86183. * Gets or sets the minimal initial rotation in radians.
  86184. */
  86185. minInitialRotation: number;
  86186. /**
  86187. * Gets or sets the maximal initial rotation in radians.
  86188. */
  86189. maxInitialRotation: number;
  86190. /**
  86191. * The particle emitter type defines the emitter used by the particle system.
  86192. * It can be for example box, sphere, or cone...
  86193. */
  86194. particleEmitterType: Nullable<IParticleEmitterType>;
  86195. /**
  86196. * Defines the delay in milliseconds before starting the system (0 by default)
  86197. */
  86198. startDelay: number;
  86199. /**
  86200. * 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
  86201. */
  86202. preWarmCycles: number;
  86203. /**
  86204. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86205. */
  86206. preWarmStepOffset: number;
  86207. /**
  86208. * 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)
  86209. */
  86210. spriteCellChangeSpeed: number;
  86211. /**
  86212. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86213. */
  86214. startSpriteCellID: number;
  86215. /**
  86216. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86217. */
  86218. endSpriteCellID: number;
  86219. /**
  86220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86221. */
  86222. spriteCellWidth: number;
  86223. /**
  86224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86225. */
  86226. spriteCellHeight: number;
  86227. /**
  86228. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86229. */
  86230. spriteRandomStartCell: boolean;
  86231. /**
  86232. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86233. */
  86234. isAnimationSheetEnabled: boolean;
  86235. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86236. translationPivot: Vector2;
  86237. /**
  86238. * Gets or sets a texture used to add random noise to particle positions
  86239. */
  86240. noiseTexture: Nullable<BaseTexture>;
  86241. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86242. noiseStrength: Vector3;
  86243. /**
  86244. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86245. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86246. */
  86247. billboardMode: number;
  86248. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86249. limitVelocityDamping: number;
  86250. /**
  86251. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86252. */
  86253. beginAnimationOnStart: boolean;
  86254. /**
  86255. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86256. */
  86257. beginAnimationFrom: number;
  86258. /**
  86259. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86260. */
  86261. beginAnimationTo: number;
  86262. /**
  86263. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86264. */
  86265. beginAnimationLoop: boolean;
  86266. /**
  86267. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86268. */
  86269. disposeOnStop: boolean;
  86270. /**
  86271. * Gets the maximum number of particles active at the same time.
  86272. * @returns The max number of active particles.
  86273. */
  86274. getCapacity(): number;
  86275. /**
  86276. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86277. * @returns True if it has been started, otherwise false.
  86278. */
  86279. isStarted(): boolean;
  86280. /**
  86281. * Animates the particle system for this frame.
  86282. */
  86283. animate(): void;
  86284. /**
  86285. * Renders the particle system in its current state.
  86286. * @returns the current number of particles
  86287. */
  86288. render(): number;
  86289. /**
  86290. * Dispose the particle system and frees its associated resources.
  86291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86292. */
  86293. dispose(disposeTexture?: boolean): void;
  86294. /**
  86295. * Clones the particle system.
  86296. * @param name The name of the cloned object
  86297. * @param newEmitter The new emitter to use
  86298. * @returns the cloned particle system
  86299. */
  86300. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86301. /**
  86302. * Serializes the particle system to a JSON object.
  86303. * @returns the JSON object
  86304. */
  86305. serialize(): any;
  86306. /**
  86307. * Rebuild the particle system
  86308. */
  86309. rebuild(): void;
  86310. /**
  86311. * Starts the particle system and begins to emit
  86312. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86313. */
  86314. start(delay?: number): void;
  86315. /**
  86316. * Stops the particle system.
  86317. */
  86318. stop(): void;
  86319. /**
  86320. * Remove all active particles
  86321. */
  86322. reset(): void;
  86323. /**
  86324. * Is this system ready to be used/rendered
  86325. * @return true if the system is ready
  86326. */
  86327. isReady(): boolean;
  86328. /**
  86329. * Adds a new color gradient
  86330. * @param gradient defines the gradient to use (between 0 and 1)
  86331. * @param color1 defines the color to affect to the specified gradient
  86332. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86333. * @returns the current particle system
  86334. */
  86335. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86336. /**
  86337. * Remove a specific color gradient
  86338. * @param gradient defines the gradient to remove
  86339. * @returns the current particle system
  86340. */
  86341. removeColorGradient(gradient: number): IParticleSystem;
  86342. /**
  86343. * Adds a new size gradient
  86344. * @param gradient defines the gradient to use (between 0 and 1)
  86345. * @param factor defines the size factor to affect to the specified gradient
  86346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86347. * @returns the current particle system
  86348. */
  86349. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86350. /**
  86351. * Remove a specific size gradient
  86352. * @param gradient defines the gradient to remove
  86353. * @returns the current particle system
  86354. */
  86355. removeSizeGradient(gradient: number): IParticleSystem;
  86356. /**
  86357. * Gets the current list of color gradients.
  86358. * You must use addColorGradient and removeColorGradient to udpate this list
  86359. * @returns the list of color gradients
  86360. */
  86361. getColorGradients(): Nullable<Array<ColorGradient>>;
  86362. /**
  86363. * Gets the current list of size gradients.
  86364. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86365. * @returns the list of size gradients
  86366. */
  86367. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86368. /**
  86369. * Gets the current list of angular speed gradients.
  86370. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86371. * @returns the list of angular speed gradients
  86372. */
  86373. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86374. /**
  86375. * Adds a new angular speed gradient
  86376. * @param gradient defines the gradient to use (between 0 and 1)
  86377. * @param factor defines the angular speed to affect to the specified gradient
  86378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86379. * @returns the current particle system
  86380. */
  86381. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86382. /**
  86383. * Remove a specific angular speed gradient
  86384. * @param gradient defines the gradient to remove
  86385. * @returns the current particle system
  86386. */
  86387. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86388. /**
  86389. * Gets the current list of velocity gradients.
  86390. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86391. * @returns the list of velocity gradients
  86392. */
  86393. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86394. /**
  86395. * Adds a new velocity gradient
  86396. * @param gradient defines the gradient to use (between 0 and 1)
  86397. * @param factor defines the velocity to affect to the specified gradient
  86398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86399. * @returns the current particle system
  86400. */
  86401. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86402. /**
  86403. * Remove a specific velocity gradient
  86404. * @param gradient defines the gradient to remove
  86405. * @returns the current particle system
  86406. */
  86407. removeVelocityGradient(gradient: number): IParticleSystem;
  86408. /**
  86409. * Gets the current list of limit velocity gradients.
  86410. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86411. * @returns the list of limit velocity gradients
  86412. */
  86413. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86414. /**
  86415. * Adds a new limit velocity gradient
  86416. * @param gradient defines the gradient to use (between 0 and 1)
  86417. * @param factor defines the limit velocity to affect to the specified gradient
  86418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86419. * @returns the current particle system
  86420. */
  86421. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86422. /**
  86423. * Remove a specific limit velocity gradient
  86424. * @param gradient defines the gradient to remove
  86425. * @returns the current particle system
  86426. */
  86427. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86428. /**
  86429. * Adds a new drag gradient
  86430. * @param gradient defines the gradient to use (between 0 and 1)
  86431. * @param factor defines the drag to affect to the specified gradient
  86432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86433. * @returns the current particle system
  86434. */
  86435. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86436. /**
  86437. * Remove a specific drag gradient
  86438. * @param gradient defines the gradient to remove
  86439. * @returns the current particle system
  86440. */
  86441. removeDragGradient(gradient: number): IParticleSystem;
  86442. /**
  86443. * Gets the current list of drag gradients.
  86444. * You must use addDragGradient and removeDragGradient to udpate this list
  86445. * @returns the list of drag gradients
  86446. */
  86447. getDragGradients(): Nullable<Array<FactorGradient>>;
  86448. /**
  86449. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86450. * @param gradient defines the gradient to use (between 0 and 1)
  86451. * @param factor defines the emit rate to affect to the specified gradient
  86452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86453. * @returns the current particle system
  86454. */
  86455. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86456. /**
  86457. * Remove a specific emit rate gradient
  86458. * @param gradient defines the gradient to remove
  86459. * @returns the current particle system
  86460. */
  86461. removeEmitRateGradient(gradient: number): IParticleSystem;
  86462. /**
  86463. * Gets the current list of emit rate gradients.
  86464. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86465. * @returns the list of emit rate gradients
  86466. */
  86467. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86468. /**
  86469. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86470. * @param gradient defines the gradient to use (between 0 and 1)
  86471. * @param factor defines the start size to affect to the specified gradient
  86472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86473. * @returns the current particle system
  86474. */
  86475. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86476. /**
  86477. * Remove a specific start size gradient
  86478. * @param gradient defines the gradient to remove
  86479. * @returns the current particle system
  86480. */
  86481. removeStartSizeGradient(gradient: number): IParticleSystem;
  86482. /**
  86483. * Gets the current list of start size gradients.
  86484. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86485. * @returns the list of start size gradients
  86486. */
  86487. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86488. /**
  86489. * Adds a new life time gradient
  86490. * @param gradient defines the gradient to use (between 0 and 1)
  86491. * @param factor defines the life time factor to affect to the specified gradient
  86492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86493. * @returns the current particle system
  86494. */
  86495. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86496. /**
  86497. * Remove a specific life time gradient
  86498. * @param gradient defines the gradient to remove
  86499. * @returns the current particle system
  86500. */
  86501. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86502. /**
  86503. * Gets the current list of life time gradients.
  86504. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86505. * @returns the list of life time gradients
  86506. */
  86507. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86508. /**
  86509. * Gets the current list of color gradients.
  86510. * You must use addColorGradient and removeColorGradient to udpate this list
  86511. * @returns the list of color gradients
  86512. */
  86513. getColorGradients(): Nullable<Array<ColorGradient>>;
  86514. /**
  86515. * Adds a new ramp gradient used to remap particle colors
  86516. * @param gradient defines the gradient to use (between 0 and 1)
  86517. * @param color defines the color to affect to the specified gradient
  86518. * @returns the current particle system
  86519. */
  86520. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86521. /**
  86522. * Gets the current list of ramp gradients.
  86523. * You must use addRampGradient and removeRampGradient to udpate this list
  86524. * @returns the list of ramp gradients
  86525. */
  86526. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86527. /** Gets or sets a boolean indicating that ramp gradients must be used
  86528. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86529. */
  86530. useRampGradients: boolean;
  86531. /**
  86532. * Adds a new color remap gradient
  86533. * @param gradient defines the gradient to use (between 0 and 1)
  86534. * @param min defines the color remap minimal range
  86535. * @param max defines the color remap maximal range
  86536. * @returns the current particle system
  86537. */
  86538. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86539. /**
  86540. * Gets the current list of color remap gradients.
  86541. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86542. * @returns the list of color remap gradients
  86543. */
  86544. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86545. /**
  86546. * Adds a new alpha remap gradient
  86547. * @param gradient defines the gradient to use (between 0 and 1)
  86548. * @param min defines the alpha remap minimal range
  86549. * @param max defines the alpha remap maximal range
  86550. * @returns the current particle system
  86551. */
  86552. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86553. /**
  86554. * Gets the current list of alpha remap gradients.
  86555. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86556. * @returns the list of alpha remap gradients
  86557. */
  86558. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86559. /**
  86560. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86563. * @returns the emitter
  86564. */
  86565. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86566. /**
  86567. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86568. * @param radius The radius of the hemisphere to emit from
  86569. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86570. * @returns the emitter
  86571. */
  86572. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86573. /**
  86574. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86575. * @param radius The radius of the sphere to emit from
  86576. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86577. * @returns the emitter
  86578. */
  86579. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86580. /**
  86581. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86582. * @param radius The radius of the sphere to emit from
  86583. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86584. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86585. * @returns the emitter
  86586. */
  86587. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86588. /**
  86589. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86590. * @param radius The radius of the emission cylinder
  86591. * @param height The height of the emission cylinder
  86592. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86593. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86594. * @returns the emitter
  86595. */
  86596. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86597. /**
  86598. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86599. * @param radius The radius of the cylinder to emit from
  86600. * @param height The height of the emission cylinder
  86601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86604. * @returns the emitter
  86605. */
  86606. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86607. /**
  86608. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86609. * @param radius The radius of the cone to emit from
  86610. * @param angle The base angle of the cone
  86611. * @returns the emitter
  86612. */
  86613. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86614. /**
  86615. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86616. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86617. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86618. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86619. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86620. * @returns the emitter
  86621. */
  86622. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86623. /**
  86624. * Get hosting scene
  86625. * @returns the scene
  86626. */
  86627. getScene(): Scene;
  86628. }
  86629. }
  86630. declare module BABYLON {
  86631. /**
  86632. * Creates an instance based on a source mesh.
  86633. */
  86634. export class InstancedMesh extends AbstractMesh {
  86635. private _sourceMesh;
  86636. private _currentLOD;
  86637. /** @hidden */
  86638. _indexInSourceMeshInstanceArray: number;
  86639. constructor(name: string, source: Mesh);
  86640. /**
  86641. * Returns the string "InstancedMesh".
  86642. */
  86643. getClassName(): string;
  86644. /** Gets the list of lights affecting that mesh */
  86645. readonly lightSources: Light[];
  86646. _resyncLightSources(): void;
  86647. _resyncLighSource(light: Light): void;
  86648. _removeLightSource(light: Light, dispose: boolean): void;
  86649. /**
  86650. * If the source mesh receives shadows
  86651. */
  86652. readonly receiveShadows: boolean;
  86653. /**
  86654. * The material of the source mesh
  86655. */
  86656. readonly material: Nullable<Material>;
  86657. /**
  86658. * Visibility of the source mesh
  86659. */
  86660. readonly visibility: number;
  86661. /**
  86662. * Skeleton of the source mesh
  86663. */
  86664. readonly skeleton: Nullable<Skeleton>;
  86665. /**
  86666. * Rendering ground id of the source mesh
  86667. */
  86668. renderingGroupId: number;
  86669. /**
  86670. * Returns the total number of vertices (integer).
  86671. */
  86672. getTotalVertices(): number;
  86673. /**
  86674. * Returns a positive integer : the total number of indices in this mesh geometry.
  86675. * @returns the numner of indices or zero if the mesh has no geometry.
  86676. */
  86677. getTotalIndices(): number;
  86678. /**
  86679. * The source mesh of the instance
  86680. */
  86681. readonly sourceMesh: Mesh;
  86682. /**
  86683. * Is this node ready to be used/rendered
  86684. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86685. * @return {boolean} is it ready
  86686. */
  86687. isReady(completeCheck?: boolean): boolean;
  86688. /**
  86689. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86690. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86691. * @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.
  86692. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86693. */
  86694. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86695. /**
  86696. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86697. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86698. * The `data` are either a numeric array either a Float32Array.
  86699. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86700. * 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).
  86701. * Note that a new underlying VertexBuffer object is created each call.
  86702. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86703. *
  86704. * Possible `kind` values :
  86705. * - VertexBuffer.PositionKind
  86706. * - VertexBuffer.UVKind
  86707. * - VertexBuffer.UV2Kind
  86708. * - VertexBuffer.UV3Kind
  86709. * - VertexBuffer.UV4Kind
  86710. * - VertexBuffer.UV5Kind
  86711. * - VertexBuffer.UV6Kind
  86712. * - VertexBuffer.ColorKind
  86713. * - VertexBuffer.MatricesIndicesKind
  86714. * - VertexBuffer.MatricesIndicesExtraKind
  86715. * - VertexBuffer.MatricesWeightsKind
  86716. * - VertexBuffer.MatricesWeightsExtraKind
  86717. *
  86718. * Returns the Mesh.
  86719. */
  86720. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86721. /**
  86722. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86723. * If the mesh has no geometry, it is simply returned as it is.
  86724. * The `data` are either a numeric array either a Float32Array.
  86725. * No new underlying VertexBuffer object is created.
  86726. * 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.
  86727. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86728. *
  86729. * Possible `kind` values :
  86730. * - VertexBuffer.PositionKind
  86731. * - VertexBuffer.UVKind
  86732. * - VertexBuffer.UV2Kind
  86733. * - VertexBuffer.UV3Kind
  86734. * - VertexBuffer.UV4Kind
  86735. * - VertexBuffer.UV5Kind
  86736. * - VertexBuffer.UV6Kind
  86737. * - VertexBuffer.ColorKind
  86738. * - VertexBuffer.MatricesIndicesKind
  86739. * - VertexBuffer.MatricesIndicesExtraKind
  86740. * - VertexBuffer.MatricesWeightsKind
  86741. * - VertexBuffer.MatricesWeightsExtraKind
  86742. *
  86743. * Returns the Mesh.
  86744. */
  86745. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86746. /**
  86747. * Sets the mesh indices.
  86748. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86749. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86750. * This method creates a new index buffer each call.
  86751. * Returns the Mesh.
  86752. */
  86753. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86754. /**
  86755. * Boolean : True if the mesh owns the requested kind of data.
  86756. */
  86757. isVerticesDataPresent(kind: string): boolean;
  86758. /**
  86759. * Returns an array of indices (IndicesArray).
  86760. */
  86761. getIndices(): Nullable<IndicesArray>;
  86762. readonly _positions: Nullable<Vector3[]>;
  86763. /**
  86764. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86765. * This means the mesh underlying bounding box and sphere are recomputed.
  86766. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86767. * @returns the current mesh
  86768. */
  86769. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86770. /** @hidden */
  86771. _preActivate(): InstancedMesh;
  86772. /** @hidden */
  86773. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86774. /** @hidden */
  86775. _postActivate(): void;
  86776. getWorldMatrix(): Matrix;
  86777. readonly isAnInstance: boolean;
  86778. /**
  86779. * Returns the current associated LOD AbstractMesh.
  86780. */
  86781. getLOD(camera: Camera): AbstractMesh;
  86782. /** @hidden */
  86783. _syncSubMeshes(): InstancedMesh;
  86784. /** @hidden */
  86785. _generatePointsArray(): boolean;
  86786. /**
  86787. * Creates a new InstancedMesh from the current mesh.
  86788. * - name (string) : the cloned mesh name
  86789. * - newParent (optional Node) : the optional Node to parent the clone to.
  86790. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86791. *
  86792. * Returns the clone.
  86793. */
  86794. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86795. /**
  86796. * Disposes the InstancedMesh.
  86797. * Returns nothing.
  86798. */
  86799. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86800. }
  86801. interface Mesh {
  86802. /**
  86803. * Register a custom buffer that will be instanced
  86804. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86805. * @param kind defines the buffer kind
  86806. * @param stride defines the stride in floats
  86807. */
  86808. registerInstancedBuffer(kind: string, stride: number): void;
  86809. /** @hidden */
  86810. _userInstancedBuffersStorage: {
  86811. data: {
  86812. [key: string]: Float32Array;
  86813. };
  86814. sizes: {
  86815. [key: string]: number;
  86816. };
  86817. vertexBuffers: {
  86818. [key: string]: Nullable<VertexBuffer>;
  86819. };
  86820. strides: {
  86821. [key: string]: number;
  86822. };
  86823. };
  86824. }
  86825. interface AbstractMesh {
  86826. /**
  86827. * Object used to store instanced buffers defined by user
  86828. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86829. */
  86830. instancedBuffers: {
  86831. [key: string]: any;
  86832. };
  86833. }
  86834. }
  86835. declare module BABYLON {
  86836. /**
  86837. * Defines the options associated with the creation of a shader material.
  86838. */
  86839. export interface IShaderMaterialOptions {
  86840. /**
  86841. * Does the material work in alpha blend mode
  86842. */
  86843. needAlphaBlending: boolean;
  86844. /**
  86845. * Does the material work in alpha test mode
  86846. */
  86847. needAlphaTesting: boolean;
  86848. /**
  86849. * The list of attribute names used in the shader
  86850. */
  86851. attributes: string[];
  86852. /**
  86853. * The list of unifrom names used in the shader
  86854. */
  86855. uniforms: string[];
  86856. /**
  86857. * The list of UBO names used in the shader
  86858. */
  86859. uniformBuffers: string[];
  86860. /**
  86861. * The list of sampler names used in the shader
  86862. */
  86863. samplers: string[];
  86864. /**
  86865. * The list of defines used in the shader
  86866. */
  86867. defines: string[];
  86868. }
  86869. /**
  86870. * 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.
  86871. *
  86872. * This returned material effects how the mesh will look based on the code in the shaders.
  86873. *
  86874. * @see http://doc.babylonjs.com/how_to/shader_material
  86875. */
  86876. export class ShaderMaterial extends Material {
  86877. private _shaderPath;
  86878. private _options;
  86879. private _textures;
  86880. private _textureArrays;
  86881. private _floats;
  86882. private _ints;
  86883. private _floatsArrays;
  86884. private _colors3;
  86885. private _colors3Arrays;
  86886. private _colors4;
  86887. private _colors4Arrays;
  86888. private _vectors2;
  86889. private _vectors3;
  86890. private _vectors4;
  86891. private _matrices;
  86892. private _matrices3x3;
  86893. private _matrices2x2;
  86894. private _vectors2Arrays;
  86895. private _vectors3Arrays;
  86896. private _vectors4Arrays;
  86897. private _cachedWorldViewMatrix;
  86898. private _cachedWorldViewProjectionMatrix;
  86899. private _renderId;
  86900. /**
  86901. * Instantiate a new shader material.
  86902. * 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.
  86903. * This returned material effects how the mesh will look based on the code in the shaders.
  86904. * @see http://doc.babylonjs.com/how_to/shader_material
  86905. * @param name Define the name of the material in the scene
  86906. * @param scene Define the scene the material belongs to
  86907. * @param shaderPath Defines the route to the shader code in one of three ways:
  86908. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86909. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86910. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86911. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86912. * @param options Define the options used to create the shader
  86913. */
  86914. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86915. /**
  86916. * Gets the options used to compile the shader.
  86917. * They can be modified to trigger a new compilation
  86918. */
  86919. readonly options: IShaderMaterialOptions;
  86920. /**
  86921. * Gets the current class name of the material e.g. "ShaderMaterial"
  86922. * Mainly use in serialization.
  86923. * @returns the class name
  86924. */
  86925. getClassName(): string;
  86926. /**
  86927. * Specifies if the material will require alpha blending
  86928. * @returns a boolean specifying if alpha blending is needed
  86929. */
  86930. needAlphaBlending(): boolean;
  86931. /**
  86932. * Specifies if this material should be rendered in alpha test mode
  86933. * @returns a boolean specifying if an alpha test is needed.
  86934. */
  86935. needAlphaTesting(): boolean;
  86936. private _checkUniform;
  86937. /**
  86938. * Set a texture in the shader.
  86939. * @param name Define the name of the uniform samplers as defined in the shader
  86940. * @param texture Define the texture to bind to this sampler
  86941. * @return the material itself allowing "fluent" like uniform updates
  86942. */
  86943. setTexture(name: string, texture: Texture): ShaderMaterial;
  86944. /**
  86945. * Set a texture array in the shader.
  86946. * @param name Define the name of the uniform sampler array as defined in the shader
  86947. * @param textures Define the list of textures to bind to this sampler
  86948. * @return the material itself allowing "fluent" like uniform updates
  86949. */
  86950. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86951. /**
  86952. * Set a float in the shader.
  86953. * @param name Define the name of the uniform as defined in the shader
  86954. * @param value Define the value to give to the uniform
  86955. * @return the material itself allowing "fluent" like uniform updates
  86956. */
  86957. setFloat(name: string, value: number): ShaderMaterial;
  86958. /**
  86959. * Set a int in the shader.
  86960. * @param name Define the name of the uniform as defined in the shader
  86961. * @param value Define the value to give to the uniform
  86962. * @return the material itself allowing "fluent" like uniform updates
  86963. */
  86964. setInt(name: string, value: number): ShaderMaterial;
  86965. /**
  86966. * Set an array of floats in the shader.
  86967. * @param name Define the name of the uniform as defined in the shader
  86968. * @param value Define the value to give to the uniform
  86969. * @return the material itself allowing "fluent" like uniform updates
  86970. */
  86971. setFloats(name: string, value: number[]): ShaderMaterial;
  86972. /**
  86973. * Set a vec3 in the shader from a Color3.
  86974. * @param name Define the name of the uniform as defined in the shader
  86975. * @param value Define the value to give to the uniform
  86976. * @return the material itself allowing "fluent" like uniform updates
  86977. */
  86978. setColor3(name: string, value: Color3): ShaderMaterial;
  86979. /**
  86980. * Set a vec3 array in the shader from a Color3 array.
  86981. * @param name Define the name of the uniform as defined in the shader
  86982. * @param value Define the value to give to the uniform
  86983. * @return the material itself allowing "fluent" like uniform updates
  86984. */
  86985. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86986. /**
  86987. * Set a vec4 in the shader from a Color4.
  86988. * @param name Define the name of the uniform as defined in the shader
  86989. * @param value Define the value to give to the uniform
  86990. * @return the material itself allowing "fluent" like uniform updates
  86991. */
  86992. setColor4(name: string, value: Color4): ShaderMaterial;
  86993. /**
  86994. * Set a vec4 array in the shader from a Color4 array.
  86995. * @param name Define the name of the uniform as defined in the shader
  86996. * @param value Define the value to give to the uniform
  86997. * @return the material itself allowing "fluent" like uniform updates
  86998. */
  86999. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87000. /**
  87001. * Set a vec2 in the shader from a Vector2.
  87002. * @param name Define the name of the uniform as defined in the shader
  87003. * @param value Define the value to give to the uniform
  87004. * @return the material itself allowing "fluent" like uniform updates
  87005. */
  87006. setVector2(name: string, value: Vector2): ShaderMaterial;
  87007. /**
  87008. * Set a vec3 in the shader from a Vector3.
  87009. * @param name Define the name of the uniform as defined in the shader
  87010. * @param value Define the value to give to the uniform
  87011. * @return the material itself allowing "fluent" like uniform updates
  87012. */
  87013. setVector3(name: string, value: Vector3): ShaderMaterial;
  87014. /**
  87015. * Set a vec4 in the shader from a Vector4.
  87016. * @param name Define the name of the uniform as defined in the shader
  87017. * @param value Define the value to give to the uniform
  87018. * @return the material itself allowing "fluent" like uniform updates
  87019. */
  87020. setVector4(name: string, value: Vector4): ShaderMaterial;
  87021. /**
  87022. * Set a mat4 in the shader from a Matrix.
  87023. * @param name Define the name of the uniform as defined in the shader
  87024. * @param value Define the value to give to the uniform
  87025. * @return the material itself allowing "fluent" like uniform updates
  87026. */
  87027. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87028. /**
  87029. * Set a mat3 in the shader from a Float32Array.
  87030. * @param name Define the name of the uniform as defined in the shader
  87031. * @param value Define the value to give to the uniform
  87032. * @return the material itself allowing "fluent" like uniform updates
  87033. */
  87034. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87035. /**
  87036. * Set a mat2 in the shader from a Float32Array.
  87037. * @param name Define the name of the uniform as defined in the shader
  87038. * @param value Define the value to give to the uniform
  87039. * @return the material itself allowing "fluent" like uniform updates
  87040. */
  87041. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87042. /**
  87043. * Set a vec2 array in the shader from a number array.
  87044. * @param name Define the name of the uniform as defined in the shader
  87045. * @param value Define the value to give to the uniform
  87046. * @return the material itself allowing "fluent" like uniform updates
  87047. */
  87048. setArray2(name: string, value: number[]): ShaderMaterial;
  87049. /**
  87050. * Set a vec3 array in the shader from a number array.
  87051. * @param name Define the name of the uniform as defined in the shader
  87052. * @param value Define the value to give to the uniform
  87053. * @return the material itself allowing "fluent" like uniform updates
  87054. */
  87055. setArray3(name: string, value: number[]): ShaderMaterial;
  87056. /**
  87057. * Set a vec4 array in the shader from a number array.
  87058. * @param name Define the name of the uniform as defined in the shader
  87059. * @param value Define the value to give to the uniform
  87060. * @return the material itself allowing "fluent" like uniform updates
  87061. */
  87062. setArray4(name: string, value: number[]): ShaderMaterial;
  87063. private _checkCache;
  87064. /**
  87065. * Specifies that the submesh is ready to be used
  87066. * @param mesh defines the mesh to check
  87067. * @param subMesh defines which submesh to check
  87068. * @param useInstances specifies that instances should be used
  87069. * @returns a boolean indicating that the submesh is ready or not
  87070. */
  87071. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87072. /**
  87073. * Checks if the material is ready to render the requested mesh
  87074. * @param mesh Define the mesh to render
  87075. * @param useInstances Define whether or not the material is used with instances
  87076. * @returns true if ready, otherwise false
  87077. */
  87078. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87079. /**
  87080. * Binds the world matrix to the material
  87081. * @param world defines the world transformation matrix
  87082. */
  87083. bindOnlyWorldMatrix(world: Matrix): void;
  87084. /**
  87085. * Binds the material to the mesh
  87086. * @param world defines the world transformation matrix
  87087. * @param mesh defines the mesh to bind the material to
  87088. */
  87089. bind(world: Matrix, mesh?: Mesh): void;
  87090. /**
  87091. * Gets the active textures from the material
  87092. * @returns an array of textures
  87093. */
  87094. getActiveTextures(): BaseTexture[];
  87095. /**
  87096. * Specifies if the material uses a texture
  87097. * @param texture defines the texture to check against the material
  87098. * @returns a boolean specifying if the material uses the texture
  87099. */
  87100. hasTexture(texture: BaseTexture): boolean;
  87101. /**
  87102. * Makes a duplicate of the material, and gives it a new name
  87103. * @param name defines the new name for the duplicated material
  87104. * @returns the cloned material
  87105. */
  87106. clone(name: string): ShaderMaterial;
  87107. /**
  87108. * Disposes the material
  87109. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87110. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87111. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87112. */
  87113. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87114. /**
  87115. * Serializes this material in a JSON representation
  87116. * @returns the serialized material object
  87117. */
  87118. serialize(): any;
  87119. /**
  87120. * Creates a shader material from parsed shader material data
  87121. * @param source defines the JSON represnetation of the material
  87122. * @param scene defines the hosting scene
  87123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87124. * @returns a new material
  87125. */
  87126. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87127. }
  87128. }
  87129. declare module BABYLON {
  87130. /** @hidden */
  87131. export var colorPixelShader: {
  87132. name: string;
  87133. shader: string;
  87134. };
  87135. }
  87136. declare module BABYLON {
  87137. /** @hidden */
  87138. export var colorVertexShader: {
  87139. name: string;
  87140. shader: string;
  87141. };
  87142. }
  87143. declare module BABYLON {
  87144. /**
  87145. * Line mesh
  87146. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87147. */
  87148. export class LinesMesh extends Mesh {
  87149. /**
  87150. * If vertex color should be applied to the mesh
  87151. */
  87152. readonly useVertexColor?: boolean | undefined;
  87153. /**
  87154. * If vertex alpha should be applied to the mesh
  87155. */
  87156. readonly useVertexAlpha?: boolean | undefined;
  87157. /**
  87158. * Color of the line (Default: White)
  87159. */
  87160. color: Color3;
  87161. /**
  87162. * Alpha of the line (Default: 1)
  87163. */
  87164. alpha: number;
  87165. /**
  87166. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87167. * This margin is expressed in world space coordinates, so its value may vary.
  87168. * Default value is 0.1
  87169. */
  87170. intersectionThreshold: number;
  87171. private _colorShader;
  87172. private color4;
  87173. /**
  87174. * Creates a new LinesMesh
  87175. * @param name defines the name
  87176. * @param scene defines the hosting scene
  87177. * @param parent defines the parent mesh if any
  87178. * @param source defines the optional source LinesMesh used to clone data from
  87179. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87180. * When false, achieved by calling a clone(), also passing False.
  87181. * This will make creation of children, recursive.
  87182. * @param useVertexColor defines if this LinesMesh supports vertex color
  87183. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87184. */
  87185. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87186. /**
  87187. * If vertex color should be applied to the mesh
  87188. */
  87189. useVertexColor?: boolean | undefined,
  87190. /**
  87191. * If vertex alpha should be applied to the mesh
  87192. */
  87193. useVertexAlpha?: boolean | undefined);
  87194. private _addClipPlaneDefine;
  87195. private _removeClipPlaneDefine;
  87196. isReady(): boolean;
  87197. /**
  87198. * Returns the string "LineMesh"
  87199. */
  87200. getClassName(): string;
  87201. /**
  87202. * @hidden
  87203. */
  87204. /**
  87205. * @hidden
  87206. */
  87207. material: Material;
  87208. /**
  87209. * @hidden
  87210. */
  87211. readonly checkCollisions: boolean;
  87212. /** @hidden */
  87213. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87214. /** @hidden */
  87215. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87216. /**
  87217. * Disposes of the line mesh
  87218. * @param doNotRecurse If children should be disposed
  87219. */
  87220. dispose(doNotRecurse?: boolean): void;
  87221. /**
  87222. * Returns a new LineMesh object cloned from the current one.
  87223. */
  87224. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87225. /**
  87226. * Creates a new InstancedLinesMesh object from the mesh model.
  87227. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87228. * @param name defines the name of the new instance
  87229. * @returns a new InstancedLinesMesh
  87230. */
  87231. createInstance(name: string): InstancedLinesMesh;
  87232. }
  87233. /**
  87234. * Creates an instance based on a source LinesMesh
  87235. */
  87236. export class InstancedLinesMesh extends InstancedMesh {
  87237. /**
  87238. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87239. * This margin is expressed in world space coordinates, so its value may vary.
  87240. * Initilized with the intersectionThreshold value of the source LinesMesh
  87241. */
  87242. intersectionThreshold: number;
  87243. constructor(name: string, source: LinesMesh);
  87244. /**
  87245. * Returns the string "InstancedLinesMesh".
  87246. */
  87247. getClassName(): string;
  87248. }
  87249. }
  87250. declare module BABYLON {
  87251. /** @hidden */
  87252. export var linePixelShader: {
  87253. name: string;
  87254. shader: string;
  87255. };
  87256. }
  87257. declare module BABYLON {
  87258. /** @hidden */
  87259. export var lineVertexShader: {
  87260. name: string;
  87261. shader: string;
  87262. };
  87263. }
  87264. declare module BABYLON {
  87265. interface AbstractMesh {
  87266. /**
  87267. * Gets the edgesRenderer associated with the mesh
  87268. */
  87269. edgesRenderer: Nullable<EdgesRenderer>;
  87270. }
  87271. interface LinesMesh {
  87272. /**
  87273. * Enables the edge rendering mode on the mesh.
  87274. * This mode makes the mesh edges visible
  87275. * @param epsilon defines the maximal distance between two angles to detect a face
  87276. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87277. * @returns the currentAbstractMesh
  87278. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87279. */
  87280. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87281. }
  87282. interface InstancedLinesMesh {
  87283. /**
  87284. * Enables the edge rendering mode on the mesh.
  87285. * This mode makes the mesh edges visible
  87286. * @param epsilon defines the maximal distance between two angles to detect a face
  87287. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87288. * @returns the current InstancedLinesMesh
  87289. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87290. */
  87291. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87292. }
  87293. /**
  87294. * Defines the minimum contract an Edges renderer should follow.
  87295. */
  87296. export interface IEdgesRenderer extends IDisposable {
  87297. /**
  87298. * Gets or sets a boolean indicating if the edgesRenderer is active
  87299. */
  87300. isEnabled: boolean;
  87301. /**
  87302. * Renders the edges of the attached mesh,
  87303. */
  87304. render(): void;
  87305. /**
  87306. * Checks wether or not the edges renderer is ready to render.
  87307. * @return true if ready, otherwise false.
  87308. */
  87309. isReady(): boolean;
  87310. }
  87311. /**
  87312. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87313. */
  87314. export class EdgesRenderer implements IEdgesRenderer {
  87315. /**
  87316. * Define the size of the edges with an orthographic camera
  87317. */
  87318. edgesWidthScalerForOrthographic: number;
  87319. /**
  87320. * Define the size of the edges with a perspective camera
  87321. */
  87322. edgesWidthScalerForPerspective: number;
  87323. protected _source: AbstractMesh;
  87324. protected _linesPositions: number[];
  87325. protected _linesNormals: number[];
  87326. protected _linesIndices: number[];
  87327. protected _epsilon: number;
  87328. protected _indicesCount: number;
  87329. protected _lineShader: ShaderMaterial;
  87330. protected _ib: DataBuffer;
  87331. protected _buffers: {
  87332. [key: string]: Nullable<VertexBuffer>;
  87333. };
  87334. protected _checkVerticesInsteadOfIndices: boolean;
  87335. private _meshRebuildObserver;
  87336. private _meshDisposeObserver;
  87337. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87338. isEnabled: boolean;
  87339. /**
  87340. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87341. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87342. * @param source Mesh used to create edges
  87343. * @param epsilon sum of angles in adjacency to check for edge
  87344. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87345. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87346. */
  87347. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87348. protected _prepareRessources(): void;
  87349. /** @hidden */
  87350. _rebuild(): void;
  87351. /**
  87352. * Releases the required resources for the edges renderer
  87353. */
  87354. dispose(): void;
  87355. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87356. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87357. /**
  87358. * Checks if the pair of p0 and p1 is en edge
  87359. * @param faceIndex
  87360. * @param edge
  87361. * @param faceNormals
  87362. * @param p0
  87363. * @param p1
  87364. * @private
  87365. */
  87366. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87367. /**
  87368. * push line into the position, normal and index buffer
  87369. * @protected
  87370. */
  87371. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87372. /**
  87373. * Generates lines edges from adjacencjes
  87374. * @private
  87375. */
  87376. _generateEdgesLines(): void;
  87377. /**
  87378. * Checks wether or not the edges renderer is ready to render.
  87379. * @return true if ready, otherwise false.
  87380. */
  87381. isReady(): boolean;
  87382. /**
  87383. * Renders the edges of the attached mesh,
  87384. */
  87385. render(): void;
  87386. }
  87387. /**
  87388. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87389. */
  87390. export class LineEdgesRenderer extends EdgesRenderer {
  87391. /**
  87392. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87393. * @param source LineMesh used to generate edges
  87394. * @param epsilon not important (specified angle for edge detection)
  87395. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87396. */
  87397. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87398. /**
  87399. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87400. */
  87401. _generateEdgesLines(): void;
  87402. }
  87403. }
  87404. declare module BABYLON {
  87405. /**
  87406. * This represents the object necessary to create a rendering group.
  87407. * This is exclusively used and created by the rendering manager.
  87408. * To modify the behavior, you use the available helpers in your scene or meshes.
  87409. * @hidden
  87410. */
  87411. export class RenderingGroup {
  87412. index: number;
  87413. private static _zeroVector;
  87414. private _scene;
  87415. private _opaqueSubMeshes;
  87416. private _transparentSubMeshes;
  87417. private _alphaTestSubMeshes;
  87418. private _depthOnlySubMeshes;
  87419. private _particleSystems;
  87420. private _spriteManagers;
  87421. private _opaqueSortCompareFn;
  87422. private _alphaTestSortCompareFn;
  87423. private _transparentSortCompareFn;
  87424. private _renderOpaque;
  87425. private _renderAlphaTest;
  87426. private _renderTransparent;
  87427. /** @hidden */
  87428. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87429. onBeforeTransparentRendering: () => void;
  87430. /**
  87431. * Set the opaque sort comparison function.
  87432. * If null the sub meshes will be render in the order they were created
  87433. */
  87434. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87435. /**
  87436. * Set the alpha test sort comparison function.
  87437. * If null the sub meshes will be render in the order they were created
  87438. */
  87439. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87440. /**
  87441. * Set the transparent sort comparison function.
  87442. * If null the sub meshes will be render in the order they were created
  87443. */
  87444. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87445. /**
  87446. * Creates a new rendering group.
  87447. * @param index The rendering group index
  87448. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87449. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87450. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87451. */
  87452. 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>);
  87453. /**
  87454. * Render all the sub meshes contained in the group.
  87455. * @param customRenderFunction Used to override the default render behaviour of the group.
  87456. * @returns true if rendered some submeshes.
  87457. */
  87458. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87459. /**
  87460. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87461. * @param subMeshes The submeshes to render
  87462. */
  87463. private renderOpaqueSorted;
  87464. /**
  87465. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87466. * @param subMeshes The submeshes to render
  87467. */
  87468. private renderAlphaTestSorted;
  87469. /**
  87470. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87471. * @param subMeshes The submeshes to render
  87472. */
  87473. private renderTransparentSorted;
  87474. /**
  87475. * Renders the submeshes in a specified order.
  87476. * @param subMeshes The submeshes to sort before render
  87477. * @param sortCompareFn The comparison function use to sort
  87478. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87479. * @param transparent Specifies to activate blending if true
  87480. */
  87481. private static renderSorted;
  87482. /**
  87483. * Renders the submeshes in the order they were dispatched (no sort applied).
  87484. * @param subMeshes The submeshes to render
  87485. */
  87486. private static renderUnsorted;
  87487. /**
  87488. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87489. * are rendered back to front if in the same alpha index.
  87490. *
  87491. * @param a The first submesh
  87492. * @param b The second submesh
  87493. * @returns The result of the comparison
  87494. */
  87495. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87496. /**
  87497. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87498. * are rendered back to front.
  87499. *
  87500. * @param a The first submesh
  87501. * @param b The second submesh
  87502. * @returns The result of the comparison
  87503. */
  87504. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87505. /**
  87506. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87507. * are rendered front to back (prevent overdraw).
  87508. *
  87509. * @param a The first submesh
  87510. * @param b The second submesh
  87511. * @returns The result of the comparison
  87512. */
  87513. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87514. /**
  87515. * Resets the different lists of submeshes to prepare a new frame.
  87516. */
  87517. prepare(): void;
  87518. dispose(): void;
  87519. /**
  87520. * Inserts the submesh in its correct queue depending on its material.
  87521. * @param subMesh The submesh to dispatch
  87522. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87523. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87524. */
  87525. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87526. dispatchSprites(spriteManager: ISpriteManager): void;
  87527. dispatchParticles(particleSystem: IParticleSystem): void;
  87528. private _renderParticles;
  87529. private _renderSprites;
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /**
  87534. * Interface describing the different options available in the rendering manager
  87535. * regarding Auto Clear between groups.
  87536. */
  87537. export interface IRenderingManagerAutoClearSetup {
  87538. /**
  87539. * Defines whether or not autoclear is enable.
  87540. */
  87541. autoClear: boolean;
  87542. /**
  87543. * Defines whether or not to autoclear the depth buffer.
  87544. */
  87545. depth: boolean;
  87546. /**
  87547. * Defines whether or not to autoclear the stencil buffer.
  87548. */
  87549. stencil: boolean;
  87550. }
  87551. /**
  87552. * This class is used by the onRenderingGroupObservable
  87553. */
  87554. export class RenderingGroupInfo {
  87555. /**
  87556. * The Scene that being rendered
  87557. */
  87558. scene: Scene;
  87559. /**
  87560. * The camera currently used for the rendering pass
  87561. */
  87562. camera: Nullable<Camera>;
  87563. /**
  87564. * The ID of the renderingGroup being processed
  87565. */
  87566. renderingGroupId: number;
  87567. }
  87568. /**
  87569. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87570. * It is enable to manage the different groups as well as the different necessary sort functions.
  87571. * This should not be used directly aside of the few static configurations
  87572. */
  87573. export class RenderingManager {
  87574. /**
  87575. * The max id used for rendering groups (not included)
  87576. */
  87577. static MAX_RENDERINGGROUPS: number;
  87578. /**
  87579. * The min id used for rendering groups (included)
  87580. */
  87581. static MIN_RENDERINGGROUPS: number;
  87582. /**
  87583. * Used to globally prevent autoclearing scenes.
  87584. */
  87585. static AUTOCLEAR: boolean;
  87586. /**
  87587. * @hidden
  87588. */
  87589. _useSceneAutoClearSetup: boolean;
  87590. private _scene;
  87591. private _renderingGroups;
  87592. private _depthStencilBufferAlreadyCleaned;
  87593. private _autoClearDepthStencil;
  87594. private _customOpaqueSortCompareFn;
  87595. private _customAlphaTestSortCompareFn;
  87596. private _customTransparentSortCompareFn;
  87597. private _renderingGroupInfo;
  87598. /**
  87599. * Instantiates a new rendering group for a particular scene
  87600. * @param scene Defines the scene the groups belongs to
  87601. */
  87602. constructor(scene: Scene);
  87603. private _clearDepthStencilBuffer;
  87604. /**
  87605. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87606. * @hidden
  87607. */
  87608. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87609. /**
  87610. * Resets the different information of the group to prepare a new frame
  87611. * @hidden
  87612. */
  87613. reset(): void;
  87614. /**
  87615. * Dispose and release the group and its associated resources.
  87616. * @hidden
  87617. */
  87618. dispose(): void;
  87619. /**
  87620. * Clear the info related to rendering groups preventing retention points during dispose.
  87621. */
  87622. freeRenderingGroups(): void;
  87623. private _prepareRenderingGroup;
  87624. /**
  87625. * Add a sprite manager to the rendering manager in order to render it this frame.
  87626. * @param spriteManager Define the sprite manager to render
  87627. */
  87628. dispatchSprites(spriteManager: ISpriteManager): void;
  87629. /**
  87630. * Add a particle system to the rendering manager in order to render it this frame.
  87631. * @param particleSystem Define the particle system to render
  87632. */
  87633. dispatchParticles(particleSystem: IParticleSystem): void;
  87634. /**
  87635. * Add a submesh to the manager in order to render it this frame
  87636. * @param subMesh The submesh to dispatch
  87637. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87638. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87639. */
  87640. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87641. /**
  87642. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87643. * This allowed control for front to back rendering or reversly depending of the special needs.
  87644. *
  87645. * @param renderingGroupId The rendering group id corresponding to its index
  87646. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87647. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87648. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87649. */
  87650. 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;
  87651. /**
  87652. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87653. *
  87654. * @param renderingGroupId The rendering group id corresponding to its index
  87655. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87656. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87657. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87658. */
  87659. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87660. /**
  87661. * Gets the current auto clear configuration for one rendering group of the rendering
  87662. * manager.
  87663. * @param index the rendering group index to get the information for
  87664. * @returns The auto clear setup for the requested rendering group
  87665. */
  87666. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87667. }
  87668. }
  87669. declare module BABYLON {
  87670. /**
  87671. * This Helps creating a texture that will be created from a camera in your scene.
  87672. * It is basically a dynamic texture that could be used to create special effects for instance.
  87673. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87674. */
  87675. export class RenderTargetTexture extends Texture {
  87676. isCube: boolean;
  87677. /**
  87678. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87679. */
  87680. static readonly REFRESHRATE_RENDER_ONCE: number;
  87681. /**
  87682. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87683. */
  87684. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87685. /**
  87686. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87687. * the central point of your effect and can save a lot of performances.
  87688. */
  87689. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87690. /**
  87691. * Use this predicate to dynamically define the list of mesh you want to render.
  87692. * If set, the renderList property will be overwritten.
  87693. */
  87694. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87695. private _renderList;
  87696. /**
  87697. * Use this list to define the list of mesh you want to render.
  87698. */
  87699. renderList: Nullable<Array<AbstractMesh>>;
  87700. private _hookArray;
  87701. /**
  87702. * Define if particles should be rendered in your texture.
  87703. */
  87704. renderParticles: boolean;
  87705. /**
  87706. * Define if sprites should be rendered in your texture.
  87707. */
  87708. renderSprites: boolean;
  87709. /**
  87710. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87711. */
  87712. coordinatesMode: number;
  87713. /**
  87714. * Define the camera used to render the texture.
  87715. */
  87716. activeCamera: Nullable<Camera>;
  87717. /**
  87718. * Override the render function of the texture with your own one.
  87719. */
  87720. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87721. /**
  87722. * Define if camera post processes should be use while rendering the texture.
  87723. */
  87724. useCameraPostProcesses: boolean;
  87725. /**
  87726. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87727. */
  87728. ignoreCameraViewport: boolean;
  87729. private _postProcessManager;
  87730. private _postProcesses;
  87731. private _resizeObserver;
  87732. /**
  87733. * An event triggered when the texture is unbind.
  87734. */
  87735. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87736. /**
  87737. * An event triggered when the texture is unbind.
  87738. */
  87739. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87740. private _onAfterUnbindObserver;
  87741. /**
  87742. * Set a after unbind callback in the texture.
  87743. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87744. */
  87745. onAfterUnbind: () => void;
  87746. /**
  87747. * An event triggered before rendering the texture
  87748. */
  87749. onBeforeRenderObservable: Observable<number>;
  87750. private _onBeforeRenderObserver;
  87751. /**
  87752. * Set a before render callback in the texture.
  87753. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87754. */
  87755. onBeforeRender: (faceIndex: number) => void;
  87756. /**
  87757. * An event triggered after rendering the texture
  87758. */
  87759. onAfterRenderObservable: Observable<number>;
  87760. private _onAfterRenderObserver;
  87761. /**
  87762. * Set a after render callback in the texture.
  87763. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87764. */
  87765. onAfterRender: (faceIndex: number) => void;
  87766. /**
  87767. * An event triggered after the texture clear
  87768. */
  87769. onClearObservable: Observable<Engine>;
  87770. private _onClearObserver;
  87771. /**
  87772. * Set a clear callback in the texture.
  87773. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87774. */
  87775. onClear: (Engine: Engine) => void;
  87776. /**
  87777. * An event triggered when the texture is resized.
  87778. */
  87779. onResizeObservable: Observable<RenderTargetTexture>;
  87780. /**
  87781. * Define the clear color of the Render Target if it should be different from the scene.
  87782. */
  87783. clearColor: Color4;
  87784. protected _size: number | {
  87785. width: number;
  87786. height: number;
  87787. };
  87788. protected _initialSizeParameter: number | {
  87789. width: number;
  87790. height: number;
  87791. } | {
  87792. ratio: number;
  87793. };
  87794. protected _sizeRatio: Nullable<number>;
  87795. /** @hidden */
  87796. _generateMipMaps: boolean;
  87797. protected _renderingManager: RenderingManager;
  87798. /** @hidden */
  87799. _waitingRenderList: string[];
  87800. protected _doNotChangeAspectRatio: boolean;
  87801. protected _currentRefreshId: number;
  87802. protected _refreshRate: number;
  87803. protected _textureMatrix: Matrix;
  87804. protected _samples: number;
  87805. protected _renderTargetOptions: RenderTargetCreationOptions;
  87806. /**
  87807. * Gets render target creation options that were used.
  87808. */
  87809. readonly renderTargetOptions: RenderTargetCreationOptions;
  87810. protected _engine: Engine;
  87811. protected _onRatioRescale(): void;
  87812. /**
  87813. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87814. * It must define where the camera used to render the texture is set
  87815. */
  87816. boundingBoxPosition: Vector3;
  87817. private _boundingBoxSize;
  87818. /**
  87819. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87820. * When defined, the cubemap will switch to local mode
  87821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87822. * @example https://www.babylonjs-playground.com/#RNASML
  87823. */
  87824. boundingBoxSize: Vector3;
  87825. /**
  87826. * In case the RTT has been created with a depth texture, get the associated
  87827. * depth texture.
  87828. * Otherwise, return null.
  87829. */
  87830. depthStencilTexture: Nullable<InternalTexture>;
  87831. /**
  87832. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87833. * or used a shadow, depth texture...
  87834. * @param name The friendly name of the texture
  87835. * @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)
  87836. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87837. * @param generateMipMaps True if mip maps need to be generated after render.
  87838. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87839. * @param type The type of the buffer in the RTT (int, half float, float...)
  87840. * @param isCube True if a cube texture needs to be created
  87841. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87842. * @param generateDepthBuffer True to generate a depth buffer
  87843. * @param generateStencilBuffer True to generate a stencil buffer
  87844. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87845. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87846. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87847. */
  87848. constructor(name: string, size: number | {
  87849. width: number;
  87850. height: number;
  87851. } | {
  87852. ratio: number;
  87853. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87854. /**
  87855. * Creates a depth stencil texture.
  87856. * This is only available in WebGL 2 or with the depth texture extension available.
  87857. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87858. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87859. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87860. */
  87861. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87862. private _processSizeParameter;
  87863. /**
  87864. * Define the number of samples to use in case of MSAA.
  87865. * It defaults to one meaning no MSAA has been enabled.
  87866. */
  87867. samples: number;
  87868. /**
  87869. * Resets the refresh counter of the texture and start bak from scratch.
  87870. * Could be useful to regenerate the texture if it is setup to render only once.
  87871. */
  87872. resetRefreshCounter(): void;
  87873. /**
  87874. * Define the refresh rate of the texture or the rendering frequency.
  87875. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87876. */
  87877. refreshRate: number;
  87878. /**
  87879. * Adds a post process to the render target rendering passes.
  87880. * @param postProcess define the post process to add
  87881. */
  87882. addPostProcess(postProcess: PostProcess): void;
  87883. /**
  87884. * Clear all the post processes attached to the render target
  87885. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87886. */
  87887. clearPostProcesses(dispose?: boolean): void;
  87888. /**
  87889. * Remove one of the post process from the list of attached post processes to the texture
  87890. * @param postProcess define the post process to remove from the list
  87891. */
  87892. removePostProcess(postProcess: PostProcess): void;
  87893. /** @hidden */
  87894. _shouldRender(): boolean;
  87895. /**
  87896. * Gets the actual render size of the texture.
  87897. * @returns the width of the render size
  87898. */
  87899. getRenderSize(): number;
  87900. /**
  87901. * Gets the actual render width of the texture.
  87902. * @returns the width of the render size
  87903. */
  87904. getRenderWidth(): number;
  87905. /**
  87906. * Gets the actual render height of the texture.
  87907. * @returns the height of the render size
  87908. */
  87909. getRenderHeight(): number;
  87910. /**
  87911. * Get if the texture can be rescaled or not.
  87912. */
  87913. readonly canRescale: boolean;
  87914. /**
  87915. * Resize the texture using a ratio.
  87916. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87917. */
  87918. scale(ratio: number): void;
  87919. /**
  87920. * Get the texture reflection matrix used to rotate/transform the reflection.
  87921. * @returns the reflection matrix
  87922. */
  87923. getReflectionTextureMatrix(): Matrix;
  87924. /**
  87925. * Resize the texture to a new desired size.
  87926. * Be carrefull as it will recreate all the data in the new texture.
  87927. * @param size Define the new size. It can be:
  87928. * - a number for squared texture,
  87929. * - an object containing { width: number, height: number }
  87930. * - or an object containing a ratio { ratio: number }
  87931. */
  87932. resize(size: number | {
  87933. width: number;
  87934. height: number;
  87935. } | {
  87936. ratio: number;
  87937. }): void;
  87938. /**
  87939. * Renders all the objects from the render list into the texture.
  87940. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87941. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87942. */
  87943. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87944. private _bestReflectionRenderTargetDimension;
  87945. /**
  87946. * @hidden
  87947. * @param faceIndex face index to bind to if this is a cubetexture
  87948. */
  87949. _bindFrameBuffer(faceIndex?: number): void;
  87950. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87951. private renderToTarget;
  87952. /**
  87953. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87954. * This allowed control for front to back rendering or reversly depending of the special needs.
  87955. *
  87956. * @param renderingGroupId The rendering group id corresponding to its index
  87957. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87958. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87959. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87960. */
  87961. 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;
  87962. /**
  87963. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87964. *
  87965. * @param renderingGroupId The rendering group id corresponding to its index
  87966. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87967. */
  87968. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87969. /**
  87970. * Clones the texture.
  87971. * @returns the cloned texture
  87972. */
  87973. clone(): RenderTargetTexture;
  87974. /**
  87975. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87976. * @returns The JSON representation of the texture
  87977. */
  87978. serialize(): any;
  87979. /**
  87980. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87981. */
  87982. disposeFramebufferObjects(): void;
  87983. /**
  87984. * Dispose the texture and release its associated resources.
  87985. */
  87986. dispose(): void;
  87987. /** @hidden */
  87988. _rebuild(): void;
  87989. /**
  87990. * Clear the info related to rendering groups preventing retention point in material dispose.
  87991. */
  87992. freeRenderingGroups(): void;
  87993. /**
  87994. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87995. * @returns the view count
  87996. */
  87997. getViewCount(): number;
  87998. }
  87999. }
  88000. declare module BABYLON {
  88001. /**
  88002. * Options for compiling materials.
  88003. */
  88004. export interface IMaterialCompilationOptions {
  88005. /**
  88006. * Defines whether clip planes are enabled.
  88007. */
  88008. clipPlane: boolean;
  88009. /**
  88010. * Defines whether instances are enabled.
  88011. */
  88012. useInstances: boolean;
  88013. }
  88014. /**
  88015. * Base class for the main features of a material in Babylon.js
  88016. */
  88017. export class Material implements IAnimatable {
  88018. /**
  88019. * Returns the triangle fill mode
  88020. */
  88021. static readonly TriangleFillMode: number;
  88022. /**
  88023. * Returns the wireframe mode
  88024. */
  88025. static readonly WireFrameFillMode: number;
  88026. /**
  88027. * Returns the point fill mode
  88028. */
  88029. static readonly PointFillMode: number;
  88030. /**
  88031. * Returns the point list draw mode
  88032. */
  88033. static readonly PointListDrawMode: number;
  88034. /**
  88035. * Returns the line list draw mode
  88036. */
  88037. static readonly LineListDrawMode: number;
  88038. /**
  88039. * Returns the line loop draw mode
  88040. */
  88041. static readonly LineLoopDrawMode: number;
  88042. /**
  88043. * Returns the line strip draw mode
  88044. */
  88045. static readonly LineStripDrawMode: number;
  88046. /**
  88047. * Returns the triangle strip draw mode
  88048. */
  88049. static readonly TriangleStripDrawMode: number;
  88050. /**
  88051. * Returns the triangle fan draw mode
  88052. */
  88053. static readonly TriangleFanDrawMode: number;
  88054. /**
  88055. * Stores the clock-wise side orientation
  88056. */
  88057. static readonly ClockWiseSideOrientation: number;
  88058. /**
  88059. * Stores the counter clock-wise side orientation
  88060. */
  88061. static readonly CounterClockWiseSideOrientation: number;
  88062. /**
  88063. * The dirty texture flag value
  88064. */
  88065. static readonly TextureDirtyFlag: number;
  88066. /**
  88067. * The dirty light flag value
  88068. */
  88069. static readonly LightDirtyFlag: number;
  88070. /**
  88071. * The dirty fresnel flag value
  88072. */
  88073. static readonly FresnelDirtyFlag: number;
  88074. /**
  88075. * The dirty attribute flag value
  88076. */
  88077. static readonly AttributesDirtyFlag: number;
  88078. /**
  88079. * The dirty misc flag value
  88080. */
  88081. static readonly MiscDirtyFlag: number;
  88082. /**
  88083. * The all dirty flag value
  88084. */
  88085. static readonly AllDirtyFlag: number;
  88086. /**
  88087. * The ID of the material
  88088. */
  88089. id: string;
  88090. /**
  88091. * Gets or sets the unique id of the material
  88092. */
  88093. uniqueId: number;
  88094. /**
  88095. * The name of the material
  88096. */
  88097. name: string;
  88098. /**
  88099. * Gets or sets user defined metadata
  88100. */
  88101. metadata: any;
  88102. /**
  88103. * For internal use only. Please do not use.
  88104. */
  88105. reservedDataStore: any;
  88106. /**
  88107. * Specifies if the ready state should be checked on each call
  88108. */
  88109. checkReadyOnEveryCall: boolean;
  88110. /**
  88111. * Specifies if the ready state should be checked once
  88112. */
  88113. checkReadyOnlyOnce: boolean;
  88114. /**
  88115. * The state of the material
  88116. */
  88117. state: string;
  88118. /**
  88119. * The alpha value of the material
  88120. */
  88121. protected _alpha: number;
  88122. /**
  88123. * List of inspectable custom properties (used by the Inspector)
  88124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88125. */
  88126. inspectableCustomProperties: IInspectable[];
  88127. /**
  88128. * Sets the alpha value of the material
  88129. */
  88130. /**
  88131. * Gets the alpha value of the material
  88132. */
  88133. alpha: number;
  88134. /**
  88135. * Specifies if back face culling is enabled
  88136. */
  88137. protected _backFaceCulling: boolean;
  88138. /**
  88139. * Sets the back-face culling state
  88140. */
  88141. /**
  88142. * Gets the back-face culling state
  88143. */
  88144. backFaceCulling: boolean;
  88145. /**
  88146. * Stores the value for side orientation
  88147. */
  88148. sideOrientation: number;
  88149. /**
  88150. * Callback triggered when the material is compiled
  88151. */
  88152. onCompiled: Nullable<(effect: Effect) => void>;
  88153. /**
  88154. * Callback triggered when an error occurs
  88155. */
  88156. onError: Nullable<(effect: Effect, errors: string) => void>;
  88157. /**
  88158. * Callback triggered to get the render target textures
  88159. */
  88160. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88161. /**
  88162. * Gets a boolean indicating that current material needs to register RTT
  88163. */
  88164. readonly hasRenderTargetTextures: boolean;
  88165. /**
  88166. * Specifies if the material should be serialized
  88167. */
  88168. doNotSerialize: boolean;
  88169. /**
  88170. * @hidden
  88171. */
  88172. _storeEffectOnSubMeshes: boolean;
  88173. /**
  88174. * Stores the animations for the material
  88175. */
  88176. animations: Nullable<Array<Animation>>;
  88177. /**
  88178. * An event triggered when the material is disposed
  88179. */
  88180. onDisposeObservable: Observable<Material>;
  88181. /**
  88182. * An observer which watches for dispose events
  88183. */
  88184. private _onDisposeObserver;
  88185. private _onUnBindObservable;
  88186. /**
  88187. * Called during a dispose event
  88188. */
  88189. onDispose: () => void;
  88190. private _onBindObservable;
  88191. /**
  88192. * An event triggered when the material is bound
  88193. */
  88194. readonly onBindObservable: Observable<AbstractMesh>;
  88195. /**
  88196. * An observer which watches for bind events
  88197. */
  88198. private _onBindObserver;
  88199. /**
  88200. * Called during a bind event
  88201. */
  88202. onBind: (Mesh: AbstractMesh) => void;
  88203. /**
  88204. * An event triggered when the material is unbound
  88205. */
  88206. readonly onUnBindObservable: Observable<Material>;
  88207. /**
  88208. * Stores the value of the alpha mode
  88209. */
  88210. private _alphaMode;
  88211. /**
  88212. * Sets the value of the alpha mode.
  88213. *
  88214. * | Value | Type | Description |
  88215. * | --- | --- | --- |
  88216. * | 0 | ALPHA_DISABLE | |
  88217. * | 1 | ALPHA_ADD | |
  88218. * | 2 | ALPHA_COMBINE | |
  88219. * | 3 | ALPHA_SUBTRACT | |
  88220. * | 4 | ALPHA_MULTIPLY | |
  88221. * | 5 | ALPHA_MAXIMIZED | |
  88222. * | 6 | ALPHA_ONEONE | |
  88223. * | 7 | ALPHA_PREMULTIPLIED | |
  88224. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88225. * | 9 | ALPHA_INTERPOLATE | |
  88226. * | 10 | ALPHA_SCREENMODE | |
  88227. *
  88228. */
  88229. /**
  88230. * Gets the value of the alpha mode
  88231. */
  88232. alphaMode: number;
  88233. /**
  88234. * Stores the state of the need depth pre-pass value
  88235. */
  88236. private _needDepthPrePass;
  88237. /**
  88238. * Sets the need depth pre-pass value
  88239. */
  88240. /**
  88241. * Gets the depth pre-pass value
  88242. */
  88243. needDepthPrePass: boolean;
  88244. /**
  88245. * Specifies if depth writing should be disabled
  88246. */
  88247. disableDepthWrite: boolean;
  88248. /**
  88249. * Specifies if depth writing should be forced
  88250. */
  88251. forceDepthWrite: boolean;
  88252. /**
  88253. * Specifies if there should be a separate pass for culling
  88254. */
  88255. separateCullingPass: boolean;
  88256. /**
  88257. * Stores the state specifing if fog should be enabled
  88258. */
  88259. private _fogEnabled;
  88260. /**
  88261. * Sets the state for enabling fog
  88262. */
  88263. /**
  88264. * Gets the value of the fog enabled state
  88265. */
  88266. fogEnabled: boolean;
  88267. /**
  88268. * Stores the size of points
  88269. */
  88270. pointSize: number;
  88271. /**
  88272. * Stores the z offset value
  88273. */
  88274. zOffset: number;
  88275. /**
  88276. * Gets a value specifying if wireframe mode is enabled
  88277. */
  88278. /**
  88279. * Sets the state of wireframe mode
  88280. */
  88281. wireframe: boolean;
  88282. /**
  88283. * Gets the value specifying if point clouds are enabled
  88284. */
  88285. /**
  88286. * Sets the state of point cloud mode
  88287. */
  88288. pointsCloud: boolean;
  88289. /**
  88290. * Gets the material fill mode
  88291. */
  88292. /**
  88293. * Sets the material fill mode
  88294. */
  88295. fillMode: number;
  88296. /**
  88297. * @hidden
  88298. * Stores the effects for the material
  88299. */
  88300. _effect: Nullable<Effect>;
  88301. /**
  88302. * @hidden
  88303. * Specifies if the material was previously ready
  88304. */
  88305. _wasPreviouslyReady: boolean;
  88306. /**
  88307. * Specifies if uniform buffers should be used
  88308. */
  88309. private _useUBO;
  88310. /**
  88311. * Stores a reference to the scene
  88312. */
  88313. private _scene;
  88314. /**
  88315. * Stores the fill mode state
  88316. */
  88317. private _fillMode;
  88318. /**
  88319. * Specifies if the depth write state should be cached
  88320. */
  88321. private _cachedDepthWriteState;
  88322. /**
  88323. * Stores the uniform buffer
  88324. */
  88325. protected _uniformBuffer: UniformBuffer;
  88326. /** @hidden */
  88327. _indexInSceneMaterialArray: number;
  88328. /** @hidden */
  88329. meshMap: Nullable<{
  88330. [id: string]: AbstractMesh | undefined;
  88331. }>;
  88332. /**
  88333. * Creates a material instance
  88334. * @param name defines the name of the material
  88335. * @param scene defines the scene to reference
  88336. * @param doNotAdd specifies if the material should be added to the scene
  88337. */
  88338. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88339. /**
  88340. * Returns a string representation of the current material
  88341. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88342. * @returns a string with material information
  88343. */
  88344. toString(fullDetails?: boolean): string;
  88345. /**
  88346. * Gets the class name of the material
  88347. * @returns a string with the class name of the material
  88348. */
  88349. getClassName(): string;
  88350. /**
  88351. * Specifies if updates for the material been locked
  88352. */
  88353. readonly isFrozen: boolean;
  88354. /**
  88355. * Locks updates for the material
  88356. */
  88357. freeze(): void;
  88358. /**
  88359. * Unlocks updates for the material
  88360. */
  88361. unfreeze(): void;
  88362. /**
  88363. * Specifies if the material is ready to be used
  88364. * @param mesh defines the mesh to check
  88365. * @param useInstances specifies if instances should be used
  88366. * @returns a boolean indicating if the material is ready to be used
  88367. */
  88368. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88369. /**
  88370. * Specifies that the submesh is ready to be used
  88371. * @param mesh defines the mesh to check
  88372. * @param subMesh defines which submesh to check
  88373. * @param useInstances specifies that instances should be used
  88374. * @returns a boolean indicating that the submesh is ready or not
  88375. */
  88376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88377. /**
  88378. * Returns the material effect
  88379. * @returns the effect associated with the material
  88380. */
  88381. getEffect(): Nullable<Effect>;
  88382. /**
  88383. * Returns the current scene
  88384. * @returns a Scene
  88385. */
  88386. getScene(): Scene;
  88387. /**
  88388. * Specifies if the material will require alpha blending
  88389. * @returns a boolean specifying if alpha blending is needed
  88390. */
  88391. needAlphaBlending(): boolean;
  88392. /**
  88393. * Specifies if the mesh will require alpha blending
  88394. * @param mesh defines the mesh to check
  88395. * @returns a boolean specifying if alpha blending is needed for the mesh
  88396. */
  88397. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88398. /**
  88399. * Specifies if this material should be rendered in alpha test mode
  88400. * @returns a boolean specifying if an alpha test is needed.
  88401. */
  88402. needAlphaTesting(): boolean;
  88403. /**
  88404. * Gets the texture used for the alpha test
  88405. * @returns the texture to use for alpha testing
  88406. */
  88407. getAlphaTestTexture(): Nullable<BaseTexture>;
  88408. /**
  88409. * Marks the material to indicate that it needs to be re-calculated
  88410. */
  88411. markDirty(): void;
  88412. /** @hidden */
  88413. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88414. /**
  88415. * Binds the material to the mesh
  88416. * @param world defines the world transformation matrix
  88417. * @param mesh defines the mesh to bind the material to
  88418. */
  88419. bind(world: Matrix, mesh?: Mesh): void;
  88420. /**
  88421. * Binds the submesh to the material
  88422. * @param world defines the world transformation matrix
  88423. * @param mesh defines the mesh containing the submesh
  88424. * @param subMesh defines the submesh to bind the material to
  88425. */
  88426. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88427. /**
  88428. * Binds the world matrix to the material
  88429. * @param world defines the world transformation matrix
  88430. */
  88431. bindOnlyWorldMatrix(world: Matrix): void;
  88432. /**
  88433. * Binds the scene's uniform buffer to the effect.
  88434. * @param effect defines the effect to bind to the scene uniform buffer
  88435. * @param sceneUbo defines the uniform buffer storing scene data
  88436. */
  88437. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88438. /**
  88439. * Binds the view matrix to the effect
  88440. * @param effect defines the effect to bind the view matrix to
  88441. */
  88442. bindView(effect: Effect): void;
  88443. /**
  88444. * Binds the view projection matrix to the effect
  88445. * @param effect defines the effect to bind the view projection matrix to
  88446. */
  88447. bindViewProjection(effect: Effect): void;
  88448. /**
  88449. * Specifies if material alpha testing should be turned on for the mesh
  88450. * @param mesh defines the mesh to check
  88451. */
  88452. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88453. /**
  88454. * Processes to execute after binding the material to a mesh
  88455. * @param mesh defines the rendered mesh
  88456. */
  88457. protected _afterBind(mesh?: Mesh): void;
  88458. /**
  88459. * Unbinds the material from the mesh
  88460. */
  88461. unbind(): void;
  88462. /**
  88463. * Gets the active textures from the material
  88464. * @returns an array of textures
  88465. */
  88466. getActiveTextures(): BaseTexture[];
  88467. /**
  88468. * Specifies if the material uses a texture
  88469. * @param texture defines the texture to check against the material
  88470. * @returns a boolean specifying if the material uses the texture
  88471. */
  88472. hasTexture(texture: BaseTexture): boolean;
  88473. /**
  88474. * Makes a duplicate of the material, and gives it a new name
  88475. * @param name defines the new name for the duplicated material
  88476. * @returns the cloned material
  88477. */
  88478. clone(name: string): Nullable<Material>;
  88479. /**
  88480. * Gets the meshes bound to the material
  88481. * @returns an array of meshes bound to the material
  88482. */
  88483. getBindedMeshes(): AbstractMesh[];
  88484. /**
  88485. * Force shader compilation
  88486. * @param mesh defines the mesh associated with this material
  88487. * @param onCompiled defines a function to execute once the material is compiled
  88488. * @param options defines the options to configure the compilation
  88489. * @param onError defines a function to execute if the material fails compiling
  88490. */
  88491. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88492. /**
  88493. * Force shader compilation
  88494. * @param mesh defines the mesh that will use this material
  88495. * @param options defines additional options for compiling the shaders
  88496. * @returns a promise that resolves when the compilation completes
  88497. */
  88498. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88499. private static readonly _AllDirtyCallBack;
  88500. private static readonly _ImageProcessingDirtyCallBack;
  88501. private static readonly _TextureDirtyCallBack;
  88502. private static readonly _FresnelDirtyCallBack;
  88503. private static readonly _MiscDirtyCallBack;
  88504. private static readonly _LightsDirtyCallBack;
  88505. private static readonly _AttributeDirtyCallBack;
  88506. private static _FresnelAndMiscDirtyCallBack;
  88507. private static _TextureAndMiscDirtyCallBack;
  88508. private static readonly _DirtyCallbackArray;
  88509. private static readonly _RunDirtyCallBacks;
  88510. /**
  88511. * Marks a define in the material to indicate that it needs to be re-computed
  88512. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88513. */
  88514. markAsDirty(flag: number): void;
  88515. /**
  88516. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88517. * @param func defines a function which checks material defines against the submeshes
  88518. */
  88519. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88520. /**
  88521. * Indicates that we need to re-calculated for all submeshes
  88522. */
  88523. protected _markAllSubMeshesAsAllDirty(): void;
  88524. /**
  88525. * Indicates that image processing needs to be re-calculated for all submeshes
  88526. */
  88527. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88528. /**
  88529. * Indicates that textures need to be re-calculated for all submeshes
  88530. */
  88531. protected _markAllSubMeshesAsTexturesDirty(): void;
  88532. /**
  88533. * Indicates that fresnel needs to be re-calculated for all submeshes
  88534. */
  88535. protected _markAllSubMeshesAsFresnelDirty(): void;
  88536. /**
  88537. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88538. */
  88539. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88540. /**
  88541. * Indicates that lights need to be re-calculated for all submeshes
  88542. */
  88543. protected _markAllSubMeshesAsLightsDirty(): void;
  88544. /**
  88545. * Indicates that attributes need to be re-calculated for all submeshes
  88546. */
  88547. protected _markAllSubMeshesAsAttributesDirty(): void;
  88548. /**
  88549. * Indicates that misc needs to be re-calculated for all submeshes
  88550. */
  88551. protected _markAllSubMeshesAsMiscDirty(): void;
  88552. /**
  88553. * Indicates that textures and misc need to be re-calculated for all submeshes
  88554. */
  88555. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88556. /**
  88557. * Disposes the material
  88558. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88559. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88560. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88561. */
  88562. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88563. /** @hidden */
  88564. private releaseVertexArrayObject;
  88565. /**
  88566. * Serializes this material
  88567. * @returns the serialized material object
  88568. */
  88569. serialize(): any;
  88570. /**
  88571. * Creates a material from parsed material data
  88572. * @param parsedMaterial defines parsed material data
  88573. * @param scene defines the hosting scene
  88574. * @param rootUrl defines the root URL to use to load textures
  88575. * @returns a new material
  88576. */
  88577. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88578. }
  88579. }
  88580. declare module BABYLON {
  88581. /**
  88582. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88583. * separate meshes. This can be use to improve performances.
  88584. * @see http://doc.babylonjs.com/how_to/multi_materials
  88585. */
  88586. export class MultiMaterial extends Material {
  88587. private _subMaterials;
  88588. /**
  88589. * Gets or Sets the list of Materials used within the multi material.
  88590. * They need to be ordered according to the submeshes order in the associated mesh
  88591. */
  88592. subMaterials: Nullable<Material>[];
  88593. /**
  88594. * Function used to align with Node.getChildren()
  88595. * @returns the list of Materials used within the multi material
  88596. */
  88597. getChildren(): Nullable<Material>[];
  88598. /**
  88599. * Instantiates a new Multi Material
  88600. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88601. * separate meshes. This can be use to improve performances.
  88602. * @see http://doc.babylonjs.com/how_to/multi_materials
  88603. * @param name Define the name in the scene
  88604. * @param scene Define the scene the material belongs to
  88605. */
  88606. constructor(name: string, scene: Scene);
  88607. private _hookArray;
  88608. /**
  88609. * Get one of the submaterial by its index in the submaterials array
  88610. * @param index The index to look the sub material at
  88611. * @returns The Material if the index has been defined
  88612. */
  88613. getSubMaterial(index: number): Nullable<Material>;
  88614. /**
  88615. * Get the list of active textures for the whole sub materials list.
  88616. * @returns All the textures that will be used during the rendering
  88617. */
  88618. getActiveTextures(): BaseTexture[];
  88619. /**
  88620. * Gets the current class name of the material e.g. "MultiMaterial"
  88621. * Mainly use in serialization.
  88622. * @returns the class name
  88623. */
  88624. getClassName(): string;
  88625. /**
  88626. * Checks if the material is ready to render the requested sub mesh
  88627. * @param mesh Define the mesh the submesh belongs to
  88628. * @param subMesh Define the sub mesh to look readyness for
  88629. * @param useInstances Define whether or not the material is used with instances
  88630. * @returns true if ready, otherwise false
  88631. */
  88632. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88633. /**
  88634. * Clones the current material and its related sub materials
  88635. * @param name Define the name of the newly cloned material
  88636. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88637. * @returns the cloned material
  88638. */
  88639. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88640. /**
  88641. * Serializes the materials into a JSON representation.
  88642. * @returns the JSON representation
  88643. */
  88644. serialize(): any;
  88645. /**
  88646. * Dispose the material and release its associated resources
  88647. * @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)
  88648. * @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)
  88649. * @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)
  88650. */
  88651. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88652. /**
  88653. * Creates a MultiMaterial from parsed MultiMaterial data.
  88654. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88655. * @param scene defines the hosting scene
  88656. * @returns a new MultiMaterial
  88657. */
  88658. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88659. }
  88660. }
  88661. declare module BABYLON {
  88662. /**
  88663. * Base class for submeshes
  88664. */
  88665. export class BaseSubMesh {
  88666. /** @hidden */
  88667. _materialDefines: Nullable<MaterialDefines>;
  88668. /** @hidden */
  88669. _materialEffect: Nullable<Effect>;
  88670. /**
  88671. * Gets associated effect
  88672. */
  88673. readonly effect: Nullable<Effect>;
  88674. /**
  88675. * Sets associated effect (effect used to render this submesh)
  88676. * @param effect defines the effect to associate with
  88677. * @param defines defines the set of defines used to compile this effect
  88678. */
  88679. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88680. }
  88681. /**
  88682. * Defines a subdivision inside a mesh
  88683. */
  88684. export class SubMesh extends BaseSubMesh implements ICullable {
  88685. /** the material index to use */
  88686. materialIndex: number;
  88687. /** vertex index start */
  88688. verticesStart: number;
  88689. /** vertices count */
  88690. verticesCount: number;
  88691. /** index start */
  88692. indexStart: number;
  88693. /** indices count */
  88694. indexCount: number;
  88695. /** @hidden */
  88696. _linesIndexCount: number;
  88697. private _mesh;
  88698. private _renderingMesh;
  88699. private _boundingInfo;
  88700. private _linesIndexBuffer;
  88701. /** @hidden */
  88702. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88703. /** @hidden */
  88704. _trianglePlanes: Plane[];
  88705. /** @hidden */
  88706. _lastColliderTransformMatrix: Nullable<Matrix>;
  88707. /** @hidden */
  88708. _renderId: number;
  88709. /** @hidden */
  88710. _alphaIndex: number;
  88711. /** @hidden */
  88712. _distanceToCamera: number;
  88713. /** @hidden */
  88714. _id: number;
  88715. private _currentMaterial;
  88716. /**
  88717. * Add a new submesh to a mesh
  88718. * @param materialIndex defines the material index to use
  88719. * @param verticesStart defines vertex index start
  88720. * @param verticesCount defines vertices count
  88721. * @param indexStart defines index start
  88722. * @param indexCount defines indices count
  88723. * @param mesh defines the parent mesh
  88724. * @param renderingMesh defines an optional rendering mesh
  88725. * @param createBoundingBox defines if bounding box should be created for this submesh
  88726. * @returns the new submesh
  88727. */
  88728. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88729. /**
  88730. * Creates a new submesh
  88731. * @param materialIndex defines the material index to use
  88732. * @param verticesStart defines vertex index start
  88733. * @param verticesCount defines vertices count
  88734. * @param indexStart defines index start
  88735. * @param indexCount defines indices count
  88736. * @param mesh defines the parent mesh
  88737. * @param renderingMesh defines an optional rendering mesh
  88738. * @param createBoundingBox defines if bounding box should be created for this submesh
  88739. */
  88740. constructor(
  88741. /** the material index to use */
  88742. materialIndex: number,
  88743. /** vertex index start */
  88744. verticesStart: number,
  88745. /** vertices count */
  88746. verticesCount: number,
  88747. /** index start */
  88748. indexStart: number,
  88749. /** indices count */
  88750. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88751. /**
  88752. * Returns true if this submesh covers the entire parent mesh
  88753. * @ignorenaming
  88754. */
  88755. readonly IsGlobal: boolean;
  88756. /**
  88757. * Returns the submesh BoudingInfo object
  88758. * @returns current bounding info (or mesh's one if the submesh is global)
  88759. */
  88760. getBoundingInfo(): BoundingInfo;
  88761. /**
  88762. * Sets the submesh BoundingInfo
  88763. * @param boundingInfo defines the new bounding info to use
  88764. * @returns the SubMesh
  88765. */
  88766. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88767. /**
  88768. * Returns the mesh of the current submesh
  88769. * @return the parent mesh
  88770. */
  88771. getMesh(): AbstractMesh;
  88772. /**
  88773. * Returns the rendering mesh of the submesh
  88774. * @returns the rendering mesh (could be different from parent mesh)
  88775. */
  88776. getRenderingMesh(): Mesh;
  88777. /**
  88778. * Returns the submesh material
  88779. * @returns null or the current material
  88780. */
  88781. getMaterial(): Nullable<Material>;
  88782. /**
  88783. * Sets a new updated BoundingInfo object to the submesh
  88784. * @param data defines an optional position array to use to determine the bounding info
  88785. * @returns the SubMesh
  88786. */
  88787. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88788. /** @hidden */
  88789. _checkCollision(collider: Collider): boolean;
  88790. /**
  88791. * Updates the submesh BoundingInfo
  88792. * @param world defines the world matrix to use to update the bounding info
  88793. * @returns the submesh
  88794. */
  88795. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88796. /**
  88797. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88798. * @param frustumPlanes defines the frustum planes
  88799. * @returns true if the submesh is intersecting with the frustum
  88800. */
  88801. isInFrustum(frustumPlanes: Plane[]): boolean;
  88802. /**
  88803. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88804. * @param frustumPlanes defines the frustum planes
  88805. * @returns true if the submesh is inside the frustum
  88806. */
  88807. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88808. /**
  88809. * Renders the submesh
  88810. * @param enableAlphaMode defines if alpha needs to be used
  88811. * @returns the submesh
  88812. */
  88813. render(enableAlphaMode: boolean): SubMesh;
  88814. /**
  88815. * @hidden
  88816. */
  88817. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88818. /**
  88819. * Checks if the submesh intersects with a ray
  88820. * @param ray defines the ray to test
  88821. * @returns true is the passed ray intersects the submesh bounding box
  88822. */
  88823. canIntersects(ray: Ray): boolean;
  88824. /**
  88825. * Intersects current submesh with a ray
  88826. * @param ray defines the ray to test
  88827. * @param positions defines mesh's positions array
  88828. * @param indices defines mesh's indices array
  88829. * @param fastCheck defines if only bounding info should be used
  88830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88831. * @returns intersection info or null if no intersection
  88832. */
  88833. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88834. /** @hidden */
  88835. private _intersectLines;
  88836. /** @hidden */
  88837. private _intersectUnIndexedLines;
  88838. /** @hidden */
  88839. private _intersectTriangles;
  88840. /** @hidden */
  88841. private _intersectUnIndexedTriangles;
  88842. /** @hidden */
  88843. _rebuild(): void;
  88844. /**
  88845. * Creates a new submesh from the passed mesh
  88846. * @param newMesh defines the new hosting mesh
  88847. * @param newRenderingMesh defines an optional rendering mesh
  88848. * @returns the new submesh
  88849. */
  88850. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88851. /**
  88852. * Release associated resources
  88853. */
  88854. dispose(): void;
  88855. /**
  88856. * Gets the class name
  88857. * @returns the string "SubMesh".
  88858. */
  88859. getClassName(): string;
  88860. /**
  88861. * Creates a new submesh from indices data
  88862. * @param materialIndex the index of the main mesh material
  88863. * @param startIndex the index where to start the copy in the mesh indices array
  88864. * @param indexCount the number of indices to copy then from the startIndex
  88865. * @param mesh the main mesh to create the submesh from
  88866. * @param renderingMesh the optional rendering mesh
  88867. * @returns a new submesh
  88868. */
  88869. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88870. }
  88871. }
  88872. declare module BABYLON {
  88873. /**
  88874. * Class used to represent data loading progression
  88875. */
  88876. export class SceneLoaderFlags {
  88877. private static _ForceFullSceneLoadingForIncremental;
  88878. private static _ShowLoadingScreen;
  88879. private static _CleanBoneMatrixWeights;
  88880. private static _loggingLevel;
  88881. /**
  88882. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88883. */
  88884. static ForceFullSceneLoadingForIncremental: boolean;
  88885. /**
  88886. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88887. */
  88888. static ShowLoadingScreen: boolean;
  88889. /**
  88890. * Defines the current logging level (while loading the scene)
  88891. * @ignorenaming
  88892. */
  88893. static loggingLevel: number;
  88894. /**
  88895. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88896. */
  88897. static CleanBoneMatrixWeights: boolean;
  88898. }
  88899. }
  88900. declare module BABYLON {
  88901. /**
  88902. * Class used to store geometry data (vertex buffers + index buffer)
  88903. */
  88904. export class Geometry implements IGetSetVerticesData {
  88905. /**
  88906. * Gets or sets the ID of the geometry
  88907. */
  88908. id: string;
  88909. /**
  88910. * Gets or sets the unique ID of the geometry
  88911. */
  88912. uniqueId: number;
  88913. /**
  88914. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88915. */
  88916. delayLoadState: number;
  88917. /**
  88918. * Gets the file containing the data to load when running in delay load state
  88919. */
  88920. delayLoadingFile: Nullable<string>;
  88921. /**
  88922. * Callback called when the geometry is updated
  88923. */
  88924. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88925. private _scene;
  88926. private _engine;
  88927. private _meshes;
  88928. private _totalVertices;
  88929. /** @hidden */
  88930. _indices: IndicesArray;
  88931. /** @hidden */
  88932. _vertexBuffers: {
  88933. [key: string]: VertexBuffer;
  88934. };
  88935. private _isDisposed;
  88936. private _extend;
  88937. private _boundingBias;
  88938. /** @hidden */
  88939. _delayInfo: Array<string>;
  88940. private _indexBuffer;
  88941. private _indexBufferIsUpdatable;
  88942. /** @hidden */
  88943. _boundingInfo: Nullable<BoundingInfo>;
  88944. /** @hidden */
  88945. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88946. /** @hidden */
  88947. _softwareSkinningFrameId: number;
  88948. private _vertexArrayObjects;
  88949. private _updatable;
  88950. /** @hidden */
  88951. _positions: Nullable<Vector3[]>;
  88952. /**
  88953. * 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
  88954. */
  88955. /**
  88956. * 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
  88957. */
  88958. boundingBias: Vector2;
  88959. /**
  88960. * Static function used to attach a new empty geometry to a mesh
  88961. * @param mesh defines the mesh to attach the geometry to
  88962. * @returns the new Geometry
  88963. */
  88964. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88965. /**
  88966. * Creates a new geometry
  88967. * @param id defines the unique ID
  88968. * @param scene defines the hosting scene
  88969. * @param vertexData defines the VertexData used to get geometry data
  88970. * @param updatable defines if geometry must be updatable (false by default)
  88971. * @param mesh defines the mesh that will be associated with the geometry
  88972. */
  88973. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88974. /**
  88975. * Gets the current extend of the geometry
  88976. */
  88977. readonly extend: {
  88978. minimum: Vector3;
  88979. maximum: Vector3;
  88980. };
  88981. /**
  88982. * Gets the hosting scene
  88983. * @returns the hosting Scene
  88984. */
  88985. getScene(): Scene;
  88986. /**
  88987. * Gets the hosting engine
  88988. * @returns the hosting Engine
  88989. */
  88990. getEngine(): Engine;
  88991. /**
  88992. * Defines if the geometry is ready to use
  88993. * @returns true if the geometry is ready to be used
  88994. */
  88995. isReady(): boolean;
  88996. /**
  88997. * Gets a value indicating that the geometry should not be serialized
  88998. */
  88999. readonly doNotSerialize: boolean;
  89000. /** @hidden */
  89001. _rebuild(): void;
  89002. /**
  89003. * Affects all geometry data in one call
  89004. * @param vertexData defines the geometry data
  89005. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89006. */
  89007. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89008. /**
  89009. * Set specific vertex data
  89010. * @param kind defines the data kind (Position, normal, etc...)
  89011. * @param data defines the vertex data to use
  89012. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89013. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89014. */
  89015. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89016. /**
  89017. * Removes a specific vertex data
  89018. * @param kind defines the data kind (Position, normal, etc...)
  89019. */
  89020. removeVerticesData(kind: string): void;
  89021. /**
  89022. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89023. * @param buffer defines the vertex buffer to use
  89024. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89025. */
  89026. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89027. /**
  89028. * Update a specific vertex buffer
  89029. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89030. * It will do nothing if the buffer is not updatable
  89031. * @param kind defines the data kind (Position, normal, etc...)
  89032. * @param data defines the data to use
  89033. * @param offset defines the offset in the target buffer where to store the data
  89034. * @param useBytes set to true if the offset is in bytes
  89035. */
  89036. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89037. /**
  89038. * Update a specific vertex buffer
  89039. * This function will create a new buffer if the current one is not updatable
  89040. * @param kind defines the data kind (Position, normal, etc...)
  89041. * @param data defines the data to use
  89042. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89043. */
  89044. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89045. private _updateBoundingInfo;
  89046. /** @hidden */
  89047. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89048. /**
  89049. * Gets total number of vertices
  89050. * @returns the total number of vertices
  89051. */
  89052. getTotalVertices(): number;
  89053. /**
  89054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89055. * @param kind defines the data kind (Position, normal, etc...)
  89056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89058. * @returns a float array containing vertex data
  89059. */
  89060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89061. /**
  89062. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89063. * @param kind defines the data kind (Position, normal, etc...)
  89064. * @returns true if the vertex buffer with the specified kind is updatable
  89065. */
  89066. isVertexBufferUpdatable(kind: string): boolean;
  89067. /**
  89068. * Gets a specific vertex buffer
  89069. * @param kind defines the data kind (Position, normal, etc...)
  89070. * @returns a VertexBuffer
  89071. */
  89072. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89073. /**
  89074. * Returns all vertex buffers
  89075. * @return an object holding all vertex buffers indexed by kind
  89076. */
  89077. getVertexBuffers(): Nullable<{
  89078. [key: string]: VertexBuffer;
  89079. }>;
  89080. /**
  89081. * Gets a boolean indicating if specific vertex buffer is present
  89082. * @param kind defines the data kind (Position, normal, etc...)
  89083. * @returns true if data is present
  89084. */
  89085. isVerticesDataPresent(kind: string): boolean;
  89086. /**
  89087. * Gets a list of all attached data kinds (Position, normal, etc...)
  89088. * @returns a list of string containing all kinds
  89089. */
  89090. getVerticesDataKinds(): string[];
  89091. /**
  89092. * Update index buffer
  89093. * @param indices defines the indices to store in the index buffer
  89094. * @param offset defines the offset in the target buffer where to store the data
  89095. * @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)
  89096. */
  89097. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89098. /**
  89099. * Creates a new index buffer
  89100. * @param indices defines the indices to store in the index buffer
  89101. * @param totalVertices defines the total number of vertices (could be null)
  89102. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89103. */
  89104. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89105. /**
  89106. * Return the total number of indices
  89107. * @returns the total number of indices
  89108. */
  89109. getTotalIndices(): number;
  89110. /**
  89111. * Gets the index buffer array
  89112. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89113. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89114. * @returns the index buffer array
  89115. */
  89116. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89117. /**
  89118. * Gets the index buffer
  89119. * @return the index buffer
  89120. */
  89121. getIndexBuffer(): Nullable<DataBuffer>;
  89122. /** @hidden */
  89123. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89124. /**
  89125. * Release the associated resources for a specific mesh
  89126. * @param mesh defines the source mesh
  89127. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89128. */
  89129. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89130. /**
  89131. * Apply current geometry to a given mesh
  89132. * @param mesh defines the mesh to apply geometry to
  89133. */
  89134. applyToMesh(mesh: Mesh): void;
  89135. private _updateExtend;
  89136. private _applyToMesh;
  89137. private notifyUpdate;
  89138. /**
  89139. * Load the geometry if it was flagged as delay loaded
  89140. * @param scene defines the hosting scene
  89141. * @param onLoaded defines a callback called when the geometry is loaded
  89142. */
  89143. load(scene: Scene, onLoaded?: () => void): void;
  89144. private _queueLoad;
  89145. /**
  89146. * Invert the geometry to move from a right handed system to a left handed one.
  89147. */
  89148. toLeftHanded(): void;
  89149. /** @hidden */
  89150. _resetPointsArrayCache(): void;
  89151. /** @hidden */
  89152. _generatePointsArray(): boolean;
  89153. /**
  89154. * Gets a value indicating if the geometry is disposed
  89155. * @returns true if the geometry was disposed
  89156. */
  89157. isDisposed(): boolean;
  89158. private _disposeVertexArrayObjects;
  89159. /**
  89160. * Free all associated resources
  89161. */
  89162. dispose(): void;
  89163. /**
  89164. * Clone the current geometry into a new geometry
  89165. * @param id defines the unique ID of the new geometry
  89166. * @returns a new geometry object
  89167. */
  89168. copy(id: string): Geometry;
  89169. /**
  89170. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89171. * @return a JSON representation of the current geometry data (without the vertices data)
  89172. */
  89173. serialize(): any;
  89174. private toNumberArray;
  89175. /**
  89176. * Serialize all vertices data into a JSON oject
  89177. * @returns a JSON representation of the current geometry data
  89178. */
  89179. serializeVerticeData(): any;
  89180. /**
  89181. * Extracts a clone of a mesh geometry
  89182. * @param mesh defines the source mesh
  89183. * @param id defines the unique ID of the new geometry object
  89184. * @returns the new geometry object
  89185. */
  89186. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89187. /**
  89188. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89189. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89190. * Be aware Math.random() could cause collisions, but:
  89191. * "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"
  89192. * @returns a string containing a new GUID
  89193. */
  89194. static RandomId(): string;
  89195. /** @hidden */
  89196. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89197. private static _CleanMatricesWeights;
  89198. /**
  89199. * Create a new geometry from persisted data (Using .babylon file format)
  89200. * @param parsedVertexData defines the persisted data
  89201. * @param scene defines the hosting scene
  89202. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89203. * @returns the new geometry object
  89204. */
  89205. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89206. }
  89207. }
  89208. declare module BABYLON {
  89209. /**
  89210. * Define an interface for all classes that will get and set the data on vertices
  89211. */
  89212. export interface IGetSetVerticesData {
  89213. /**
  89214. * Gets a boolean indicating if specific vertex data is present
  89215. * @param kind defines the vertex data kind to use
  89216. * @returns true is data kind is present
  89217. */
  89218. isVerticesDataPresent(kind: string): boolean;
  89219. /**
  89220. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89221. * @param kind defines the data kind (Position, normal, etc...)
  89222. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89223. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89224. * @returns a float array containing vertex data
  89225. */
  89226. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89227. /**
  89228. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89229. * @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.
  89230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89231. * @returns the indices array or an empty array if the mesh has no geometry
  89232. */
  89233. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89234. /**
  89235. * Set specific vertex data
  89236. * @param kind defines the data kind (Position, normal, etc...)
  89237. * @param data defines the vertex data to use
  89238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89240. */
  89241. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89242. /**
  89243. * Update a specific associated vertex buffer
  89244. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89245. * - VertexBuffer.PositionKind
  89246. * - VertexBuffer.UVKind
  89247. * - VertexBuffer.UV2Kind
  89248. * - VertexBuffer.UV3Kind
  89249. * - VertexBuffer.UV4Kind
  89250. * - VertexBuffer.UV5Kind
  89251. * - VertexBuffer.UV6Kind
  89252. * - VertexBuffer.ColorKind
  89253. * - VertexBuffer.MatricesIndicesKind
  89254. * - VertexBuffer.MatricesIndicesExtraKind
  89255. * - VertexBuffer.MatricesWeightsKind
  89256. * - VertexBuffer.MatricesWeightsExtraKind
  89257. * @param data defines the data source
  89258. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89259. * @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)
  89260. */
  89261. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89262. /**
  89263. * Creates a new index buffer
  89264. * @param indices defines the indices to store in the index buffer
  89265. * @param totalVertices defines the total number of vertices (could be null)
  89266. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89267. */
  89268. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89269. }
  89270. /**
  89271. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89272. */
  89273. export class VertexData {
  89274. /**
  89275. * Mesh side orientation : usually the external or front surface
  89276. */
  89277. static readonly FRONTSIDE: number;
  89278. /**
  89279. * Mesh side orientation : usually the internal or back surface
  89280. */
  89281. static readonly BACKSIDE: number;
  89282. /**
  89283. * Mesh side orientation : both internal and external or front and back surfaces
  89284. */
  89285. static readonly DOUBLESIDE: number;
  89286. /**
  89287. * Mesh side orientation : by default, `FRONTSIDE`
  89288. */
  89289. static readonly DEFAULTSIDE: number;
  89290. /**
  89291. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89292. */
  89293. positions: Nullable<FloatArray>;
  89294. /**
  89295. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89296. */
  89297. normals: Nullable<FloatArray>;
  89298. /**
  89299. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89300. */
  89301. tangents: Nullable<FloatArray>;
  89302. /**
  89303. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89304. */
  89305. uvs: Nullable<FloatArray>;
  89306. /**
  89307. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89308. */
  89309. uvs2: Nullable<FloatArray>;
  89310. /**
  89311. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89312. */
  89313. uvs3: Nullable<FloatArray>;
  89314. /**
  89315. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89316. */
  89317. uvs4: Nullable<FloatArray>;
  89318. /**
  89319. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89320. */
  89321. uvs5: Nullable<FloatArray>;
  89322. /**
  89323. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89324. */
  89325. uvs6: Nullable<FloatArray>;
  89326. /**
  89327. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89328. */
  89329. colors: Nullable<FloatArray>;
  89330. /**
  89331. * 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).
  89332. */
  89333. matricesIndices: Nullable<FloatArray>;
  89334. /**
  89335. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89336. */
  89337. matricesWeights: Nullable<FloatArray>;
  89338. /**
  89339. * An array extending the number of possible indices
  89340. */
  89341. matricesIndicesExtra: Nullable<FloatArray>;
  89342. /**
  89343. * An array extending the number of possible weights when the number of indices is extended
  89344. */
  89345. matricesWeightsExtra: Nullable<FloatArray>;
  89346. /**
  89347. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89348. */
  89349. indices: Nullable<IndicesArray>;
  89350. /**
  89351. * Uses the passed data array to set the set the values for the specified kind of data
  89352. * @param data a linear array of floating numbers
  89353. * @param kind the type of data that is being set, eg positions, colors etc
  89354. */
  89355. set(data: FloatArray, kind: string): void;
  89356. /**
  89357. * Associates the vertexData to the passed Mesh.
  89358. * Sets it as updatable or not (default `false`)
  89359. * @param mesh the mesh the vertexData is applied to
  89360. * @param updatable when used and having the value true allows new data to update the vertexData
  89361. * @returns the VertexData
  89362. */
  89363. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89364. /**
  89365. * Associates the vertexData to the passed Geometry.
  89366. * Sets it as updatable or not (default `false`)
  89367. * @param geometry the geometry the vertexData is applied to
  89368. * @param updatable when used and having the value true allows new data to update the vertexData
  89369. * @returns VertexData
  89370. */
  89371. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89372. /**
  89373. * Updates the associated mesh
  89374. * @param mesh the mesh to be updated
  89375. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89376. * @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
  89377. * @returns VertexData
  89378. */
  89379. updateMesh(mesh: Mesh): VertexData;
  89380. /**
  89381. * Updates the associated geometry
  89382. * @param geometry the geometry to be updated
  89383. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89384. * @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
  89385. * @returns VertexData.
  89386. */
  89387. updateGeometry(geometry: Geometry): VertexData;
  89388. private _applyTo;
  89389. private _update;
  89390. /**
  89391. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89392. * @param matrix the transforming matrix
  89393. * @returns the VertexData
  89394. */
  89395. transform(matrix: Matrix): VertexData;
  89396. /**
  89397. * Merges the passed VertexData into the current one
  89398. * @param other the VertexData to be merged into the current one
  89399. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89400. * @returns the modified VertexData
  89401. */
  89402. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89403. private _mergeElement;
  89404. private _validate;
  89405. /**
  89406. * Serializes the VertexData
  89407. * @returns a serialized object
  89408. */
  89409. serialize(): any;
  89410. /**
  89411. * Extracts the vertexData from a mesh
  89412. * @param mesh the mesh from which to extract the VertexData
  89413. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89414. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89415. * @returns the object VertexData associated to the passed mesh
  89416. */
  89417. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89418. /**
  89419. * Extracts the vertexData from the geometry
  89420. * @param geometry the geometry from which to extract the VertexData
  89421. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89422. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89423. * @returns the object VertexData associated to the passed mesh
  89424. */
  89425. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89426. private static _ExtractFrom;
  89427. /**
  89428. * Creates the VertexData for a Ribbon
  89429. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89430. * * pathArray array of paths, each of which an array of successive Vector3
  89431. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89432. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89433. * * 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
  89434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89435. * * 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)
  89436. * * 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)
  89437. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89438. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89439. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89440. * @returns the VertexData of the ribbon
  89441. */
  89442. static CreateRibbon(options: {
  89443. pathArray: Vector3[][];
  89444. closeArray?: boolean;
  89445. closePath?: boolean;
  89446. offset?: number;
  89447. sideOrientation?: number;
  89448. frontUVs?: Vector4;
  89449. backUVs?: Vector4;
  89450. invertUV?: boolean;
  89451. uvs?: Vector2[];
  89452. colors?: Color4[];
  89453. }): VertexData;
  89454. /**
  89455. * Creates the VertexData for a box
  89456. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89457. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89458. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89459. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89460. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89461. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89462. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89464. * * 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)
  89465. * * 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)
  89466. * @returns the VertexData of the box
  89467. */
  89468. static CreateBox(options: {
  89469. size?: number;
  89470. width?: number;
  89471. height?: number;
  89472. depth?: number;
  89473. faceUV?: Vector4[];
  89474. faceColors?: Color4[];
  89475. sideOrientation?: number;
  89476. frontUVs?: Vector4;
  89477. backUVs?: Vector4;
  89478. }): VertexData;
  89479. /**
  89480. * Creates the VertexData for a tiled box
  89481. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89482. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89483. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89484. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89486. * @returns the VertexData of the box
  89487. */
  89488. static CreateTiledBox(options: {
  89489. pattern?: number;
  89490. width?: number;
  89491. height?: number;
  89492. depth?: number;
  89493. tileSize?: number;
  89494. tileWidth?: number;
  89495. tileHeight?: number;
  89496. alignHorizontal?: number;
  89497. alignVertical?: number;
  89498. faceUV?: Vector4[];
  89499. faceColors?: Color4[];
  89500. sideOrientation?: number;
  89501. }): VertexData;
  89502. /**
  89503. * Creates the VertexData for a tiled plane
  89504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89505. * * pattern a limited pattern arrangement depending on the number
  89506. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89507. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89508. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89510. * * 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)
  89511. * * 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)
  89512. * @returns the VertexData of the tiled plane
  89513. */
  89514. static CreateTiledPlane(options: {
  89515. pattern?: number;
  89516. tileSize?: number;
  89517. tileWidth?: number;
  89518. tileHeight?: number;
  89519. size?: number;
  89520. width?: number;
  89521. height?: number;
  89522. alignHorizontal?: number;
  89523. alignVertical?: number;
  89524. sideOrientation?: number;
  89525. frontUVs?: Vector4;
  89526. backUVs?: Vector4;
  89527. }): VertexData;
  89528. /**
  89529. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89531. * * segments sets the number of horizontal strips optional, default 32
  89532. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89533. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89534. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89535. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89536. * * 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
  89537. * * 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
  89538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89539. * * 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)
  89540. * * 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)
  89541. * @returns the VertexData of the ellipsoid
  89542. */
  89543. static CreateSphere(options: {
  89544. segments?: number;
  89545. diameter?: number;
  89546. diameterX?: number;
  89547. diameterY?: number;
  89548. diameterZ?: number;
  89549. arc?: number;
  89550. slice?: number;
  89551. sideOrientation?: number;
  89552. frontUVs?: Vector4;
  89553. backUVs?: Vector4;
  89554. }): VertexData;
  89555. /**
  89556. * Creates the VertexData for a cylinder, cone or prism
  89557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89558. * * height sets the height (y direction) of the cylinder, optional, default 2
  89559. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89560. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89561. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89562. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89563. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89564. * * 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
  89565. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89566. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89567. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89568. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89570. * * 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)
  89571. * * 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)
  89572. * @returns the VertexData of the cylinder, cone or prism
  89573. */
  89574. static CreateCylinder(options: {
  89575. height?: number;
  89576. diameterTop?: number;
  89577. diameterBottom?: number;
  89578. diameter?: number;
  89579. tessellation?: number;
  89580. subdivisions?: number;
  89581. arc?: number;
  89582. faceColors?: Color4[];
  89583. faceUV?: Vector4[];
  89584. hasRings?: boolean;
  89585. enclose?: boolean;
  89586. sideOrientation?: number;
  89587. frontUVs?: Vector4;
  89588. backUVs?: Vector4;
  89589. }): VertexData;
  89590. /**
  89591. * Creates the VertexData for a torus
  89592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89593. * * diameter the diameter of the torus, optional default 1
  89594. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89595. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89597. * * 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)
  89598. * * 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)
  89599. * @returns the VertexData of the torus
  89600. */
  89601. static CreateTorus(options: {
  89602. diameter?: number;
  89603. thickness?: number;
  89604. tessellation?: number;
  89605. sideOrientation?: number;
  89606. frontUVs?: Vector4;
  89607. backUVs?: Vector4;
  89608. }): VertexData;
  89609. /**
  89610. * Creates the VertexData of the LineSystem
  89611. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89612. * - lines an array of lines, each line being an array of successive Vector3
  89613. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89614. * @returns the VertexData of the LineSystem
  89615. */
  89616. static CreateLineSystem(options: {
  89617. lines: Vector3[][];
  89618. colors?: Nullable<Color4[][]>;
  89619. }): VertexData;
  89620. /**
  89621. * Create the VertexData for a DashedLines
  89622. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89623. * - points an array successive Vector3
  89624. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89625. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89626. * - dashNb the intended total number of dashes, optional, default 200
  89627. * @returns the VertexData for the DashedLines
  89628. */
  89629. static CreateDashedLines(options: {
  89630. points: Vector3[];
  89631. dashSize?: number;
  89632. gapSize?: number;
  89633. dashNb?: number;
  89634. }): VertexData;
  89635. /**
  89636. * Creates the VertexData for a Ground
  89637. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89638. * - width the width (x direction) of the ground, optional, default 1
  89639. * - height the height (z direction) of the ground, optional, default 1
  89640. * - subdivisions the number of subdivisions per side, optional, default 1
  89641. * @returns the VertexData of the Ground
  89642. */
  89643. static CreateGround(options: {
  89644. width?: number;
  89645. height?: number;
  89646. subdivisions?: number;
  89647. subdivisionsX?: number;
  89648. subdivisionsY?: number;
  89649. }): VertexData;
  89650. /**
  89651. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89652. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89653. * * xmin the ground minimum X coordinate, optional, default -1
  89654. * * zmin the ground minimum Z coordinate, optional, default -1
  89655. * * xmax the ground maximum X coordinate, optional, default 1
  89656. * * zmax the ground maximum Z coordinate, optional, default 1
  89657. * * 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}
  89658. * * 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}
  89659. * @returns the VertexData of the TiledGround
  89660. */
  89661. static CreateTiledGround(options: {
  89662. xmin: number;
  89663. zmin: number;
  89664. xmax: number;
  89665. zmax: number;
  89666. subdivisions?: {
  89667. w: number;
  89668. h: number;
  89669. };
  89670. precision?: {
  89671. w: number;
  89672. h: number;
  89673. };
  89674. }): VertexData;
  89675. /**
  89676. * Creates the VertexData of the Ground designed from a heightmap
  89677. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89678. * * width the width (x direction) of the ground
  89679. * * height the height (z direction) of the ground
  89680. * * subdivisions the number of subdivisions per side
  89681. * * minHeight the minimum altitude on the ground, optional, default 0
  89682. * * maxHeight the maximum altitude on the ground, optional default 1
  89683. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89684. * * buffer the array holding the image color data
  89685. * * bufferWidth the width of image
  89686. * * bufferHeight the height of image
  89687. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89688. * @returns the VertexData of the Ground designed from a heightmap
  89689. */
  89690. static CreateGroundFromHeightMap(options: {
  89691. width: number;
  89692. height: number;
  89693. subdivisions: number;
  89694. minHeight: number;
  89695. maxHeight: number;
  89696. colorFilter: Color3;
  89697. buffer: Uint8Array;
  89698. bufferWidth: number;
  89699. bufferHeight: number;
  89700. alphaFilter: number;
  89701. }): VertexData;
  89702. /**
  89703. * Creates the VertexData for a Plane
  89704. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89705. * * size sets the width and height of the plane to the value of size, optional default 1
  89706. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89707. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89709. * * 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)
  89710. * * 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)
  89711. * @returns the VertexData of the box
  89712. */
  89713. static CreatePlane(options: {
  89714. size?: number;
  89715. width?: number;
  89716. height?: number;
  89717. sideOrientation?: number;
  89718. frontUVs?: Vector4;
  89719. backUVs?: Vector4;
  89720. }): VertexData;
  89721. /**
  89722. * Creates the VertexData of the Disc or regular Polygon
  89723. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89724. * * radius the radius of the disc, optional default 0.5
  89725. * * tessellation the number of polygon sides, optional, default 64
  89726. * * 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
  89727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89728. * * 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)
  89729. * * 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)
  89730. * @returns the VertexData of the box
  89731. */
  89732. static CreateDisc(options: {
  89733. radius?: number;
  89734. tessellation?: number;
  89735. arc?: number;
  89736. sideOrientation?: number;
  89737. frontUVs?: Vector4;
  89738. backUVs?: Vector4;
  89739. }): VertexData;
  89740. /**
  89741. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89742. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89743. * @param polygon a mesh built from polygonTriangulation.build()
  89744. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89745. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89746. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89747. * @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)
  89748. * @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)
  89749. * @returns the VertexData of the Polygon
  89750. */
  89751. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89752. /**
  89753. * Creates the VertexData of the IcoSphere
  89754. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89755. * * radius the radius of the IcoSphere, optional default 1
  89756. * * radiusX allows stretching in the x direction, optional, default radius
  89757. * * radiusY allows stretching in the y direction, optional, default radius
  89758. * * radiusZ allows stretching in the z direction, optional, default radius
  89759. * * flat when true creates a flat shaded mesh, optional, default true
  89760. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89762. * * 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)
  89763. * * 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)
  89764. * @returns the VertexData of the IcoSphere
  89765. */
  89766. static CreateIcoSphere(options: {
  89767. radius?: number;
  89768. radiusX?: number;
  89769. radiusY?: number;
  89770. radiusZ?: number;
  89771. flat?: boolean;
  89772. subdivisions?: number;
  89773. sideOrientation?: number;
  89774. frontUVs?: Vector4;
  89775. backUVs?: Vector4;
  89776. }): VertexData;
  89777. /**
  89778. * Creates the VertexData for a Polyhedron
  89779. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89780. * * type provided types are:
  89781. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89782. * * 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)
  89783. * * size the size of the IcoSphere, optional default 1
  89784. * * sizeX allows stretching in the x direction, optional, default size
  89785. * * sizeY allows stretching in the y direction, optional, default size
  89786. * * sizeZ allows stretching in the z direction, optional, default size
  89787. * * 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
  89788. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89789. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89790. * * flat when true creates a flat shaded mesh, optional, default true
  89791. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89793. * * 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)
  89794. * * 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)
  89795. * @returns the VertexData of the Polyhedron
  89796. */
  89797. static CreatePolyhedron(options: {
  89798. type?: number;
  89799. size?: number;
  89800. sizeX?: number;
  89801. sizeY?: number;
  89802. sizeZ?: number;
  89803. custom?: any;
  89804. faceUV?: Vector4[];
  89805. faceColors?: Color4[];
  89806. flat?: boolean;
  89807. sideOrientation?: number;
  89808. frontUVs?: Vector4;
  89809. backUVs?: Vector4;
  89810. }): VertexData;
  89811. /**
  89812. * Creates the VertexData for a TorusKnot
  89813. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89814. * * radius the radius of the torus knot, optional, default 2
  89815. * * tube the thickness of the tube, optional, default 0.5
  89816. * * radialSegments the number of sides on each tube segments, optional, default 32
  89817. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89818. * * p the number of windings around the z axis, optional, default 2
  89819. * * q the number of windings around the x axis, optional, default 3
  89820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89821. * * 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)
  89822. * * 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)
  89823. * @returns the VertexData of the Torus Knot
  89824. */
  89825. static CreateTorusKnot(options: {
  89826. radius?: number;
  89827. tube?: number;
  89828. radialSegments?: number;
  89829. tubularSegments?: number;
  89830. p?: number;
  89831. q?: number;
  89832. sideOrientation?: number;
  89833. frontUVs?: Vector4;
  89834. backUVs?: Vector4;
  89835. }): VertexData;
  89836. /**
  89837. * Compute normals for given positions and indices
  89838. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89839. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89840. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89841. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89842. * * facetNormals : optional array of facet normals (vector3)
  89843. * * facetPositions : optional array of facet positions (vector3)
  89844. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89845. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89846. * * bInfo : optional bounding info, required for facetPartitioning computation
  89847. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89848. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89849. * * useRightHandedSystem: optional boolean to for right handed system computation
  89850. * * depthSort : optional boolean to enable the facet depth sort computation
  89851. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89852. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89853. */
  89854. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89855. facetNormals?: any;
  89856. facetPositions?: any;
  89857. facetPartitioning?: any;
  89858. ratio?: number;
  89859. bInfo?: any;
  89860. bbSize?: Vector3;
  89861. subDiv?: any;
  89862. useRightHandedSystem?: boolean;
  89863. depthSort?: boolean;
  89864. distanceTo?: Vector3;
  89865. depthSortedFacets?: any;
  89866. }): void;
  89867. /** @hidden */
  89868. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89869. /**
  89870. * Applies VertexData created from the imported parameters to the geometry
  89871. * @param parsedVertexData the parsed data from an imported file
  89872. * @param geometry the geometry to apply the VertexData to
  89873. */
  89874. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89875. }
  89876. }
  89877. declare module BABYLON {
  89878. /**
  89879. * Defines a target to use with MorphTargetManager
  89880. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89881. */
  89882. export class MorphTarget implements IAnimatable {
  89883. /** defines the name of the target */
  89884. name: string;
  89885. /**
  89886. * Gets or sets the list of animations
  89887. */
  89888. animations: Animation[];
  89889. private _scene;
  89890. private _positions;
  89891. private _normals;
  89892. private _tangents;
  89893. private _uvs;
  89894. private _influence;
  89895. private _uniqueId;
  89896. /**
  89897. * Observable raised when the influence changes
  89898. */
  89899. onInfluenceChanged: Observable<boolean>;
  89900. /** @hidden */
  89901. _onDataLayoutChanged: Observable<void>;
  89902. /**
  89903. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89904. */
  89905. influence: number;
  89906. /**
  89907. * Gets or sets the id of the morph Target
  89908. */
  89909. id: string;
  89910. private _animationPropertiesOverride;
  89911. /**
  89912. * Gets or sets the animation properties override
  89913. */
  89914. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89915. /**
  89916. * Creates a new MorphTarget
  89917. * @param name defines the name of the target
  89918. * @param influence defines the influence to use
  89919. * @param scene defines the scene the morphtarget belongs to
  89920. */
  89921. constructor(
  89922. /** defines the name of the target */
  89923. name: string, influence?: number, scene?: Nullable<Scene>);
  89924. /**
  89925. * Gets the unique ID of this manager
  89926. */
  89927. readonly uniqueId: number;
  89928. /**
  89929. * Gets a boolean defining if the target contains position data
  89930. */
  89931. readonly hasPositions: boolean;
  89932. /**
  89933. * Gets a boolean defining if the target contains normal data
  89934. */
  89935. readonly hasNormals: boolean;
  89936. /**
  89937. * Gets a boolean defining if the target contains tangent data
  89938. */
  89939. readonly hasTangents: boolean;
  89940. /**
  89941. * Gets a boolean defining if the target contains texture coordinates data
  89942. */
  89943. readonly hasUVs: boolean;
  89944. /**
  89945. * Affects position data to this target
  89946. * @param data defines the position data to use
  89947. */
  89948. setPositions(data: Nullable<FloatArray>): void;
  89949. /**
  89950. * Gets the position data stored in this target
  89951. * @returns a FloatArray containing the position data (or null if not present)
  89952. */
  89953. getPositions(): Nullable<FloatArray>;
  89954. /**
  89955. * Affects normal data to this target
  89956. * @param data defines the normal data to use
  89957. */
  89958. setNormals(data: Nullable<FloatArray>): void;
  89959. /**
  89960. * Gets the normal data stored in this target
  89961. * @returns a FloatArray containing the normal data (or null if not present)
  89962. */
  89963. getNormals(): Nullable<FloatArray>;
  89964. /**
  89965. * Affects tangent data to this target
  89966. * @param data defines the tangent data to use
  89967. */
  89968. setTangents(data: Nullable<FloatArray>): void;
  89969. /**
  89970. * Gets the tangent data stored in this target
  89971. * @returns a FloatArray containing the tangent data (or null if not present)
  89972. */
  89973. getTangents(): Nullable<FloatArray>;
  89974. /**
  89975. * Affects texture coordinates data to this target
  89976. * @param data defines the texture coordinates data to use
  89977. */
  89978. setUVs(data: Nullable<FloatArray>): void;
  89979. /**
  89980. * Gets the texture coordinates data stored in this target
  89981. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89982. */
  89983. getUVs(): Nullable<FloatArray>;
  89984. /**
  89985. * Clone the current target
  89986. * @returns a new MorphTarget
  89987. */
  89988. clone(): MorphTarget;
  89989. /**
  89990. * Serializes the current target into a Serialization object
  89991. * @returns the serialized object
  89992. */
  89993. serialize(): any;
  89994. /**
  89995. * Returns the string "MorphTarget"
  89996. * @returns "MorphTarget"
  89997. */
  89998. getClassName(): string;
  89999. /**
  90000. * Creates a new target from serialized data
  90001. * @param serializationObject defines the serialized data to use
  90002. * @returns a new MorphTarget
  90003. */
  90004. static Parse(serializationObject: any): MorphTarget;
  90005. /**
  90006. * Creates a MorphTarget from mesh data
  90007. * @param mesh defines the source mesh
  90008. * @param name defines the name to use for the new target
  90009. * @param influence defines the influence to attach to the target
  90010. * @returns a new MorphTarget
  90011. */
  90012. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90013. }
  90014. }
  90015. declare module BABYLON {
  90016. /**
  90017. * This class is used to deform meshes using morphing between different targets
  90018. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90019. */
  90020. export class MorphTargetManager {
  90021. private _targets;
  90022. private _targetInfluenceChangedObservers;
  90023. private _targetDataLayoutChangedObservers;
  90024. private _activeTargets;
  90025. private _scene;
  90026. private _influences;
  90027. private _supportsNormals;
  90028. private _supportsTangents;
  90029. private _supportsUVs;
  90030. private _vertexCount;
  90031. private _uniqueId;
  90032. private _tempInfluences;
  90033. /**
  90034. * Gets or sets a boolean indicating if normals must be morphed
  90035. */
  90036. enableNormalMorphing: boolean;
  90037. /**
  90038. * Gets or sets a boolean indicating if tangents must be morphed
  90039. */
  90040. enableTangentMorphing: boolean;
  90041. /**
  90042. * Gets or sets a boolean indicating if UV must be morphed
  90043. */
  90044. enableUVMorphing: boolean;
  90045. /**
  90046. * Creates a new MorphTargetManager
  90047. * @param scene defines the current scene
  90048. */
  90049. constructor(scene?: Nullable<Scene>);
  90050. /**
  90051. * Gets the unique ID of this manager
  90052. */
  90053. readonly uniqueId: number;
  90054. /**
  90055. * Gets the number of vertices handled by this manager
  90056. */
  90057. readonly vertexCount: number;
  90058. /**
  90059. * Gets a boolean indicating if this manager supports morphing of normals
  90060. */
  90061. readonly supportsNormals: boolean;
  90062. /**
  90063. * Gets a boolean indicating if this manager supports morphing of tangents
  90064. */
  90065. readonly supportsTangents: boolean;
  90066. /**
  90067. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90068. */
  90069. readonly supportsUVs: boolean;
  90070. /**
  90071. * Gets the number of targets stored in this manager
  90072. */
  90073. readonly numTargets: number;
  90074. /**
  90075. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90076. */
  90077. readonly numInfluencers: number;
  90078. /**
  90079. * Gets the list of influences (one per target)
  90080. */
  90081. readonly influences: Float32Array;
  90082. /**
  90083. * Gets the active target at specified index. An active target is a target with an influence > 0
  90084. * @param index defines the index to check
  90085. * @returns the requested target
  90086. */
  90087. getActiveTarget(index: number): MorphTarget;
  90088. /**
  90089. * Gets the target at specified index
  90090. * @param index defines the index to check
  90091. * @returns the requested target
  90092. */
  90093. getTarget(index: number): MorphTarget;
  90094. /**
  90095. * Add a new target to this manager
  90096. * @param target defines the target to add
  90097. */
  90098. addTarget(target: MorphTarget): void;
  90099. /**
  90100. * Removes a target from the manager
  90101. * @param target defines the target to remove
  90102. */
  90103. removeTarget(target: MorphTarget): void;
  90104. /**
  90105. * Clone the current manager
  90106. * @returns a new MorphTargetManager
  90107. */
  90108. clone(): MorphTargetManager;
  90109. /**
  90110. * Serializes the current manager into a Serialization object
  90111. * @returns the serialized object
  90112. */
  90113. serialize(): any;
  90114. private _syncActiveTargets;
  90115. /**
  90116. * Syncrhonize the targets with all the meshes using this morph target manager
  90117. */
  90118. synchronize(): void;
  90119. /**
  90120. * Creates a new MorphTargetManager from serialized data
  90121. * @param serializationObject defines the serialized data
  90122. * @param scene defines the hosting scene
  90123. * @returns the new MorphTargetManager
  90124. */
  90125. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90126. }
  90127. }
  90128. declare module BABYLON {
  90129. /**
  90130. * Class used to represent a specific level of detail of a mesh
  90131. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90132. */
  90133. export class MeshLODLevel {
  90134. /** Defines the distance where this level should start being displayed */
  90135. distance: number;
  90136. /** Defines the mesh to use to render this level */
  90137. mesh: Nullable<Mesh>;
  90138. /**
  90139. * Creates a new LOD level
  90140. * @param distance defines the distance where this level should star being displayed
  90141. * @param mesh defines the mesh to use to render this level
  90142. */
  90143. constructor(
  90144. /** Defines the distance where this level should start being displayed */
  90145. distance: number,
  90146. /** Defines the mesh to use to render this level */
  90147. mesh: Nullable<Mesh>);
  90148. }
  90149. }
  90150. declare module BABYLON {
  90151. /**
  90152. * Mesh representing the gorund
  90153. */
  90154. export class GroundMesh extends Mesh {
  90155. /** If octree should be generated */
  90156. generateOctree: boolean;
  90157. private _heightQuads;
  90158. /** @hidden */
  90159. _subdivisionsX: number;
  90160. /** @hidden */
  90161. _subdivisionsY: number;
  90162. /** @hidden */
  90163. _width: number;
  90164. /** @hidden */
  90165. _height: number;
  90166. /** @hidden */
  90167. _minX: number;
  90168. /** @hidden */
  90169. _maxX: number;
  90170. /** @hidden */
  90171. _minZ: number;
  90172. /** @hidden */
  90173. _maxZ: number;
  90174. constructor(name: string, scene: Scene);
  90175. /**
  90176. * "GroundMesh"
  90177. * @returns "GroundMesh"
  90178. */
  90179. getClassName(): string;
  90180. /**
  90181. * The minimum of x and y subdivisions
  90182. */
  90183. readonly subdivisions: number;
  90184. /**
  90185. * X subdivisions
  90186. */
  90187. readonly subdivisionsX: number;
  90188. /**
  90189. * Y subdivisions
  90190. */
  90191. readonly subdivisionsY: number;
  90192. /**
  90193. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90194. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90195. * @param chunksCount the number of subdivisions for x and y
  90196. * @param octreeBlocksSize (Default: 32)
  90197. */
  90198. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90199. /**
  90200. * Returns a height (y) value in the Worl system :
  90201. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90202. * @param x x coordinate
  90203. * @param z z coordinate
  90204. * @returns the ground y position if (x, z) are outside the ground surface.
  90205. */
  90206. getHeightAtCoordinates(x: number, z: number): number;
  90207. /**
  90208. * Returns a normalized vector (Vector3) orthogonal to the ground
  90209. * at the ground coordinates (x, z) expressed in the World system.
  90210. * @param x x coordinate
  90211. * @param z z coordinate
  90212. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90213. */
  90214. getNormalAtCoordinates(x: number, z: number): Vector3;
  90215. /**
  90216. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90217. * at the ground coordinates (x, z) expressed in the World system.
  90218. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90219. * @param x x coordinate
  90220. * @param z z coordinate
  90221. * @param ref vector to store the result
  90222. * @returns the GroundMesh.
  90223. */
  90224. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90225. /**
  90226. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90227. * if the ground has been updated.
  90228. * This can be used in the render loop.
  90229. * @returns the GroundMesh.
  90230. */
  90231. updateCoordinateHeights(): GroundMesh;
  90232. private _getFacetAt;
  90233. private _initHeightQuads;
  90234. private _computeHeightQuads;
  90235. /**
  90236. * Serializes this ground mesh
  90237. * @param serializationObject object to write serialization to
  90238. */
  90239. serialize(serializationObject: any): void;
  90240. /**
  90241. * Parses a serialized ground mesh
  90242. * @param parsedMesh the serialized mesh
  90243. * @param scene the scene to create the ground mesh in
  90244. * @returns the created ground mesh
  90245. */
  90246. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90247. }
  90248. }
  90249. declare module BABYLON {
  90250. /**
  90251. * Interface for Physics-Joint data
  90252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90253. */
  90254. export interface PhysicsJointData {
  90255. /**
  90256. * The main pivot of the joint
  90257. */
  90258. mainPivot?: Vector3;
  90259. /**
  90260. * The connected pivot of the joint
  90261. */
  90262. connectedPivot?: Vector3;
  90263. /**
  90264. * The main axis of the joint
  90265. */
  90266. mainAxis?: Vector3;
  90267. /**
  90268. * The connected axis of the joint
  90269. */
  90270. connectedAxis?: Vector3;
  90271. /**
  90272. * The collision of the joint
  90273. */
  90274. collision?: boolean;
  90275. /**
  90276. * Native Oimo/Cannon/Energy data
  90277. */
  90278. nativeParams?: any;
  90279. }
  90280. /**
  90281. * This is a holder class for the physics joint created by the physics plugin
  90282. * It holds a set of functions to control the underlying joint
  90283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90284. */
  90285. export class PhysicsJoint {
  90286. /**
  90287. * The type of the physics joint
  90288. */
  90289. type: number;
  90290. /**
  90291. * The data for the physics joint
  90292. */
  90293. jointData: PhysicsJointData;
  90294. private _physicsJoint;
  90295. protected _physicsPlugin: IPhysicsEnginePlugin;
  90296. /**
  90297. * Initializes the physics joint
  90298. * @param type The type of the physics joint
  90299. * @param jointData The data for the physics joint
  90300. */
  90301. constructor(
  90302. /**
  90303. * The type of the physics joint
  90304. */
  90305. type: number,
  90306. /**
  90307. * The data for the physics joint
  90308. */
  90309. jointData: PhysicsJointData);
  90310. /**
  90311. * Gets the physics joint
  90312. */
  90313. /**
  90314. * Sets the physics joint
  90315. */
  90316. physicsJoint: any;
  90317. /**
  90318. * Sets the physics plugin
  90319. */
  90320. physicsPlugin: IPhysicsEnginePlugin;
  90321. /**
  90322. * Execute a function that is physics-plugin specific.
  90323. * @param {Function} func the function that will be executed.
  90324. * It accepts two parameters: the physics world and the physics joint
  90325. */
  90326. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90327. /**
  90328. * Distance-Joint type
  90329. */
  90330. static DistanceJoint: number;
  90331. /**
  90332. * Hinge-Joint type
  90333. */
  90334. static HingeJoint: number;
  90335. /**
  90336. * Ball-and-Socket joint type
  90337. */
  90338. static BallAndSocketJoint: number;
  90339. /**
  90340. * Wheel-Joint type
  90341. */
  90342. static WheelJoint: number;
  90343. /**
  90344. * Slider-Joint type
  90345. */
  90346. static SliderJoint: number;
  90347. /**
  90348. * Prismatic-Joint type
  90349. */
  90350. static PrismaticJoint: number;
  90351. /**
  90352. * Universal-Joint type
  90353. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90354. */
  90355. static UniversalJoint: number;
  90356. /**
  90357. * Hinge-Joint 2 type
  90358. */
  90359. static Hinge2Joint: number;
  90360. /**
  90361. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90362. */
  90363. static PointToPointJoint: number;
  90364. /**
  90365. * Spring-Joint type
  90366. */
  90367. static SpringJoint: number;
  90368. /**
  90369. * Lock-Joint type
  90370. */
  90371. static LockJoint: number;
  90372. }
  90373. /**
  90374. * A class representing a physics distance joint
  90375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90376. */
  90377. export class DistanceJoint extends PhysicsJoint {
  90378. /**
  90379. *
  90380. * @param jointData The data for the Distance-Joint
  90381. */
  90382. constructor(jointData: DistanceJointData);
  90383. /**
  90384. * Update the predefined distance.
  90385. * @param maxDistance The maximum preferred distance
  90386. * @param minDistance The minimum preferred distance
  90387. */
  90388. updateDistance(maxDistance: number, minDistance?: number): void;
  90389. }
  90390. /**
  90391. * Represents a Motor-Enabled Joint
  90392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90393. */
  90394. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90395. /**
  90396. * Initializes the Motor-Enabled Joint
  90397. * @param type The type of the joint
  90398. * @param jointData The physica joint data for the joint
  90399. */
  90400. constructor(type: number, jointData: PhysicsJointData);
  90401. /**
  90402. * Set the motor values.
  90403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90404. * @param force the force to apply
  90405. * @param maxForce max force for this motor.
  90406. */
  90407. setMotor(force?: number, maxForce?: number): void;
  90408. /**
  90409. * Set the motor's limits.
  90410. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90411. * @param upperLimit The upper limit of the motor
  90412. * @param lowerLimit The lower limit of the motor
  90413. */
  90414. setLimit(upperLimit: number, lowerLimit?: number): void;
  90415. }
  90416. /**
  90417. * This class represents a single physics Hinge-Joint
  90418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90419. */
  90420. export class HingeJoint extends MotorEnabledJoint {
  90421. /**
  90422. * Initializes the Hinge-Joint
  90423. * @param jointData The joint data for the Hinge-Joint
  90424. */
  90425. constructor(jointData: PhysicsJointData);
  90426. /**
  90427. * Set the motor values.
  90428. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90429. * @param {number} force the force to apply
  90430. * @param {number} maxForce max force for this motor.
  90431. */
  90432. setMotor(force?: number, maxForce?: number): void;
  90433. /**
  90434. * Set the motor's limits.
  90435. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90436. * @param upperLimit The upper limit of the motor
  90437. * @param lowerLimit The lower limit of the motor
  90438. */
  90439. setLimit(upperLimit: number, lowerLimit?: number): void;
  90440. }
  90441. /**
  90442. * This class represents a dual hinge physics joint (same as wheel joint)
  90443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90444. */
  90445. export class Hinge2Joint extends MotorEnabledJoint {
  90446. /**
  90447. * Initializes the Hinge2-Joint
  90448. * @param jointData The joint data for the Hinge2-Joint
  90449. */
  90450. constructor(jointData: PhysicsJointData);
  90451. /**
  90452. * Set the motor values.
  90453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90454. * @param {number} targetSpeed the speed the motor is to reach
  90455. * @param {number} maxForce max force for this motor.
  90456. * @param {motorIndex} the motor's index, 0 or 1.
  90457. */
  90458. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90459. /**
  90460. * Set the motor limits.
  90461. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90462. * @param {number} upperLimit the upper limit
  90463. * @param {number} lowerLimit lower limit
  90464. * @param {motorIndex} the motor's index, 0 or 1.
  90465. */
  90466. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90467. }
  90468. /**
  90469. * Interface for a motor enabled joint
  90470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90471. */
  90472. export interface IMotorEnabledJoint {
  90473. /**
  90474. * Physics joint
  90475. */
  90476. physicsJoint: any;
  90477. /**
  90478. * Sets the motor of the motor-enabled joint
  90479. * @param force The force of the motor
  90480. * @param maxForce The maximum force of the motor
  90481. * @param motorIndex The index of the motor
  90482. */
  90483. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90484. /**
  90485. * Sets the limit of the motor
  90486. * @param upperLimit The upper limit of the motor
  90487. * @param lowerLimit The lower limit of the motor
  90488. * @param motorIndex The index of the motor
  90489. */
  90490. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90491. }
  90492. /**
  90493. * Joint data for a Distance-Joint
  90494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90495. */
  90496. export interface DistanceJointData extends PhysicsJointData {
  90497. /**
  90498. * Max distance the 2 joint objects can be apart
  90499. */
  90500. maxDistance: number;
  90501. }
  90502. /**
  90503. * Joint data from a spring joint
  90504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90505. */
  90506. export interface SpringJointData extends PhysicsJointData {
  90507. /**
  90508. * Length of the spring
  90509. */
  90510. length: number;
  90511. /**
  90512. * Stiffness of the spring
  90513. */
  90514. stiffness: number;
  90515. /**
  90516. * Damping of the spring
  90517. */
  90518. damping: number;
  90519. /** this callback will be called when applying the force to the impostors. */
  90520. forceApplicationCallback: () => void;
  90521. }
  90522. }
  90523. declare module BABYLON {
  90524. /**
  90525. * Holds the data for the raycast result
  90526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90527. */
  90528. export class PhysicsRaycastResult {
  90529. private _hasHit;
  90530. private _hitDistance;
  90531. private _hitNormalWorld;
  90532. private _hitPointWorld;
  90533. private _rayFromWorld;
  90534. private _rayToWorld;
  90535. /**
  90536. * Gets if there was a hit
  90537. */
  90538. readonly hasHit: boolean;
  90539. /**
  90540. * Gets the distance from the hit
  90541. */
  90542. readonly hitDistance: number;
  90543. /**
  90544. * Gets the hit normal/direction in the world
  90545. */
  90546. readonly hitNormalWorld: Vector3;
  90547. /**
  90548. * Gets the hit point in the world
  90549. */
  90550. readonly hitPointWorld: Vector3;
  90551. /**
  90552. * Gets the ray "start point" of the ray in the world
  90553. */
  90554. readonly rayFromWorld: Vector3;
  90555. /**
  90556. * Gets the ray "end point" of the ray in the world
  90557. */
  90558. readonly rayToWorld: Vector3;
  90559. /**
  90560. * Sets the hit data (normal & point in world space)
  90561. * @param hitNormalWorld defines the normal in world space
  90562. * @param hitPointWorld defines the point in world space
  90563. */
  90564. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90565. /**
  90566. * Sets the distance from the start point to the hit point
  90567. * @param distance
  90568. */
  90569. setHitDistance(distance: number): void;
  90570. /**
  90571. * Calculates the distance manually
  90572. */
  90573. calculateHitDistance(): void;
  90574. /**
  90575. * Resets all the values to default
  90576. * @param from The from point on world space
  90577. * @param to The to point on world space
  90578. */
  90579. reset(from?: Vector3, to?: Vector3): void;
  90580. }
  90581. /**
  90582. * Interface for the size containing width and height
  90583. */
  90584. interface IXYZ {
  90585. /**
  90586. * X
  90587. */
  90588. x: number;
  90589. /**
  90590. * Y
  90591. */
  90592. y: number;
  90593. /**
  90594. * Z
  90595. */
  90596. z: number;
  90597. }
  90598. }
  90599. declare module BABYLON {
  90600. /**
  90601. * Interface used to describe a physics joint
  90602. */
  90603. export interface PhysicsImpostorJoint {
  90604. /** Defines the main impostor to which the joint is linked */
  90605. mainImpostor: PhysicsImpostor;
  90606. /** Defines the impostor that is connected to the main impostor using this joint */
  90607. connectedImpostor: PhysicsImpostor;
  90608. /** Defines the joint itself */
  90609. joint: PhysicsJoint;
  90610. }
  90611. /** @hidden */
  90612. export interface IPhysicsEnginePlugin {
  90613. world: any;
  90614. name: string;
  90615. setGravity(gravity: Vector3): void;
  90616. setTimeStep(timeStep: number): void;
  90617. getTimeStep(): number;
  90618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90620. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90622. removePhysicsBody(impostor: PhysicsImpostor): void;
  90623. generateJoint(joint: PhysicsImpostorJoint): void;
  90624. removeJoint(joint: PhysicsImpostorJoint): void;
  90625. isSupported(): boolean;
  90626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90633. getBodyMass(impostor: PhysicsImpostor): number;
  90634. getBodyFriction(impostor: PhysicsImpostor): number;
  90635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90636. getBodyRestitution(impostor: PhysicsImpostor): number;
  90637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90638. getBodyPressure?(impostor: PhysicsImpostor): number;
  90639. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90640. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90641. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90642. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90643. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90644. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90645. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90646. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90647. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90648. sleepBody(impostor: PhysicsImpostor): void;
  90649. wakeUpBody(impostor: PhysicsImpostor): void;
  90650. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90652. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90654. getRadius(impostor: PhysicsImpostor): number;
  90655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90657. dispose(): void;
  90658. }
  90659. /**
  90660. * Interface used to define a physics engine
  90661. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90662. */
  90663. export interface IPhysicsEngine {
  90664. /**
  90665. * Gets the gravity vector used by the simulation
  90666. */
  90667. gravity: Vector3;
  90668. /**
  90669. * Sets the gravity vector used by the simulation
  90670. * @param gravity defines the gravity vector to use
  90671. */
  90672. setGravity(gravity: Vector3): void;
  90673. /**
  90674. * Set the time step of the physics engine.
  90675. * Default is 1/60.
  90676. * To slow it down, enter 1/600 for example.
  90677. * To speed it up, 1/30
  90678. * @param newTimeStep the new timestep to apply to this world.
  90679. */
  90680. setTimeStep(newTimeStep: number): void;
  90681. /**
  90682. * Get the time step of the physics engine.
  90683. * @returns the current time step
  90684. */
  90685. getTimeStep(): number;
  90686. /**
  90687. * Release all resources
  90688. */
  90689. dispose(): void;
  90690. /**
  90691. * Gets the name of the current physics plugin
  90692. * @returns the name of the plugin
  90693. */
  90694. getPhysicsPluginName(): string;
  90695. /**
  90696. * Adding a new impostor for the impostor tracking.
  90697. * This will be done by the impostor itself.
  90698. * @param impostor the impostor to add
  90699. */
  90700. addImpostor(impostor: PhysicsImpostor): void;
  90701. /**
  90702. * Remove an impostor from the engine.
  90703. * This impostor and its mesh will not longer be updated by the physics engine.
  90704. * @param impostor the impostor to remove
  90705. */
  90706. removeImpostor(impostor: PhysicsImpostor): void;
  90707. /**
  90708. * Add a joint to the physics engine
  90709. * @param mainImpostor defines the main impostor to which the joint is added.
  90710. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90711. * @param joint defines the joint that will connect both impostors.
  90712. */
  90713. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90714. /**
  90715. * Removes a joint from the simulation
  90716. * @param mainImpostor defines the impostor used with the joint
  90717. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90718. * @param joint defines the joint to remove
  90719. */
  90720. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90721. /**
  90722. * Gets the current plugin used to run the simulation
  90723. * @returns current plugin
  90724. */
  90725. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90726. /**
  90727. * Gets the list of physic impostors
  90728. * @returns an array of PhysicsImpostor
  90729. */
  90730. getImpostors(): Array<PhysicsImpostor>;
  90731. /**
  90732. * Gets the impostor for a physics enabled object
  90733. * @param object defines the object impersonated by the impostor
  90734. * @returns the PhysicsImpostor or null if not found
  90735. */
  90736. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90737. /**
  90738. * Gets the impostor for a physics body object
  90739. * @param body defines physics body used by the impostor
  90740. * @returns the PhysicsImpostor or null if not found
  90741. */
  90742. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90743. /**
  90744. * Does a raycast in the physics world
  90745. * @param from when should the ray start?
  90746. * @param to when should the ray end?
  90747. * @returns PhysicsRaycastResult
  90748. */
  90749. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90750. /**
  90751. * Called by the scene. No need to call it.
  90752. * @param delta defines the timespam between frames
  90753. */
  90754. _step(delta: number): void;
  90755. }
  90756. }
  90757. declare module BABYLON {
  90758. /**
  90759. * The interface for the physics imposter parameters
  90760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90761. */
  90762. export interface PhysicsImpostorParameters {
  90763. /**
  90764. * The mass of the physics imposter
  90765. */
  90766. mass: number;
  90767. /**
  90768. * The friction of the physics imposter
  90769. */
  90770. friction?: number;
  90771. /**
  90772. * The coefficient of restitution of the physics imposter
  90773. */
  90774. restitution?: number;
  90775. /**
  90776. * The native options of the physics imposter
  90777. */
  90778. nativeOptions?: any;
  90779. /**
  90780. * Specifies if the parent should be ignored
  90781. */
  90782. ignoreParent?: boolean;
  90783. /**
  90784. * Specifies if bi-directional transformations should be disabled
  90785. */
  90786. disableBidirectionalTransformation?: boolean;
  90787. /**
  90788. * The pressure inside the physics imposter, soft object only
  90789. */
  90790. pressure?: number;
  90791. /**
  90792. * The stiffness the physics imposter, soft object only
  90793. */
  90794. stiffness?: number;
  90795. /**
  90796. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90797. */
  90798. velocityIterations?: number;
  90799. /**
  90800. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90801. */
  90802. positionIterations?: number;
  90803. /**
  90804. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90805. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90806. * Add to fix multiple points
  90807. */
  90808. fixedPoints?: number;
  90809. /**
  90810. * The collision margin around a soft object
  90811. */
  90812. margin?: number;
  90813. /**
  90814. * The collision margin around a soft object
  90815. */
  90816. damping?: number;
  90817. /**
  90818. * The path for a rope based on an extrusion
  90819. */
  90820. path?: any;
  90821. /**
  90822. * The shape of an extrusion used for a rope based on an extrusion
  90823. */
  90824. shape?: any;
  90825. }
  90826. /**
  90827. * Interface for a physics-enabled object
  90828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90829. */
  90830. export interface IPhysicsEnabledObject {
  90831. /**
  90832. * The position of the physics-enabled object
  90833. */
  90834. position: Vector3;
  90835. /**
  90836. * The rotation of the physics-enabled object
  90837. */
  90838. rotationQuaternion: Nullable<Quaternion>;
  90839. /**
  90840. * The scale of the physics-enabled object
  90841. */
  90842. scaling: Vector3;
  90843. /**
  90844. * The rotation of the physics-enabled object
  90845. */
  90846. rotation?: Vector3;
  90847. /**
  90848. * The parent of the physics-enabled object
  90849. */
  90850. parent?: any;
  90851. /**
  90852. * The bounding info of the physics-enabled object
  90853. * @returns The bounding info of the physics-enabled object
  90854. */
  90855. getBoundingInfo(): BoundingInfo;
  90856. /**
  90857. * Computes the world matrix
  90858. * @param force Specifies if the world matrix should be computed by force
  90859. * @returns A world matrix
  90860. */
  90861. computeWorldMatrix(force: boolean): Matrix;
  90862. /**
  90863. * Gets the world matrix
  90864. * @returns A world matrix
  90865. */
  90866. getWorldMatrix?(): Matrix;
  90867. /**
  90868. * Gets the child meshes
  90869. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90870. * @returns An array of abstract meshes
  90871. */
  90872. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90873. /**
  90874. * Gets the vertex data
  90875. * @param kind The type of vertex data
  90876. * @returns A nullable array of numbers, or a float32 array
  90877. */
  90878. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90879. /**
  90880. * Gets the indices from the mesh
  90881. * @returns A nullable array of index arrays
  90882. */
  90883. getIndices?(): Nullable<IndicesArray>;
  90884. /**
  90885. * Gets the scene from the mesh
  90886. * @returns the indices array or null
  90887. */
  90888. getScene?(): Scene;
  90889. /**
  90890. * Gets the absolute position from the mesh
  90891. * @returns the absolute position
  90892. */
  90893. getAbsolutePosition(): Vector3;
  90894. /**
  90895. * Gets the absolute pivot point from the mesh
  90896. * @returns the absolute pivot point
  90897. */
  90898. getAbsolutePivotPoint(): Vector3;
  90899. /**
  90900. * Rotates the mesh
  90901. * @param axis The axis of rotation
  90902. * @param amount The amount of rotation
  90903. * @param space The space of the rotation
  90904. * @returns The rotation transform node
  90905. */
  90906. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90907. /**
  90908. * Translates the mesh
  90909. * @param axis The axis of translation
  90910. * @param distance The distance of translation
  90911. * @param space The space of the translation
  90912. * @returns The transform node
  90913. */
  90914. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90915. /**
  90916. * Sets the absolute position of the mesh
  90917. * @param absolutePosition The absolute position of the mesh
  90918. * @returns The transform node
  90919. */
  90920. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90921. /**
  90922. * Gets the class name of the mesh
  90923. * @returns The class name
  90924. */
  90925. getClassName(): string;
  90926. }
  90927. /**
  90928. * Represents a physics imposter
  90929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90930. */
  90931. export class PhysicsImpostor {
  90932. /**
  90933. * The physics-enabled object used as the physics imposter
  90934. */
  90935. object: IPhysicsEnabledObject;
  90936. /**
  90937. * The type of the physics imposter
  90938. */
  90939. type: number;
  90940. private _options;
  90941. private _scene?;
  90942. /**
  90943. * The default object size of the imposter
  90944. */
  90945. static DEFAULT_OBJECT_SIZE: Vector3;
  90946. /**
  90947. * The identity quaternion of the imposter
  90948. */
  90949. static IDENTITY_QUATERNION: Quaternion;
  90950. /** @hidden */
  90951. _pluginData: any;
  90952. private _physicsEngine;
  90953. private _physicsBody;
  90954. private _bodyUpdateRequired;
  90955. private _onBeforePhysicsStepCallbacks;
  90956. private _onAfterPhysicsStepCallbacks;
  90957. /** @hidden */
  90958. _onPhysicsCollideCallbacks: Array<{
  90959. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90960. otherImpostors: Array<PhysicsImpostor>;
  90961. }>;
  90962. private _deltaPosition;
  90963. private _deltaRotation;
  90964. private _deltaRotationConjugated;
  90965. /** @hidden */
  90966. _isFromLine: boolean;
  90967. private _parent;
  90968. private _isDisposed;
  90969. private static _tmpVecs;
  90970. private static _tmpQuat;
  90971. /**
  90972. * Specifies if the physics imposter is disposed
  90973. */
  90974. readonly isDisposed: boolean;
  90975. /**
  90976. * Gets the mass of the physics imposter
  90977. */
  90978. mass: number;
  90979. /**
  90980. * Gets the coefficient of friction
  90981. */
  90982. /**
  90983. * Sets the coefficient of friction
  90984. */
  90985. friction: number;
  90986. /**
  90987. * Gets the coefficient of restitution
  90988. */
  90989. /**
  90990. * Sets the coefficient of restitution
  90991. */
  90992. restitution: number;
  90993. /**
  90994. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90995. */
  90996. /**
  90997. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90998. */
  90999. pressure: number;
  91000. /**
  91001. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91002. */
  91003. /**
  91004. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91005. */
  91006. stiffness: number;
  91007. /**
  91008. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91009. */
  91010. /**
  91011. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91012. */
  91013. velocityIterations: number;
  91014. /**
  91015. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91016. */
  91017. /**
  91018. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91019. */
  91020. positionIterations: number;
  91021. /**
  91022. * The unique id of the physics imposter
  91023. * set by the physics engine when adding this impostor to the array
  91024. */
  91025. uniqueId: number;
  91026. /**
  91027. * @hidden
  91028. */
  91029. soft: boolean;
  91030. /**
  91031. * @hidden
  91032. */
  91033. segments: number;
  91034. private _joints;
  91035. /**
  91036. * Initializes the physics imposter
  91037. * @param object The physics-enabled object used as the physics imposter
  91038. * @param type The type of the physics imposter
  91039. * @param _options The options for the physics imposter
  91040. * @param _scene The Babylon scene
  91041. */
  91042. constructor(
  91043. /**
  91044. * The physics-enabled object used as the physics imposter
  91045. */
  91046. object: IPhysicsEnabledObject,
  91047. /**
  91048. * The type of the physics imposter
  91049. */
  91050. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91051. /**
  91052. * This function will completly initialize this impostor.
  91053. * It will create a new body - but only if this mesh has no parent.
  91054. * If it has, this impostor will not be used other than to define the impostor
  91055. * of the child mesh.
  91056. * @hidden
  91057. */
  91058. _init(): void;
  91059. private _getPhysicsParent;
  91060. /**
  91061. * Should a new body be generated.
  91062. * @returns boolean specifying if body initialization is required
  91063. */
  91064. isBodyInitRequired(): boolean;
  91065. /**
  91066. * Sets the updated scaling
  91067. * @param updated Specifies if the scaling is updated
  91068. */
  91069. setScalingUpdated(): void;
  91070. /**
  91071. * Force a regeneration of this or the parent's impostor's body.
  91072. * Use under cautious - This will remove all joints already implemented.
  91073. */
  91074. forceUpdate(): void;
  91075. /**
  91076. * Gets the body that holds this impostor. Either its own, or its parent.
  91077. */
  91078. /**
  91079. * Set the physics body. Used mainly by the physics engine/plugin
  91080. */
  91081. physicsBody: any;
  91082. /**
  91083. * Get the parent of the physics imposter
  91084. * @returns Physics imposter or null
  91085. */
  91086. /**
  91087. * Sets the parent of the physics imposter
  91088. */
  91089. parent: Nullable<PhysicsImpostor>;
  91090. /**
  91091. * Resets the update flags
  91092. */
  91093. resetUpdateFlags(): void;
  91094. /**
  91095. * Gets the object extend size
  91096. * @returns the object extend size
  91097. */
  91098. getObjectExtendSize(): Vector3;
  91099. /**
  91100. * Gets the object center
  91101. * @returns The object center
  91102. */
  91103. getObjectCenter(): Vector3;
  91104. /**
  91105. * Get a specific parametes from the options parameter
  91106. * @param paramName The object parameter name
  91107. * @returns The object parameter
  91108. */
  91109. getParam(paramName: string): any;
  91110. /**
  91111. * Sets a specific parameter in the options given to the physics plugin
  91112. * @param paramName The parameter name
  91113. * @param value The value of the parameter
  91114. */
  91115. setParam(paramName: string, value: number): void;
  91116. /**
  91117. * Specifically change the body's mass option. Won't recreate the physics body object
  91118. * @param mass The mass of the physics imposter
  91119. */
  91120. setMass(mass: number): void;
  91121. /**
  91122. * Gets the linear velocity
  91123. * @returns linear velocity or null
  91124. */
  91125. getLinearVelocity(): Nullable<Vector3>;
  91126. /**
  91127. * Sets the linear velocity
  91128. * @param velocity linear velocity or null
  91129. */
  91130. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91131. /**
  91132. * Gets the angular velocity
  91133. * @returns angular velocity or null
  91134. */
  91135. getAngularVelocity(): Nullable<Vector3>;
  91136. /**
  91137. * Sets the angular velocity
  91138. * @param velocity The velocity or null
  91139. */
  91140. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91141. /**
  91142. * Execute a function with the physics plugin native code
  91143. * Provide a function the will have two variables - the world object and the physics body object
  91144. * @param func The function to execute with the physics plugin native code
  91145. */
  91146. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91147. /**
  91148. * Register a function that will be executed before the physics world is stepping forward
  91149. * @param func The function to execute before the physics world is stepped forward
  91150. */
  91151. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91152. /**
  91153. * Unregister a function that will be executed before the physics world is stepping forward
  91154. * @param func The function to execute before the physics world is stepped forward
  91155. */
  91156. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91157. /**
  91158. * Register a function that will be executed after the physics step
  91159. * @param func The function to execute after physics step
  91160. */
  91161. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91162. /**
  91163. * Unregisters a function that will be executed after the physics step
  91164. * @param func The function to execute after physics step
  91165. */
  91166. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91167. /**
  91168. * register a function that will be executed when this impostor collides against a different body
  91169. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91170. * @param func Callback that is executed on collision
  91171. */
  91172. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91173. /**
  91174. * Unregisters the physics imposter on contact
  91175. * @param collideAgainst The physics object to collide against
  91176. * @param func Callback to execute on collision
  91177. */
  91178. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91179. private _tmpQuat;
  91180. private _tmpQuat2;
  91181. /**
  91182. * Get the parent rotation
  91183. * @returns The parent rotation
  91184. */
  91185. getParentsRotation(): Quaternion;
  91186. /**
  91187. * this function is executed by the physics engine.
  91188. */
  91189. beforeStep: () => void;
  91190. /**
  91191. * this function is executed by the physics engine
  91192. */
  91193. afterStep: () => void;
  91194. /**
  91195. * Legacy collision detection event support
  91196. */
  91197. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91198. /**
  91199. * event and body object due to cannon's event-based architecture.
  91200. */
  91201. onCollide: (e: {
  91202. body: any;
  91203. }) => void;
  91204. /**
  91205. * Apply a force
  91206. * @param force The force to apply
  91207. * @param contactPoint The contact point for the force
  91208. * @returns The physics imposter
  91209. */
  91210. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91211. /**
  91212. * Apply an impulse
  91213. * @param force The impulse force
  91214. * @param contactPoint The contact point for the impulse force
  91215. * @returns The physics imposter
  91216. */
  91217. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91218. /**
  91219. * A help function to create a joint
  91220. * @param otherImpostor A physics imposter used to create a joint
  91221. * @param jointType The type of joint
  91222. * @param jointData The data for the joint
  91223. * @returns The physics imposter
  91224. */
  91225. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91226. /**
  91227. * Add a joint to this impostor with a different impostor
  91228. * @param otherImpostor A physics imposter used to add a joint
  91229. * @param joint The joint to add
  91230. * @returns The physics imposter
  91231. */
  91232. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91233. /**
  91234. * Add an anchor to a cloth impostor
  91235. * @param otherImpostor rigid impostor to anchor to
  91236. * @param width ratio across width from 0 to 1
  91237. * @param height ratio up height from 0 to 1
  91238. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91239. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91240. * @returns impostor the soft imposter
  91241. */
  91242. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91243. /**
  91244. * Add a hook to a rope impostor
  91245. * @param otherImpostor rigid impostor to anchor to
  91246. * @param length ratio across rope from 0 to 1
  91247. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91248. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91249. * @returns impostor the rope imposter
  91250. */
  91251. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91252. /**
  91253. * Will keep this body still, in a sleep mode.
  91254. * @returns the physics imposter
  91255. */
  91256. sleep(): PhysicsImpostor;
  91257. /**
  91258. * Wake the body up.
  91259. * @returns The physics imposter
  91260. */
  91261. wakeUp(): PhysicsImpostor;
  91262. /**
  91263. * Clones the physics imposter
  91264. * @param newObject The physics imposter clones to this physics-enabled object
  91265. * @returns A nullable physics imposter
  91266. */
  91267. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91268. /**
  91269. * Disposes the physics imposter
  91270. */
  91271. dispose(): void;
  91272. /**
  91273. * Sets the delta position
  91274. * @param position The delta position amount
  91275. */
  91276. setDeltaPosition(position: Vector3): void;
  91277. /**
  91278. * Sets the delta rotation
  91279. * @param rotation The delta rotation amount
  91280. */
  91281. setDeltaRotation(rotation: Quaternion): void;
  91282. /**
  91283. * Gets the box size of the physics imposter and stores the result in the input parameter
  91284. * @param result Stores the box size
  91285. * @returns The physics imposter
  91286. */
  91287. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91288. /**
  91289. * Gets the radius of the physics imposter
  91290. * @returns Radius of the physics imposter
  91291. */
  91292. getRadius(): number;
  91293. /**
  91294. * Sync a bone with this impostor
  91295. * @param bone The bone to sync to the impostor.
  91296. * @param boneMesh The mesh that the bone is influencing.
  91297. * @param jointPivot The pivot of the joint / bone in local space.
  91298. * @param distToJoint Optional distance from the impostor to the joint.
  91299. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91300. */
  91301. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91302. /**
  91303. * Sync impostor to a bone
  91304. * @param bone The bone that the impostor will be synced to.
  91305. * @param boneMesh The mesh that the bone is influencing.
  91306. * @param jointPivot The pivot of the joint / bone in local space.
  91307. * @param distToJoint Optional distance from the impostor to the joint.
  91308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91309. * @param boneAxis Optional vector3 axis the bone is aligned with
  91310. */
  91311. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91312. /**
  91313. * No-Imposter type
  91314. */
  91315. static NoImpostor: number;
  91316. /**
  91317. * Sphere-Imposter type
  91318. */
  91319. static SphereImpostor: number;
  91320. /**
  91321. * Box-Imposter type
  91322. */
  91323. static BoxImpostor: number;
  91324. /**
  91325. * Plane-Imposter type
  91326. */
  91327. static PlaneImpostor: number;
  91328. /**
  91329. * Mesh-imposter type
  91330. */
  91331. static MeshImpostor: number;
  91332. /**
  91333. * Capsule-Impostor type (Ammo.js plugin only)
  91334. */
  91335. static CapsuleImpostor: number;
  91336. /**
  91337. * Cylinder-Imposter type
  91338. */
  91339. static CylinderImpostor: number;
  91340. /**
  91341. * Particle-Imposter type
  91342. */
  91343. static ParticleImpostor: number;
  91344. /**
  91345. * Heightmap-Imposter type
  91346. */
  91347. static HeightmapImpostor: number;
  91348. /**
  91349. * ConvexHull-Impostor type (Ammo.js plugin only)
  91350. */
  91351. static ConvexHullImpostor: number;
  91352. /**
  91353. * Rope-Imposter type
  91354. */
  91355. static RopeImpostor: number;
  91356. /**
  91357. * Cloth-Imposter type
  91358. */
  91359. static ClothImpostor: number;
  91360. /**
  91361. * Softbody-Imposter type
  91362. */
  91363. static SoftbodyImpostor: number;
  91364. }
  91365. }
  91366. declare module BABYLON {
  91367. /**
  91368. * @hidden
  91369. **/
  91370. export class _CreationDataStorage {
  91371. closePath?: boolean;
  91372. closeArray?: boolean;
  91373. idx: number[];
  91374. dashSize: number;
  91375. gapSize: number;
  91376. path3D: Path3D;
  91377. pathArray: Vector3[][];
  91378. arc: number;
  91379. radius: number;
  91380. cap: number;
  91381. tessellation: number;
  91382. }
  91383. /**
  91384. * @hidden
  91385. **/
  91386. class _InstanceDataStorage {
  91387. visibleInstances: any;
  91388. batchCache: _InstancesBatch;
  91389. instancesBufferSize: number;
  91390. instancesBuffer: Nullable<Buffer>;
  91391. instancesData: Float32Array;
  91392. overridenInstanceCount: number;
  91393. isFrozen: boolean;
  91394. previousBatch: Nullable<_InstancesBatch>;
  91395. hardwareInstancedRendering: boolean;
  91396. sideOrientation: number;
  91397. }
  91398. /**
  91399. * @hidden
  91400. **/
  91401. export class _InstancesBatch {
  91402. mustReturn: boolean;
  91403. visibleInstances: Nullable<InstancedMesh[]>[];
  91404. renderSelf: boolean[];
  91405. hardwareInstancedRendering: boolean[];
  91406. }
  91407. /**
  91408. * Class used to represent renderable models
  91409. */
  91410. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91411. /**
  91412. * Mesh side orientation : usually the external or front surface
  91413. */
  91414. static readonly FRONTSIDE: number;
  91415. /**
  91416. * Mesh side orientation : usually the internal or back surface
  91417. */
  91418. static readonly BACKSIDE: number;
  91419. /**
  91420. * Mesh side orientation : both internal and external or front and back surfaces
  91421. */
  91422. static readonly DOUBLESIDE: number;
  91423. /**
  91424. * Mesh side orientation : by default, `FRONTSIDE`
  91425. */
  91426. static readonly DEFAULTSIDE: number;
  91427. /**
  91428. * Mesh cap setting : no cap
  91429. */
  91430. static readonly NO_CAP: number;
  91431. /**
  91432. * Mesh cap setting : one cap at the beginning of the mesh
  91433. */
  91434. static readonly CAP_START: number;
  91435. /**
  91436. * Mesh cap setting : one cap at the end of the mesh
  91437. */
  91438. static readonly CAP_END: number;
  91439. /**
  91440. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91441. */
  91442. static readonly CAP_ALL: number;
  91443. /**
  91444. * Mesh pattern setting : no flip or rotate
  91445. */
  91446. static readonly NO_FLIP: number;
  91447. /**
  91448. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91449. */
  91450. static readonly FLIP_TILE: number;
  91451. /**
  91452. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91453. */
  91454. static readonly ROTATE_TILE: number;
  91455. /**
  91456. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91457. */
  91458. static readonly FLIP_ROW: number;
  91459. /**
  91460. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91461. */
  91462. static readonly ROTATE_ROW: number;
  91463. /**
  91464. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91465. */
  91466. static readonly FLIP_N_ROTATE_TILE: number;
  91467. /**
  91468. * Mesh pattern setting : rotate pattern and rotate
  91469. */
  91470. static readonly FLIP_N_ROTATE_ROW: number;
  91471. /**
  91472. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91473. */
  91474. static readonly CENTER: number;
  91475. /**
  91476. * Mesh tile positioning : part tiles on left
  91477. */
  91478. static readonly LEFT: number;
  91479. /**
  91480. * Mesh tile positioning : part tiles on right
  91481. */
  91482. static readonly RIGHT: number;
  91483. /**
  91484. * Mesh tile positioning : part tiles on top
  91485. */
  91486. static readonly TOP: number;
  91487. /**
  91488. * Mesh tile positioning : part tiles on bottom
  91489. */
  91490. static readonly BOTTOM: number;
  91491. /**
  91492. * Gets the default side orientation.
  91493. * @param orientation the orientation to value to attempt to get
  91494. * @returns the default orientation
  91495. * @hidden
  91496. */
  91497. static _GetDefaultSideOrientation(orientation?: number): number;
  91498. private _internalMeshDataInfo;
  91499. /**
  91500. * An event triggered before rendering the mesh
  91501. */
  91502. readonly onBeforeRenderObservable: Observable<Mesh>;
  91503. /**
  91504. * An event triggered before binding the mesh
  91505. */
  91506. readonly onBeforeBindObservable: Observable<Mesh>;
  91507. /**
  91508. * An event triggered after rendering the mesh
  91509. */
  91510. readonly onAfterRenderObservable: Observable<Mesh>;
  91511. /**
  91512. * An event triggered before drawing the mesh
  91513. */
  91514. readonly onBeforeDrawObservable: Observable<Mesh>;
  91515. private _onBeforeDrawObserver;
  91516. /**
  91517. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91518. */
  91519. onBeforeDraw: () => void;
  91520. readonly hasInstances: boolean;
  91521. /**
  91522. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91523. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91524. */
  91525. delayLoadState: number;
  91526. /**
  91527. * Gets the list of instances created from this mesh
  91528. * it is not supposed to be modified manually.
  91529. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91530. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91531. */
  91532. instances: InstancedMesh[];
  91533. /**
  91534. * Gets the file containing delay loading data for this mesh
  91535. */
  91536. delayLoadingFile: string;
  91537. /** @hidden */
  91538. _binaryInfo: any;
  91539. /**
  91540. * User defined function used to change how LOD level selection is done
  91541. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91542. */
  91543. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91544. /**
  91545. * Gets or sets the morph target manager
  91546. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91547. */
  91548. morphTargetManager: Nullable<MorphTargetManager>;
  91549. /** @hidden */
  91550. _creationDataStorage: Nullable<_CreationDataStorage>;
  91551. /** @hidden */
  91552. _geometry: Nullable<Geometry>;
  91553. /** @hidden */
  91554. _delayInfo: Array<string>;
  91555. /** @hidden */
  91556. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91557. /** @hidden */
  91558. _instanceDataStorage: _InstanceDataStorage;
  91559. private _effectiveMaterial;
  91560. /** @hidden */
  91561. _shouldGenerateFlatShading: boolean;
  91562. /** @hidden */
  91563. _originalBuilderSideOrientation: number;
  91564. /**
  91565. * Use this property to change the original side orientation defined at construction time
  91566. */
  91567. overrideMaterialSideOrientation: Nullable<number>;
  91568. /**
  91569. * Gets the source mesh (the one used to clone this one from)
  91570. */
  91571. readonly source: Nullable<Mesh>;
  91572. /**
  91573. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91574. */
  91575. isUnIndexed: boolean;
  91576. /**
  91577. * @constructor
  91578. * @param name The value used by scene.getMeshByName() to do a lookup.
  91579. * @param scene The scene to add this mesh to.
  91580. * @param parent The parent of this mesh, if it has one
  91581. * @param source An optional Mesh from which geometry is shared, cloned.
  91582. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91583. * When false, achieved by calling a clone(), also passing False.
  91584. * This will make creation of children, recursive.
  91585. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91586. */
  91587. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91588. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91589. doNotInstantiate: boolean;
  91590. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91591. /**
  91592. * Gets the class name
  91593. * @returns the string "Mesh".
  91594. */
  91595. getClassName(): string;
  91596. /** @hidden */
  91597. readonly _isMesh: boolean;
  91598. /**
  91599. * Returns a description of this mesh
  91600. * @param fullDetails define if full details about this mesh must be used
  91601. * @returns a descriptive string representing this mesh
  91602. */
  91603. toString(fullDetails?: boolean): string;
  91604. /** @hidden */
  91605. _unBindEffect(): void;
  91606. /**
  91607. * Gets a boolean indicating if this mesh has LOD
  91608. */
  91609. readonly hasLODLevels: boolean;
  91610. /**
  91611. * Gets the list of MeshLODLevel associated with the current mesh
  91612. * @returns an array of MeshLODLevel
  91613. */
  91614. getLODLevels(): MeshLODLevel[];
  91615. private _sortLODLevels;
  91616. /**
  91617. * Add a mesh as LOD level triggered at the given distance.
  91618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91619. * @param distance The distance from the center of the object to show this level
  91620. * @param mesh The mesh to be added as LOD level (can be null)
  91621. * @return This mesh (for chaining)
  91622. */
  91623. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91624. /**
  91625. * Returns the LOD level mesh at the passed distance or null if not found.
  91626. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91627. * @param distance The distance from the center of the object to show this level
  91628. * @returns a Mesh or `null`
  91629. */
  91630. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91631. /**
  91632. * Remove a mesh from the LOD array
  91633. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91634. * @param mesh defines the mesh to be removed
  91635. * @return This mesh (for chaining)
  91636. */
  91637. removeLODLevel(mesh: Mesh): Mesh;
  91638. /**
  91639. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91640. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91641. * @param camera defines the camera to use to compute distance
  91642. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91643. * @return This mesh (for chaining)
  91644. */
  91645. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91646. /**
  91647. * Gets the mesh internal Geometry object
  91648. */
  91649. readonly geometry: Nullable<Geometry>;
  91650. /**
  91651. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91652. * @returns the total number of vertices
  91653. */
  91654. getTotalVertices(): number;
  91655. /**
  91656. * Returns the content of an associated vertex buffer
  91657. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91658. * - VertexBuffer.PositionKind
  91659. * - VertexBuffer.UVKind
  91660. * - VertexBuffer.UV2Kind
  91661. * - VertexBuffer.UV3Kind
  91662. * - VertexBuffer.UV4Kind
  91663. * - VertexBuffer.UV5Kind
  91664. * - VertexBuffer.UV6Kind
  91665. * - VertexBuffer.ColorKind
  91666. * - VertexBuffer.MatricesIndicesKind
  91667. * - VertexBuffer.MatricesIndicesExtraKind
  91668. * - VertexBuffer.MatricesWeightsKind
  91669. * - VertexBuffer.MatricesWeightsExtraKind
  91670. * @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
  91671. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91672. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91673. */
  91674. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91675. /**
  91676. * Returns the mesh VertexBuffer object from the requested `kind`
  91677. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91678. * - VertexBuffer.PositionKind
  91679. * - VertexBuffer.NormalKind
  91680. * - VertexBuffer.UVKind
  91681. * - VertexBuffer.UV2Kind
  91682. * - VertexBuffer.UV3Kind
  91683. * - VertexBuffer.UV4Kind
  91684. * - VertexBuffer.UV5Kind
  91685. * - VertexBuffer.UV6Kind
  91686. * - VertexBuffer.ColorKind
  91687. * - VertexBuffer.MatricesIndicesKind
  91688. * - VertexBuffer.MatricesIndicesExtraKind
  91689. * - VertexBuffer.MatricesWeightsKind
  91690. * - VertexBuffer.MatricesWeightsExtraKind
  91691. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91692. */
  91693. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91694. /**
  91695. * Tests if a specific vertex buffer is associated with this mesh
  91696. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91697. * - VertexBuffer.PositionKind
  91698. * - VertexBuffer.NormalKind
  91699. * - VertexBuffer.UVKind
  91700. * - VertexBuffer.UV2Kind
  91701. * - VertexBuffer.UV3Kind
  91702. * - VertexBuffer.UV4Kind
  91703. * - VertexBuffer.UV5Kind
  91704. * - VertexBuffer.UV6Kind
  91705. * - VertexBuffer.ColorKind
  91706. * - VertexBuffer.MatricesIndicesKind
  91707. * - VertexBuffer.MatricesIndicesExtraKind
  91708. * - VertexBuffer.MatricesWeightsKind
  91709. * - VertexBuffer.MatricesWeightsExtraKind
  91710. * @returns a boolean
  91711. */
  91712. isVerticesDataPresent(kind: string): boolean;
  91713. /**
  91714. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91715. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91716. * - VertexBuffer.PositionKind
  91717. * - VertexBuffer.UVKind
  91718. * - VertexBuffer.UV2Kind
  91719. * - VertexBuffer.UV3Kind
  91720. * - VertexBuffer.UV4Kind
  91721. * - VertexBuffer.UV5Kind
  91722. * - VertexBuffer.UV6Kind
  91723. * - VertexBuffer.ColorKind
  91724. * - VertexBuffer.MatricesIndicesKind
  91725. * - VertexBuffer.MatricesIndicesExtraKind
  91726. * - VertexBuffer.MatricesWeightsKind
  91727. * - VertexBuffer.MatricesWeightsExtraKind
  91728. * @returns a boolean
  91729. */
  91730. isVertexBufferUpdatable(kind: string): boolean;
  91731. /**
  91732. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91733. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91734. * - VertexBuffer.PositionKind
  91735. * - VertexBuffer.NormalKind
  91736. * - VertexBuffer.UVKind
  91737. * - VertexBuffer.UV2Kind
  91738. * - VertexBuffer.UV3Kind
  91739. * - VertexBuffer.UV4Kind
  91740. * - VertexBuffer.UV5Kind
  91741. * - VertexBuffer.UV6Kind
  91742. * - VertexBuffer.ColorKind
  91743. * - VertexBuffer.MatricesIndicesKind
  91744. * - VertexBuffer.MatricesIndicesExtraKind
  91745. * - VertexBuffer.MatricesWeightsKind
  91746. * - VertexBuffer.MatricesWeightsExtraKind
  91747. * @returns an array of strings
  91748. */
  91749. getVerticesDataKinds(): string[];
  91750. /**
  91751. * Returns a positive integer : the total number of indices in this mesh geometry.
  91752. * @returns the numner of indices or zero if the mesh has no geometry.
  91753. */
  91754. getTotalIndices(): number;
  91755. /**
  91756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91757. * @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.
  91758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91759. * @returns the indices array or an empty array if the mesh has no geometry
  91760. */
  91761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91762. readonly isBlocked: boolean;
  91763. /**
  91764. * Determine if the current mesh is ready to be rendered
  91765. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91766. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91767. * @returns true if all associated assets are ready (material, textures, shaders)
  91768. */
  91769. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91770. /**
  91771. * 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.
  91772. */
  91773. readonly areNormalsFrozen: boolean;
  91774. /**
  91775. * 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.
  91776. * @returns the current mesh
  91777. */
  91778. freezeNormals(): Mesh;
  91779. /**
  91780. * 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
  91781. * @returns the current mesh
  91782. */
  91783. unfreezeNormals(): Mesh;
  91784. /**
  91785. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91786. */
  91787. overridenInstanceCount: number;
  91788. /** @hidden */
  91789. _preActivate(): Mesh;
  91790. /** @hidden */
  91791. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91792. /** @hidden */
  91793. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91794. /**
  91795. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91796. * This means the mesh underlying bounding box and sphere are recomputed.
  91797. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91798. * @returns the current mesh
  91799. */
  91800. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91801. /** @hidden */
  91802. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91803. /**
  91804. * This function will subdivide the mesh into multiple submeshes
  91805. * @param count defines the expected number of submeshes
  91806. */
  91807. subdivide(count: number): void;
  91808. /**
  91809. * Copy a FloatArray into a specific associated vertex buffer
  91810. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91811. * - VertexBuffer.PositionKind
  91812. * - VertexBuffer.UVKind
  91813. * - VertexBuffer.UV2Kind
  91814. * - VertexBuffer.UV3Kind
  91815. * - VertexBuffer.UV4Kind
  91816. * - VertexBuffer.UV5Kind
  91817. * - VertexBuffer.UV6Kind
  91818. * - VertexBuffer.ColorKind
  91819. * - VertexBuffer.MatricesIndicesKind
  91820. * - VertexBuffer.MatricesIndicesExtraKind
  91821. * - VertexBuffer.MatricesWeightsKind
  91822. * - VertexBuffer.MatricesWeightsExtraKind
  91823. * @param data defines the data source
  91824. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91825. * @param stride defines the data stride size (can be null)
  91826. * @returns the current mesh
  91827. */
  91828. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91829. /**
  91830. * Delete a vertex buffer associated with this mesh
  91831. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91832. * - VertexBuffer.PositionKind
  91833. * - VertexBuffer.UVKind
  91834. * - VertexBuffer.UV2Kind
  91835. * - VertexBuffer.UV3Kind
  91836. * - VertexBuffer.UV4Kind
  91837. * - VertexBuffer.UV5Kind
  91838. * - VertexBuffer.UV6Kind
  91839. * - VertexBuffer.ColorKind
  91840. * - VertexBuffer.MatricesIndicesKind
  91841. * - VertexBuffer.MatricesIndicesExtraKind
  91842. * - VertexBuffer.MatricesWeightsKind
  91843. * - VertexBuffer.MatricesWeightsExtraKind
  91844. */
  91845. removeVerticesData(kind: string): void;
  91846. /**
  91847. * Flags an associated vertex buffer as updatable
  91848. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91849. * - VertexBuffer.PositionKind
  91850. * - VertexBuffer.UVKind
  91851. * - VertexBuffer.UV2Kind
  91852. * - VertexBuffer.UV3Kind
  91853. * - VertexBuffer.UV4Kind
  91854. * - VertexBuffer.UV5Kind
  91855. * - VertexBuffer.UV6Kind
  91856. * - VertexBuffer.ColorKind
  91857. * - VertexBuffer.MatricesIndicesKind
  91858. * - VertexBuffer.MatricesIndicesExtraKind
  91859. * - VertexBuffer.MatricesWeightsKind
  91860. * - VertexBuffer.MatricesWeightsExtraKind
  91861. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91862. */
  91863. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91864. /**
  91865. * Sets the mesh global Vertex Buffer
  91866. * @param buffer defines the buffer to use
  91867. * @returns the current mesh
  91868. */
  91869. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91870. /**
  91871. * Update a specific associated vertex buffer
  91872. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91873. * - VertexBuffer.PositionKind
  91874. * - VertexBuffer.UVKind
  91875. * - VertexBuffer.UV2Kind
  91876. * - VertexBuffer.UV3Kind
  91877. * - VertexBuffer.UV4Kind
  91878. * - VertexBuffer.UV5Kind
  91879. * - VertexBuffer.UV6Kind
  91880. * - VertexBuffer.ColorKind
  91881. * - VertexBuffer.MatricesIndicesKind
  91882. * - VertexBuffer.MatricesIndicesExtraKind
  91883. * - VertexBuffer.MatricesWeightsKind
  91884. * - VertexBuffer.MatricesWeightsExtraKind
  91885. * @param data defines the data source
  91886. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91887. * @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)
  91888. * @returns the current mesh
  91889. */
  91890. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91891. /**
  91892. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91893. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91894. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91895. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91896. * @returns the current mesh
  91897. */
  91898. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91899. /**
  91900. * Creates a un-shared specific occurence of the geometry for the mesh.
  91901. * @returns the current mesh
  91902. */
  91903. makeGeometryUnique(): Mesh;
  91904. /**
  91905. * Set the index buffer of this mesh
  91906. * @param indices defines the source data
  91907. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91908. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91909. * @returns the current mesh
  91910. */
  91911. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91912. /**
  91913. * Update the current index buffer
  91914. * @param indices defines the source data
  91915. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91916. * @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)
  91917. * @returns the current mesh
  91918. */
  91919. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91920. /**
  91921. * Invert the geometry to move from a right handed system to a left handed one.
  91922. * @returns the current mesh
  91923. */
  91924. toLeftHanded(): Mesh;
  91925. /** @hidden */
  91926. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91927. /** @hidden */
  91928. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91929. /**
  91930. * Registers for this mesh a javascript function called just before the rendering process
  91931. * @param func defines the function to call before rendering this mesh
  91932. * @returns the current mesh
  91933. */
  91934. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91935. /**
  91936. * Disposes a previously registered javascript function called before the rendering
  91937. * @param func defines the function to remove
  91938. * @returns the current mesh
  91939. */
  91940. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91941. /**
  91942. * Registers for this mesh a javascript function called just after the rendering is complete
  91943. * @param func defines the function to call after rendering this mesh
  91944. * @returns the current mesh
  91945. */
  91946. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91947. /**
  91948. * Disposes a previously registered javascript function called after the rendering.
  91949. * @param func defines the function to remove
  91950. * @returns the current mesh
  91951. */
  91952. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91953. /** @hidden */
  91954. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91955. /** @hidden */
  91956. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91957. /** @hidden */
  91958. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91959. /** @hidden */
  91960. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91961. /** @hidden */
  91962. _rebuild(): void;
  91963. /** @hidden */
  91964. _freeze(): void;
  91965. /** @hidden */
  91966. _unFreeze(): void;
  91967. /**
  91968. * 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
  91969. * @param subMesh defines the subMesh to render
  91970. * @param enableAlphaMode defines if alpha mode can be changed
  91971. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91972. * @returns the current mesh
  91973. */
  91974. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91975. private _onBeforeDraw;
  91976. /**
  91977. * Renormalize the mesh and patch it up if there are no weights
  91978. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91979. * However in the case of zero weights then we set just a single influence to 1.
  91980. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91981. */
  91982. cleanMatrixWeights(): void;
  91983. private normalizeSkinFourWeights;
  91984. private normalizeSkinWeightsAndExtra;
  91985. /**
  91986. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91987. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91988. * the user know there was an issue with importing the mesh
  91989. * @returns a validation object with skinned, valid and report string
  91990. */
  91991. validateSkinning(): {
  91992. skinned: boolean;
  91993. valid: boolean;
  91994. report: string;
  91995. };
  91996. /** @hidden */
  91997. _checkDelayState(): Mesh;
  91998. private _queueLoad;
  91999. /**
  92000. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92001. * A mesh is in the frustum if its bounding box intersects the frustum
  92002. * @param frustumPlanes defines the frustum to test
  92003. * @returns true if the mesh is in the frustum planes
  92004. */
  92005. isInFrustum(frustumPlanes: Plane[]): boolean;
  92006. /**
  92007. * Sets the mesh material by the material or multiMaterial `id` property
  92008. * @param id is a string identifying the material or the multiMaterial
  92009. * @returns the current mesh
  92010. */
  92011. setMaterialByID(id: string): Mesh;
  92012. /**
  92013. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92014. * @returns an array of IAnimatable
  92015. */
  92016. getAnimatables(): IAnimatable[];
  92017. /**
  92018. * Modifies the mesh geometry according to the passed transformation matrix.
  92019. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92020. * The mesh normals are modified using the same transformation.
  92021. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92022. * @param transform defines the transform matrix to use
  92023. * @see http://doc.babylonjs.com/resources/baking_transformations
  92024. * @returns the current mesh
  92025. */
  92026. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92027. /**
  92028. * Modifies the mesh geometry according to its own current World Matrix.
  92029. * The mesh World Matrix is then reset.
  92030. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92031. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92032. * @see http://doc.babylonjs.com/resources/baking_transformations
  92033. * @returns the current mesh
  92034. */
  92035. bakeCurrentTransformIntoVertices(): Mesh;
  92036. /** @hidden */
  92037. readonly _positions: Nullable<Vector3[]>;
  92038. /** @hidden */
  92039. _resetPointsArrayCache(): Mesh;
  92040. /** @hidden */
  92041. _generatePointsArray(): boolean;
  92042. /**
  92043. * Returns a new Mesh object generated from the current mesh properties.
  92044. * This method must not get confused with createInstance()
  92045. * @param name is a string, the name given to the new mesh
  92046. * @param newParent can be any Node object (default `null`)
  92047. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92048. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92049. * @returns a new mesh
  92050. */
  92051. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92052. /**
  92053. * Releases resources associated with this mesh.
  92054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92056. */
  92057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92058. /** @hidden */
  92059. _disposeInstanceSpecificData(): void;
  92060. /**
  92061. * Modifies the mesh geometry according to a displacement map.
  92062. * 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.
  92063. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92064. * @param url is a string, the URL from the image file is to be downloaded.
  92065. * @param minHeight is the lower limit of the displacement.
  92066. * @param maxHeight is the upper limit of the displacement.
  92067. * @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.
  92068. * @param uvOffset is an optional vector2 used to offset UV.
  92069. * @param uvScale is an optional vector2 used to scale UV.
  92070. * @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.
  92071. * @returns the Mesh.
  92072. */
  92073. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92074. /**
  92075. * Modifies the mesh geometry according to a displacementMap buffer.
  92076. * 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.
  92077. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92078. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92079. * @param heightMapWidth is the width of the buffer image.
  92080. * @param heightMapHeight is the height of the buffer image.
  92081. * @param minHeight is the lower limit of the displacement.
  92082. * @param maxHeight is the upper limit of the displacement.
  92083. * @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.
  92084. * @param uvOffset is an optional vector2 used to offset UV.
  92085. * @param uvScale is an optional vector2 used to scale UV.
  92086. * @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.
  92087. * @returns the Mesh.
  92088. */
  92089. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92090. /**
  92091. * Modify the mesh to get a flat shading rendering.
  92092. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92093. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92094. * @returns current mesh
  92095. */
  92096. convertToFlatShadedMesh(): Mesh;
  92097. /**
  92098. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92099. * In other words, more vertices, no more indices and a single bigger VBO.
  92100. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92101. * @returns current mesh
  92102. */
  92103. convertToUnIndexedMesh(): Mesh;
  92104. /**
  92105. * Inverses facet orientations.
  92106. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92107. * @param flipNormals will also inverts the normals
  92108. * @returns current mesh
  92109. */
  92110. flipFaces(flipNormals?: boolean): Mesh;
  92111. /**
  92112. * Increase the number of facets and hence vertices in a mesh
  92113. * Vertex normals are interpolated from existing vertex normals
  92114. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92115. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92116. */
  92117. increaseVertices(numberPerEdge: number): void;
  92118. /**
  92119. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92120. * This will undo any application of covertToFlatShadedMesh
  92121. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92122. */
  92123. forceSharedVertices(): void;
  92124. /** @hidden */
  92125. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92126. /** @hidden */
  92127. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92128. /**
  92129. * Creates a new InstancedMesh object from the mesh model.
  92130. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92131. * @param name defines the name of the new instance
  92132. * @returns a new InstancedMesh
  92133. */
  92134. createInstance(name: string): InstancedMesh;
  92135. /**
  92136. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92137. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92138. * @returns the current mesh
  92139. */
  92140. synchronizeInstances(): Mesh;
  92141. /**
  92142. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92143. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92144. * This should be used together with the simplification to avoid disappearing triangles.
  92145. * @param successCallback an optional success callback to be called after the optimization finished.
  92146. * @returns the current mesh
  92147. */
  92148. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92149. /**
  92150. * Serialize current mesh
  92151. * @param serializationObject defines the object which will receive the serialization data
  92152. */
  92153. serialize(serializationObject: any): void;
  92154. /** @hidden */
  92155. _syncGeometryWithMorphTargetManager(): void;
  92156. /** @hidden */
  92157. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92158. /**
  92159. * Returns a new Mesh object parsed from the source provided.
  92160. * @param parsedMesh is the source
  92161. * @param scene defines the hosting scene
  92162. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92163. * @returns a new Mesh
  92164. */
  92165. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92166. /**
  92167. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92168. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92169. * @param name defines the name of the mesh to create
  92170. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92171. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92172. * @param closePath creates a seam between the first and the last points of each path of the path array
  92173. * @param offset is taken in account only if the `pathArray` is containing a single path
  92174. * @param scene defines the hosting scene
  92175. * @param updatable defines if the mesh must be flagged as updatable
  92176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92177. * @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)
  92178. * @returns a new Mesh
  92179. */
  92180. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92181. /**
  92182. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92183. * @param name defines the name of the mesh to create
  92184. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92185. * @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
  92186. * @param scene defines the hosting scene
  92187. * @param updatable defines if the mesh must be flagged as updatable
  92188. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92189. * @returns a new Mesh
  92190. */
  92191. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92192. /**
  92193. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92194. * @param name defines the name of the mesh to create
  92195. * @param size sets the size (float) of each box side (default 1)
  92196. * @param scene defines the hosting scene
  92197. * @param updatable defines if the mesh must be flagged as updatable
  92198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92199. * @returns a new Mesh
  92200. */
  92201. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92202. /**
  92203. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92204. * @param name defines the name of the mesh to create
  92205. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92206. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92207. * @param scene defines the hosting scene
  92208. * @param updatable defines if the mesh must be flagged as updatable
  92209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92210. * @returns a new Mesh
  92211. */
  92212. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92213. /**
  92214. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92215. * @param name defines the name of the mesh to create
  92216. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92217. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92218. * @param scene defines the hosting scene
  92219. * @returns a new Mesh
  92220. */
  92221. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92222. /**
  92223. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92224. * @param name defines the name of the mesh to create
  92225. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92226. * @param diameterTop set the top cap diameter (floats, default 1)
  92227. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92228. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92229. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92230. * @param scene defines the hosting scene
  92231. * @param updatable defines if the mesh must be flagged as updatable
  92232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92233. * @returns a new Mesh
  92234. */
  92235. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92236. /**
  92237. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92238. * @param name defines the name of the mesh to create
  92239. * @param diameter sets the diameter size (float) of the torus (default 1)
  92240. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92241. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92242. * @param scene defines the hosting scene
  92243. * @param updatable defines if the mesh must be flagged as updatable
  92244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92245. * @returns a new Mesh
  92246. */
  92247. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92248. /**
  92249. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92250. * @param name defines the name of the mesh to create
  92251. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92252. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92253. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92254. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92255. * @param p the number of windings on X axis (positive integers, default 2)
  92256. * @param q the number of windings on Y axis (positive integers, default 3)
  92257. * @param scene defines the hosting scene
  92258. * @param updatable defines if the mesh must be flagged as updatable
  92259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92260. * @returns a new Mesh
  92261. */
  92262. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92263. /**
  92264. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92265. * @param name defines the name of the mesh to create
  92266. * @param points is an array successive Vector3
  92267. * @param scene defines the hosting scene
  92268. * @param updatable defines if the mesh must be flagged as updatable
  92269. * @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).
  92270. * @returns a new Mesh
  92271. */
  92272. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92273. /**
  92274. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92275. * @param name defines the name of the mesh to create
  92276. * @param points is an array successive Vector3
  92277. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92278. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92279. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92280. * @param scene defines the hosting scene
  92281. * @param updatable defines if the mesh must be flagged as updatable
  92282. * @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)
  92283. * @returns a new Mesh
  92284. */
  92285. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92286. /**
  92287. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92288. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92289. * 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.
  92290. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92291. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92292. * Remember you can only change the shape positions, not their number when updating a polygon.
  92293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92294. * @param name defines the name of the mesh to create
  92295. * @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
  92296. * @param scene defines the hosting scene
  92297. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92298. * @param updatable defines if the mesh must be flagged as updatable
  92299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92300. * @param earcutInjection can be used to inject your own earcut reference
  92301. * @returns a new Mesh
  92302. */
  92303. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92304. /**
  92305. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92306. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92307. * @param name defines the name of the mesh to create
  92308. * @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
  92309. * @param depth defines the height of extrusion
  92310. * @param scene defines the hosting scene
  92311. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92312. * @param updatable defines if the mesh must be flagged as updatable
  92313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92314. * @param earcutInjection can be used to inject your own earcut reference
  92315. * @returns a new Mesh
  92316. */
  92317. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92318. /**
  92319. * Creates an extruded shape mesh.
  92320. * 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
  92321. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92322. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92323. * @param name defines the name of the mesh to create
  92324. * @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
  92325. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92326. * @param scale is the value to scale the shape
  92327. * @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
  92328. * @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
  92329. * @param scene defines the hosting scene
  92330. * @param updatable defines if the mesh must be flagged as updatable
  92331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92332. * @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)
  92333. * @returns a new Mesh
  92334. */
  92335. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92336. /**
  92337. * Creates an custom extruded shape mesh.
  92338. * The custom extrusion is a parametric shape.
  92339. * It has no predefined shape. Its final shape will depend on the input parameters.
  92340. * Please consider using the same method from the MeshBuilder class instead
  92341. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92342. * @param name defines the name of the mesh to create
  92343. * @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
  92344. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92345. * @param scaleFunction is a custom Javascript function called on each path point
  92346. * @param rotationFunction is a custom Javascript function called on each path point
  92347. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92348. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92349. * @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
  92350. * @param scene defines the hosting scene
  92351. * @param updatable defines if the mesh must be flagged as updatable
  92352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92353. * @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)
  92354. * @returns a new Mesh
  92355. */
  92356. 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;
  92357. /**
  92358. * Creates lathe mesh.
  92359. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92360. * Please consider using the same method from the MeshBuilder class instead
  92361. * @param name defines the name of the mesh to create
  92362. * @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
  92363. * @param radius is the radius value of the lathe
  92364. * @param tessellation is the side number of the lathe.
  92365. * @param scene defines the hosting scene
  92366. * @param updatable defines if the mesh must be flagged as updatable
  92367. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92368. * @returns a new Mesh
  92369. */
  92370. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92371. /**
  92372. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92373. * @param name defines the name of the mesh to create
  92374. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92375. * @param scene defines the hosting scene
  92376. * @param updatable defines if the mesh must be flagged as updatable
  92377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92378. * @returns a new Mesh
  92379. */
  92380. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92381. /**
  92382. * Creates a ground mesh.
  92383. * Please consider using the same method from the MeshBuilder class instead
  92384. * @param name defines the name of the mesh to create
  92385. * @param width set the width of the ground
  92386. * @param height set the height of the ground
  92387. * @param subdivisions sets the number of subdivisions per side
  92388. * @param scene defines the hosting scene
  92389. * @param updatable defines if the mesh must be flagged as updatable
  92390. * @returns a new Mesh
  92391. */
  92392. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92393. /**
  92394. * Creates a tiled ground mesh.
  92395. * Please consider using the same method from the MeshBuilder class instead
  92396. * @param name defines the name of the mesh to create
  92397. * @param xmin set the ground minimum X coordinate
  92398. * @param zmin set the ground minimum Y coordinate
  92399. * @param xmax set the ground maximum X coordinate
  92400. * @param zmax set the ground maximum Z coordinate
  92401. * @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
  92402. * @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
  92403. * @param scene defines the hosting scene
  92404. * @param updatable defines if the mesh must be flagged as updatable
  92405. * @returns a new Mesh
  92406. */
  92407. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92408. w: number;
  92409. h: number;
  92410. }, precision: {
  92411. w: number;
  92412. h: number;
  92413. }, scene: Scene, updatable?: boolean): Mesh;
  92414. /**
  92415. * Creates a ground mesh from a height map.
  92416. * Please consider using the same method from the MeshBuilder class instead
  92417. * @see http://doc.babylonjs.com/babylon101/height_map
  92418. * @param name defines the name of the mesh to create
  92419. * @param url sets the URL of the height map image resource
  92420. * @param width set the ground width size
  92421. * @param height set the ground height size
  92422. * @param subdivisions sets the number of subdivision per side
  92423. * @param minHeight is the minimum altitude on the ground
  92424. * @param maxHeight is the maximum altitude on the ground
  92425. * @param scene defines the hosting scene
  92426. * @param updatable defines if the mesh must be flagged as updatable
  92427. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92428. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92429. * @returns a new Mesh
  92430. */
  92431. 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;
  92432. /**
  92433. * Creates a tube mesh.
  92434. * The tube is a parametric shape.
  92435. * It has no predefined shape. Its final shape will depend on the input parameters.
  92436. * Please consider using the same method from the MeshBuilder class instead
  92437. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92438. * @param name defines the name of the mesh to create
  92439. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92440. * @param radius sets the tube radius size
  92441. * @param tessellation is the number of sides on the tubular surface
  92442. * @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
  92443. * @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
  92444. * @param scene defines the hosting scene
  92445. * @param updatable defines if the mesh must be flagged as updatable
  92446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92447. * @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)
  92448. * @returns a new Mesh
  92449. */
  92450. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92451. (i: number, distance: number): number;
  92452. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92453. /**
  92454. * Creates a polyhedron mesh.
  92455. * Please consider using the same method from the MeshBuilder class instead.
  92456. * * 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
  92457. * * The parameter `size` (positive float, default 1) sets the polygon size
  92458. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92459. * * 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`
  92460. * * 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
  92461. * * 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)`)
  92462. * * 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
  92463. * * 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
  92464. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92465. * * If you create a double-sided mesh, you can choose what parts of 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
  92466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92467. * @param name defines the name of the mesh to create
  92468. * @param options defines the options used to create the mesh
  92469. * @param scene defines the hosting scene
  92470. * @returns a new Mesh
  92471. */
  92472. static CreatePolyhedron(name: string, options: {
  92473. type?: number;
  92474. size?: number;
  92475. sizeX?: number;
  92476. sizeY?: number;
  92477. sizeZ?: number;
  92478. custom?: any;
  92479. faceUV?: Vector4[];
  92480. faceColors?: Color4[];
  92481. updatable?: boolean;
  92482. sideOrientation?: number;
  92483. }, scene: Scene): Mesh;
  92484. /**
  92485. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92486. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92487. * * 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`)
  92488. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92489. * * 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
  92490. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92491. * * If you create a double-sided mesh, you can choose what parts of 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
  92492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92493. * @param name defines the name of the mesh
  92494. * @param options defines the options used to create the mesh
  92495. * @param scene defines the hosting scene
  92496. * @returns a new Mesh
  92497. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92498. */
  92499. static CreateIcoSphere(name: string, options: {
  92500. radius?: number;
  92501. flat?: boolean;
  92502. subdivisions?: number;
  92503. sideOrientation?: number;
  92504. updatable?: boolean;
  92505. }, scene: Scene): Mesh;
  92506. /**
  92507. * Creates a decal mesh.
  92508. * Please consider using the same method from the MeshBuilder class instead.
  92509. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92510. * @param name defines the name of the mesh
  92511. * @param sourceMesh defines the mesh receiving the decal
  92512. * @param position sets the position of the decal in world coordinates
  92513. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92514. * @param size sets the decal scaling
  92515. * @param angle sets the angle to rotate the decal
  92516. * @returns a new Mesh
  92517. */
  92518. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92519. /**
  92520. * Prepare internal position array for software CPU skinning
  92521. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92522. */
  92523. setPositionsForCPUSkinning(): Float32Array;
  92524. /**
  92525. * Prepare internal normal array for software CPU skinning
  92526. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92527. */
  92528. setNormalsForCPUSkinning(): Float32Array;
  92529. /**
  92530. * Updates the vertex buffer by applying transformation from the bones
  92531. * @param skeleton defines the skeleton to apply to current mesh
  92532. * @returns the current mesh
  92533. */
  92534. applySkeleton(skeleton: Skeleton): Mesh;
  92535. /**
  92536. * 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
  92537. * @param meshes defines the list of meshes to scan
  92538. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92539. */
  92540. static MinMax(meshes: AbstractMesh[]): {
  92541. min: Vector3;
  92542. max: Vector3;
  92543. };
  92544. /**
  92545. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92546. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92547. * @returns a vector3
  92548. */
  92549. static Center(meshesOrMinMaxVector: {
  92550. min: Vector3;
  92551. max: Vector3;
  92552. } | AbstractMesh[]): Vector3;
  92553. /**
  92554. * Merge the array of meshes into a single mesh for performance reasons.
  92555. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92556. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92557. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92558. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92559. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92560. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92561. * @returns a new mesh
  92562. */
  92563. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92564. /** @hidden */
  92565. addInstance(instance: InstancedMesh): void;
  92566. /** @hidden */
  92567. removeInstance(instance: InstancedMesh): void;
  92568. }
  92569. }
  92570. declare module BABYLON {
  92571. /**
  92572. * This is the base class of all the camera used in the application.
  92573. * @see http://doc.babylonjs.com/features/cameras
  92574. */
  92575. export class Camera extends Node {
  92576. /** @hidden */
  92577. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92578. /**
  92579. * This is the default projection mode used by the cameras.
  92580. * It helps recreating a feeling of perspective and better appreciate depth.
  92581. * This is the best way to simulate real life cameras.
  92582. */
  92583. static readonly PERSPECTIVE_CAMERA: number;
  92584. /**
  92585. * This helps creating camera with an orthographic mode.
  92586. * 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.
  92587. */
  92588. static readonly ORTHOGRAPHIC_CAMERA: number;
  92589. /**
  92590. * This is the default FOV mode for perspective cameras.
  92591. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92592. */
  92593. static readonly FOVMODE_VERTICAL_FIXED: number;
  92594. /**
  92595. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92596. */
  92597. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92598. /**
  92599. * This specifies ther is no need for a camera rig.
  92600. * Basically only one eye is rendered corresponding to the camera.
  92601. */
  92602. static readonly RIG_MODE_NONE: number;
  92603. /**
  92604. * Simulates a camera Rig with one blue eye and one red eye.
  92605. * This can be use with 3d blue and red glasses.
  92606. */
  92607. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92608. /**
  92609. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92610. */
  92611. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92612. /**
  92613. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92614. */
  92615. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92616. /**
  92617. * Defines that both eyes of the camera will be rendered over under each other.
  92618. */
  92619. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92620. /**
  92621. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92622. */
  92623. static readonly RIG_MODE_VR: number;
  92624. /**
  92625. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92626. */
  92627. static readonly RIG_MODE_WEBVR: number;
  92628. /**
  92629. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92630. */
  92631. static readonly RIG_MODE_CUSTOM: number;
  92632. /**
  92633. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92634. */
  92635. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92636. /**
  92637. * Define the input manager associated with the camera.
  92638. */
  92639. inputs: CameraInputsManager<Camera>;
  92640. /** @hidden */
  92641. _position: Vector3;
  92642. /**
  92643. * Define the current local position of the camera in the scene
  92644. */
  92645. position: Vector3;
  92646. /**
  92647. * The vector the camera should consider as up.
  92648. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92649. */
  92650. upVector: Vector3;
  92651. /**
  92652. * Define the current limit on the left side for an orthographic camera
  92653. * In scene unit
  92654. */
  92655. orthoLeft: Nullable<number>;
  92656. /**
  92657. * Define the current limit on the right side for an orthographic camera
  92658. * In scene unit
  92659. */
  92660. orthoRight: Nullable<number>;
  92661. /**
  92662. * Define the current limit on the bottom side for an orthographic camera
  92663. * In scene unit
  92664. */
  92665. orthoBottom: Nullable<number>;
  92666. /**
  92667. * Define the current limit on the top side for an orthographic camera
  92668. * In scene unit
  92669. */
  92670. orthoTop: Nullable<number>;
  92671. /**
  92672. * Field Of View is set in Radians. (default is 0.8)
  92673. */
  92674. fov: number;
  92675. /**
  92676. * Define the minimum distance the camera can see from.
  92677. * This is important to note that the depth buffer are not infinite and the closer it starts
  92678. * the more your scene might encounter depth fighting issue.
  92679. */
  92680. minZ: number;
  92681. /**
  92682. * Define the maximum distance the camera can see to.
  92683. * This is important to note that the depth buffer are not infinite and the further it end
  92684. * the more your scene might encounter depth fighting issue.
  92685. */
  92686. maxZ: number;
  92687. /**
  92688. * Define the default inertia of the camera.
  92689. * This helps giving a smooth feeling to the camera movement.
  92690. */
  92691. inertia: number;
  92692. /**
  92693. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92694. */
  92695. mode: number;
  92696. /**
  92697. * Define wether the camera is intermediate.
  92698. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92699. */
  92700. isIntermediate: boolean;
  92701. /**
  92702. * Define the viewport of the camera.
  92703. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92704. */
  92705. viewport: Viewport;
  92706. /**
  92707. * Restricts the camera to viewing objects with the same layerMask.
  92708. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92709. */
  92710. layerMask: number;
  92711. /**
  92712. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92713. */
  92714. fovMode: number;
  92715. /**
  92716. * Rig mode of the camera.
  92717. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92718. * This is normally controlled byt the camera themselves as internal use.
  92719. */
  92720. cameraRigMode: number;
  92721. /**
  92722. * Defines the distance between both "eyes" in case of a RIG
  92723. */
  92724. interaxialDistance: number;
  92725. /**
  92726. * Defines if stereoscopic rendering is done side by side or over under.
  92727. */
  92728. isStereoscopicSideBySide: boolean;
  92729. /**
  92730. * 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
  92731. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92732. * else in the scene. (Eg. security camera)
  92733. *
  92734. * 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)
  92735. */
  92736. customRenderTargets: RenderTargetTexture[];
  92737. /**
  92738. * When set, the camera will render to this render target instead of the default canvas
  92739. *
  92740. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92741. */
  92742. outputRenderTarget: Nullable<RenderTargetTexture>;
  92743. /**
  92744. * Observable triggered when the camera view matrix has changed.
  92745. */
  92746. onViewMatrixChangedObservable: Observable<Camera>;
  92747. /**
  92748. * Observable triggered when the camera Projection matrix has changed.
  92749. */
  92750. onProjectionMatrixChangedObservable: Observable<Camera>;
  92751. /**
  92752. * Observable triggered when the inputs have been processed.
  92753. */
  92754. onAfterCheckInputsObservable: Observable<Camera>;
  92755. /**
  92756. * Observable triggered when reset has been called and applied to the camera.
  92757. */
  92758. onRestoreStateObservable: Observable<Camera>;
  92759. /** @hidden */
  92760. _cameraRigParams: any;
  92761. /** @hidden */
  92762. _rigCameras: Camera[];
  92763. /** @hidden */
  92764. _rigPostProcess: Nullable<PostProcess>;
  92765. protected _webvrViewMatrix: Matrix;
  92766. /** @hidden */
  92767. _skipRendering: boolean;
  92768. /** @hidden */
  92769. _projectionMatrix: Matrix;
  92770. /** @hidden */
  92771. _postProcesses: Nullable<PostProcess>[];
  92772. /** @hidden */
  92773. _activeMeshes: SmartArray<AbstractMesh>;
  92774. protected _globalPosition: Vector3;
  92775. /** @hidden */
  92776. _computedViewMatrix: Matrix;
  92777. private _doNotComputeProjectionMatrix;
  92778. private _transformMatrix;
  92779. private _frustumPlanes;
  92780. private _refreshFrustumPlanes;
  92781. private _storedFov;
  92782. private _stateStored;
  92783. /**
  92784. * Instantiates a new camera object.
  92785. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92786. * @see http://doc.babylonjs.com/features/cameras
  92787. * @param name Defines the name of the camera in the scene
  92788. * @param position Defines the position of the camera
  92789. * @param scene Defines the scene the camera belongs too
  92790. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92791. */
  92792. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92793. /**
  92794. * Store current camera state (fov, position, etc..)
  92795. * @returns the camera
  92796. */
  92797. storeState(): Camera;
  92798. /**
  92799. * Restores the camera state values if it has been stored. You must call storeState() first
  92800. */
  92801. protected _restoreStateValues(): boolean;
  92802. /**
  92803. * Restored camera state. You must call storeState() first.
  92804. * @returns true if restored and false otherwise
  92805. */
  92806. restoreState(): boolean;
  92807. /**
  92808. * Gets the class name of the camera.
  92809. * @returns the class name
  92810. */
  92811. getClassName(): string;
  92812. /** @hidden */
  92813. readonly _isCamera: boolean;
  92814. /**
  92815. * Gets a string representation of the camera useful for debug purpose.
  92816. * @param fullDetails Defines that a more verboe level of logging is required
  92817. * @returns the string representation
  92818. */
  92819. toString(fullDetails?: boolean): string;
  92820. /**
  92821. * Gets the current world space position of the camera.
  92822. */
  92823. readonly globalPosition: Vector3;
  92824. /**
  92825. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92826. * @returns the active meshe list
  92827. */
  92828. getActiveMeshes(): SmartArray<AbstractMesh>;
  92829. /**
  92830. * Check wether a mesh is part of the current active mesh list of the camera
  92831. * @param mesh Defines the mesh to check
  92832. * @returns true if active, false otherwise
  92833. */
  92834. isActiveMesh(mesh: Mesh): boolean;
  92835. /**
  92836. * Is this camera ready to be used/rendered
  92837. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92838. * @return true if the camera is ready
  92839. */
  92840. isReady(completeCheck?: boolean): boolean;
  92841. /** @hidden */
  92842. _initCache(): void;
  92843. /** @hidden */
  92844. _updateCache(ignoreParentClass?: boolean): void;
  92845. /** @hidden */
  92846. _isSynchronized(): boolean;
  92847. /** @hidden */
  92848. _isSynchronizedViewMatrix(): boolean;
  92849. /** @hidden */
  92850. _isSynchronizedProjectionMatrix(): boolean;
  92851. /**
  92852. * Attach the input controls to a specific dom element to get the input from.
  92853. * @param element Defines the element the controls should be listened from
  92854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92855. */
  92856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92857. /**
  92858. * Detach the current controls from the specified dom element.
  92859. * @param element Defines the element to stop listening the inputs from
  92860. */
  92861. detachControl(element: HTMLElement): void;
  92862. /**
  92863. * Update the camera state according to the different inputs gathered during the frame.
  92864. */
  92865. update(): void;
  92866. /** @hidden */
  92867. _checkInputs(): void;
  92868. /** @hidden */
  92869. readonly rigCameras: Camera[];
  92870. /**
  92871. * Gets the post process used by the rig cameras
  92872. */
  92873. readonly rigPostProcess: Nullable<PostProcess>;
  92874. /**
  92875. * Internal, gets the first post proces.
  92876. * @returns the first post process to be run on this camera.
  92877. */
  92878. _getFirstPostProcess(): Nullable<PostProcess>;
  92879. private _cascadePostProcessesToRigCams;
  92880. /**
  92881. * Attach a post process to the camera.
  92882. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92883. * @param postProcess The post process to attach to the camera
  92884. * @param insertAt The position of the post process in case several of them are in use in the scene
  92885. * @returns the position the post process has been inserted at
  92886. */
  92887. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92888. /**
  92889. * Detach a post process to the camera.
  92890. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92891. * @param postProcess The post process to detach from the camera
  92892. */
  92893. detachPostProcess(postProcess: PostProcess): void;
  92894. /**
  92895. * Gets the current world matrix of the camera
  92896. */
  92897. getWorldMatrix(): Matrix;
  92898. /** @hidden */
  92899. _getViewMatrix(): Matrix;
  92900. /**
  92901. * Gets the current view matrix of the camera.
  92902. * @param force forces the camera to recompute the matrix without looking at the cached state
  92903. * @returns the view matrix
  92904. */
  92905. getViewMatrix(force?: boolean): Matrix;
  92906. /**
  92907. * Freeze the projection matrix.
  92908. * It will prevent the cache check of the camera projection compute and can speed up perf
  92909. * if no parameter of the camera are meant to change
  92910. * @param projection Defines manually a projection if necessary
  92911. */
  92912. freezeProjectionMatrix(projection?: Matrix): void;
  92913. /**
  92914. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92915. */
  92916. unfreezeProjectionMatrix(): void;
  92917. /**
  92918. * Gets the current projection matrix of the camera.
  92919. * @param force forces the camera to recompute the matrix without looking at the cached state
  92920. * @returns the projection matrix
  92921. */
  92922. getProjectionMatrix(force?: boolean): Matrix;
  92923. /**
  92924. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92925. * @returns a Matrix
  92926. */
  92927. getTransformationMatrix(): Matrix;
  92928. private _updateFrustumPlanes;
  92929. /**
  92930. * Checks if a cullable object (mesh...) is in the camera frustum
  92931. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92932. * @param target The object to check
  92933. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92934. * @returns true if the object is in frustum otherwise false
  92935. */
  92936. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92937. /**
  92938. * Checks if a cullable object (mesh...) is in the camera frustum
  92939. * Unlike isInFrustum this cheks the full bounding box
  92940. * @param target The object to check
  92941. * @returns true if the object is in frustum otherwise false
  92942. */
  92943. isCompletelyInFrustum(target: ICullable): boolean;
  92944. /**
  92945. * Gets a ray in the forward direction from the camera.
  92946. * @param length Defines the length of the ray to create
  92947. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92948. * @param origin Defines the start point of the ray which defaults to the camera position
  92949. * @returns the forward ray
  92950. */
  92951. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92952. /**
  92953. * Releases resources associated with this node.
  92954. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92955. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92956. */
  92957. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92958. /** @hidden */
  92959. _isLeftCamera: boolean;
  92960. /**
  92961. * Gets the left camera of a rig setup in case of Rigged Camera
  92962. */
  92963. readonly isLeftCamera: boolean;
  92964. /** @hidden */
  92965. _isRightCamera: boolean;
  92966. /**
  92967. * Gets the right camera of a rig setup in case of Rigged Camera
  92968. */
  92969. readonly isRightCamera: boolean;
  92970. /**
  92971. * Gets the left camera of a rig setup in case of Rigged Camera
  92972. */
  92973. readonly leftCamera: Nullable<FreeCamera>;
  92974. /**
  92975. * Gets the right camera of a rig setup in case of Rigged Camera
  92976. */
  92977. readonly rightCamera: Nullable<FreeCamera>;
  92978. /**
  92979. * Gets the left camera target of a rig setup in case of Rigged Camera
  92980. * @returns the target position
  92981. */
  92982. getLeftTarget(): Nullable<Vector3>;
  92983. /**
  92984. * Gets the right camera target of a rig setup in case of Rigged Camera
  92985. * @returns the target position
  92986. */
  92987. getRightTarget(): Nullable<Vector3>;
  92988. /**
  92989. * @hidden
  92990. */
  92991. setCameraRigMode(mode: number, rigParams: any): void;
  92992. /** @hidden */
  92993. static _setStereoscopicRigMode(camera: Camera): void;
  92994. /** @hidden */
  92995. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92996. /** @hidden */
  92997. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92998. /** @hidden */
  92999. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93000. /** @hidden */
  93001. _getVRProjectionMatrix(): Matrix;
  93002. protected _updateCameraRotationMatrix(): void;
  93003. protected _updateWebVRCameraRotationMatrix(): void;
  93004. /**
  93005. * This function MUST be overwritten by the different WebVR cameras available.
  93006. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93007. * @hidden
  93008. */
  93009. _getWebVRProjectionMatrix(): Matrix;
  93010. /**
  93011. * This function MUST be overwritten by the different WebVR cameras available.
  93012. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93013. * @hidden
  93014. */
  93015. _getWebVRViewMatrix(): Matrix;
  93016. /** @hidden */
  93017. setCameraRigParameter(name: string, value: any): void;
  93018. /**
  93019. * needs to be overridden by children so sub has required properties to be copied
  93020. * @hidden
  93021. */
  93022. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93023. /**
  93024. * May need to be overridden by children
  93025. * @hidden
  93026. */
  93027. _updateRigCameras(): void;
  93028. /** @hidden */
  93029. _setupInputs(): void;
  93030. /**
  93031. * Serialiaze the camera setup to a json represention
  93032. * @returns the JSON representation
  93033. */
  93034. serialize(): any;
  93035. /**
  93036. * Clones the current camera.
  93037. * @param name The cloned camera name
  93038. * @returns the cloned camera
  93039. */
  93040. clone(name: string): Camera;
  93041. /**
  93042. * Gets the direction of the camera relative to a given local axis.
  93043. * @param localAxis Defines the reference axis to provide a relative direction.
  93044. * @return the direction
  93045. */
  93046. getDirection(localAxis: Vector3): Vector3;
  93047. /**
  93048. * Returns the current camera absolute rotation
  93049. */
  93050. readonly absoluteRotation: Quaternion;
  93051. /**
  93052. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93053. * @param localAxis Defines the reference axis to provide a relative direction.
  93054. * @param result Defines the vector to store the result in
  93055. */
  93056. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93057. /**
  93058. * Gets a camera constructor for a given camera type
  93059. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93060. * @param name The name of the camera the result will be able to instantiate
  93061. * @param scene The scene the result will construct the camera in
  93062. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93063. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93064. * @returns a factory method to construc the camera
  93065. */
  93066. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93067. /**
  93068. * Compute the world matrix of the camera.
  93069. * @returns the camera world matrix
  93070. */
  93071. computeWorldMatrix(): Matrix;
  93072. /**
  93073. * Parse a JSON and creates the camera from the parsed information
  93074. * @param parsedCamera The JSON to parse
  93075. * @param scene The scene to instantiate the camera in
  93076. * @returns the newly constructed camera
  93077. */
  93078. static Parse(parsedCamera: any, scene: Scene): Camera;
  93079. }
  93080. }
  93081. declare module BABYLON {
  93082. /**
  93083. * Class containing static functions to help procedurally build meshes
  93084. */
  93085. export class DiscBuilder {
  93086. /**
  93087. * Creates a plane polygonal mesh. By default, this is a disc
  93088. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93089. * * 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
  93090. * * 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
  93091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93094. * @param name defines the name of the mesh
  93095. * @param options defines the options used to create the mesh
  93096. * @param scene defines the hosting scene
  93097. * @returns the plane polygonal mesh
  93098. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93099. */
  93100. static CreateDisc(name: string, options: {
  93101. radius?: number;
  93102. tessellation?: number;
  93103. arc?: number;
  93104. updatable?: boolean;
  93105. sideOrientation?: number;
  93106. frontUVs?: Vector4;
  93107. backUVs?: Vector4;
  93108. }, scene?: Nullable<Scene>): Mesh;
  93109. }
  93110. }
  93111. declare module BABYLON {
  93112. /**
  93113. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93114. *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.
  93115. * The SPS is also a particle system. It provides some methods to manage the particles.
  93116. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93117. *
  93118. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93119. */
  93120. export class SolidParticleSystem implements IDisposable {
  93121. /**
  93122. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93123. * Example : var p = SPS.particles[i];
  93124. */
  93125. particles: SolidParticle[];
  93126. /**
  93127. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93128. */
  93129. nbParticles: number;
  93130. /**
  93131. * If the particles must ever face the camera (default false). Useful for planar particles.
  93132. */
  93133. billboard: boolean;
  93134. /**
  93135. * Recompute normals when adding a shape
  93136. */
  93137. recomputeNormals: boolean;
  93138. /**
  93139. * This a counter ofr your own usage. It's not set by any SPS functions.
  93140. */
  93141. counter: number;
  93142. /**
  93143. * The SPS name. This name is also given to the underlying mesh.
  93144. */
  93145. name: string;
  93146. /**
  93147. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93148. */
  93149. mesh: Mesh;
  93150. /**
  93151. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93152. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93153. */
  93154. vars: any;
  93155. /**
  93156. * This array is populated when the SPS is set as 'pickable'.
  93157. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93158. * Each element of this array is an object `{idx: int, faceId: int}`.
  93159. * `idx` is the picked particle index in the `SPS.particles` array
  93160. * `faceId` is the picked face index counted within this particle.
  93161. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93162. */
  93163. pickedParticles: {
  93164. idx: number;
  93165. faceId: number;
  93166. }[];
  93167. /**
  93168. * This array is populated when `enableDepthSort` is set to true.
  93169. * Each element of this array is an instance of the class DepthSortedParticle.
  93170. */
  93171. depthSortedParticles: DepthSortedParticle[];
  93172. /**
  93173. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93174. * @hidden
  93175. */
  93176. _bSphereOnly: boolean;
  93177. /**
  93178. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93179. * @hidden
  93180. */
  93181. _bSphereRadiusFactor: number;
  93182. private _scene;
  93183. private _positions;
  93184. private _indices;
  93185. private _normals;
  93186. private _colors;
  93187. private _uvs;
  93188. private _indices32;
  93189. private _positions32;
  93190. private _normals32;
  93191. private _fixedNormal32;
  93192. private _colors32;
  93193. private _uvs32;
  93194. private _index;
  93195. private _updatable;
  93196. private _pickable;
  93197. private _isVisibilityBoxLocked;
  93198. private _alwaysVisible;
  93199. private _depthSort;
  93200. private _expandable;
  93201. private _shapeCounter;
  93202. private _copy;
  93203. private _color;
  93204. private _computeParticleColor;
  93205. private _computeParticleTexture;
  93206. private _computeParticleRotation;
  93207. private _computeParticleVertex;
  93208. private _computeBoundingBox;
  93209. private _depthSortParticles;
  93210. private _camera;
  93211. private _mustUnrotateFixedNormals;
  93212. private _particlesIntersect;
  93213. private _needs32Bits;
  93214. private _isNotBuilt;
  93215. /**
  93216. * Creates a SPS (Solid Particle System) object.
  93217. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93218. * @param scene (Scene) is the scene in which the SPS is added.
  93219. * @param options defines the options of the sps e.g.
  93220. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93221. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93222. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93223. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93224. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93225. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93226. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93227. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93228. */
  93229. constructor(name: string, scene: Scene, options?: {
  93230. updatable?: boolean;
  93231. isPickable?: boolean;
  93232. enableDepthSort?: boolean;
  93233. particleIntersection?: boolean;
  93234. boundingSphereOnly?: boolean;
  93235. bSphereRadiusFactor?: number;
  93236. expandable?: boolean;
  93237. });
  93238. /**
  93239. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93240. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93241. * @returns the created mesh
  93242. */
  93243. buildMesh(): Mesh;
  93244. /**
  93245. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93246. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93247. * Thus the particles generated from `digest()` have their property `position` set yet.
  93248. * @param mesh ( Mesh ) is the mesh to be digested
  93249. * @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
  93250. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93251. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93252. * @returns the current SPS
  93253. */
  93254. digest(mesh: Mesh, options?: {
  93255. facetNb?: number;
  93256. number?: number;
  93257. delta?: number;
  93258. }): SolidParticleSystem;
  93259. private _unrotateFixedNormals;
  93260. private _resetCopy;
  93261. private _meshBuilder;
  93262. private _posToShape;
  93263. private _uvsToShapeUV;
  93264. private _addParticle;
  93265. /**
  93266. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93267. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93268. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93269. * @param nb (positive integer) the number of particles to be created from this model
  93270. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93271. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93272. * @returns the number of shapes in the system
  93273. */
  93274. addShape(mesh: Mesh, nb: number, options?: {
  93275. positionFunction?: any;
  93276. vertexFunction?: any;
  93277. }): number;
  93278. private _rebuildParticle;
  93279. /**
  93280. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93281. * @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.
  93282. * @returns the SPS.
  93283. */
  93284. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93285. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93286. * Returns an array with the removed particles.
  93287. * 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.
  93288. * The SPS can't be empty so at least one particle needs to remain in place.
  93289. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93290. * @param start index of the first particle to remove
  93291. * @param end index of the last particle to remove (included)
  93292. * @returns an array populated with the removed particles
  93293. */
  93294. removeParticles(start: number, end: number): SolidParticle[];
  93295. /**
  93296. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93297. * This method calls `updateParticle()` for each particle of the SPS.
  93298. * For an animated SPS, it is usually called within the render loop.
  93299. * 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.
  93300. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93301. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93302. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93303. * @returns the SPS.
  93304. */
  93305. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93306. /**
  93307. * Disposes the SPS.
  93308. */
  93309. dispose(): void;
  93310. /**
  93311. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93313. * @returns the SPS.
  93314. */
  93315. refreshVisibleSize(): SolidParticleSystem;
  93316. /**
  93317. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93318. * @param size the size (float) of the visibility box
  93319. * note : this doesn't lock the SPS mesh bounding box.
  93320. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93321. */
  93322. setVisibilityBox(size: number): void;
  93323. /**
  93324. * Gets whether the SPS as always visible or not
  93325. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93326. */
  93327. /**
  93328. * Sets the SPS as always visible or not
  93329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93330. */
  93331. isAlwaysVisible: boolean;
  93332. /**
  93333. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93334. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93335. */
  93336. /**
  93337. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93338. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93339. */
  93340. isVisibilityBoxLocked: boolean;
  93341. /**
  93342. * Tells to `setParticles()` to compute the particle rotations or not.
  93343. * Default value : true. The SPS is faster when it's set to false.
  93344. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93345. */
  93346. /**
  93347. * Gets if `setParticles()` computes the particle rotations or not.
  93348. * Default value : true. The SPS is faster when it's set to false.
  93349. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93350. */
  93351. computeParticleRotation: boolean;
  93352. /**
  93353. * Tells to `setParticles()` to compute the particle colors or not.
  93354. * Default value : true. The SPS is faster when it's set to false.
  93355. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93356. */
  93357. /**
  93358. * Gets if `setParticles()` computes the particle colors or not.
  93359. * Default value : true. The SPS is faster when it's set to false.
  93360. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93361. */
  93362. computeParticleColor: boolean;
  93363. /**
  93364. * Gets if `setParticles()` computes the particle textures or not.
  93365. * Default value : true. The SPS is faster when it's set to false.
  93366. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93367. */
  93368. computeParticleTexture: boolean;
  93369. /**
  93370. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93371. * Default value : false. The SPS is faster when it's set to false.
  93372. * Note : the particle custom vertex positions aren't stored values.
  93373. */
  93374. /**
  93375. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93376. * Default value : false. The SPS is faster when it's set to false.
  93377. * Note : the particle custom vertex positions aren't stored values.
  93378. */
  93379. computeParticleVertex: boolean;
  93380. /**
  93381. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93382. */
  93383. /**
  93384. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93385. */
  93386. computeBoundingBox: boolean;
  93387. /**
  93388. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93389. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93390. * Default : `true`
  93391. */
  93392. /**
  93393. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93394. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93395. * Default : `true`
  93396. */
  93397. depthSortParticles: boolean;
  93398. /**
  93399. * Gets if the SPS is created as expandable at construction time.
  93400. * Default : `false`
  93401. */
  93402. readonly expandable: boolean;
  93403. /**
  93404. * This function does nothing. It may be overwritten to set all the particle first values.
  93405. * The SPS doesn't call this function, you may have to call it by your own.
  93406. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93407. */
  93408. initParticles(): void;
  93409. /**
  93410. * This function does nothing. It may be overwritten to recycle a particle.
  93411. * The SPS doesn't call this function, you may have to call it by your own.
  93412. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93413. * @param particle The particle to recycle
  93414. * @returns the recycled particle
  93415. */
  93416. recycleParticle(particle: SolidParticle): SolidParticle;
  93417. /**
  93418. * Updates a particle : this function should be overwritten by the user.
  93419. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93420. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93421. * @example : just set a particle position or velocity and recycle conditions
  93422. * @param particle The particle to update
  93423. * @returns the updated particle
  93424. */
  93425. updateParticle(particle: SolidParticle): SolidParticle;
  93426. /**
  93427. * Updates a vertex of a particle : it can be overwritten by the user.
  93428. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93429. * @param particle the current particle
  93430. * @param vertex the current index of the current particle
  93431. * @param pt the index of the current vertex in the particle shape
  93432. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93433. * @example : just set a vertex particle position
  93434. * @returns the updated vertex
  93435. */
  93436. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93437. /**
  93438. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93439. * This does nothing and may be overwritten by the user.
  93440. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93441. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93442. * @param update the boolean update value actually passed to setParticles()
  93443. */
  93444. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93445. /**
  93446. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93447. * This will be passed three parameters.
  93448. * This does nothing and may be overwritten by the user.
  93449. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93450. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93451. * @param update the boolean update value actually passed to setParticles()
  93452. */
  93453. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93454. }
  93455. }
  93456. declare module BABYLON {
  93457. /**
  93458. * Represents one particle of a solid particle system.
  93459. */
  93460. export class SolidParticle {
  93461. /**
  93462. * particle global index
  93463. */
  93464. idx: number;
  93465. /**
  93466. * The color of the particle
  93467. */
  93468. color: Nullable<Color4>;
  93469. /**
  93470. * The world space position of the particle.
  93471. */
  93472. position: Vector3;
  93473. /**
  93474. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93475. */
  93476. rotation: Vector3;
  93477. /**
  93478. * The world space rotation quaternion of the particle.
  93479. */
  93480. rotationQuaternion: Nullable<Quaternion>;
  93481. /**
  93482. * The scaling of the particle.
  93483. */
  93484. scaling: Vector3;
  93485. /**
  93486. * The uvs of the particle.
  93487. */
  93488. uvs: Vector4;
  93489. /**
  93490. * The current speed of the particle.
  93491. */
  93492. velocity: Vector3;
  93493. /**
  93494. * The pivot point in the particle local space.
  93495. */
  93496. pivot: Vector3;
  93497. /**
  93498. * Must the particle be translated from its pivot point in its local space ?
  93499. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93500. * Default : false
  93501. */
  93502. translateFromPivot: boolean;
  93503. /**
  93504. * Is the particle active or not ?
  93505. */
  93506. alive: boolean;
  93507. /**
  93508. * Is the particle visible or not ?
  93509. */
  93510. isVisible: boolean;
  93511. /**
  93512. * Index of this particle in the global "positions" array (Internal use)
  93513. * @hidden
  93514. */
  93515. _pos: number;
  93516. /**
  93517. * @hidden Index of this particle in the global "indices" array (Internal use)
  93518. */
  93519. _ind: number;
  93520. /**
  93521. * @hidden ModelShape of this particle (Internal use)
  93522. */
  93523. _model: ModelShape;
  93524. /**
  93525. * ModelShape id of this particle
  93526. */
  93527. shapeId: number;
  93528. /**
  93529. * Index of the particle in its shape id
  93530. */
  93531. idxInShape: number;
  93532. /**
  93533. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93534. */
  93535. _modelBoundingInfo: BoundingInfo;
  93536. /**
  93537. * @hidden Particle BoundingInfo object (Internal use)
  93538. */
  93539. _boundingInfo: BoundingInfo;
  93540. /**
  93541. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93542. */
  93543. _sps: SolidParticleSystem;
  93544. /**
  93545. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93546. */
  93547. _stillInvisible: boolean;
  93548. /**
  93549. * @hidden Last computed particle rotation matrix
  93550. */
  93551. _rotationMatrix: number[];
  93552. /**
  93553. * Parent particle Id, if any.
  93554. * Default null.
  93555. */
  93556. parentId: Nullable<number>;
  93557. /**
  93558. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93559. * The possible values are :
  93560. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93561. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93562. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93563. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93564. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93565. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93566. * */
  93567. cullingStrategy: number;
  93568. /**
  93569. * @hidden Internal global position in the SPS.
  93570. */
  93571. _globalPosition: Vector3;
  93572. /**
  93573. * Creates a Solid Particle object.
  93574. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93575. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93576. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93577. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93578. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93579. * @param shapeId (integer) is the model shape identifier in the SPS.
  93580. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93581. * @param sps defines the sps it is associated to
  93582. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93583. */
  93584. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93585. /**
  93586. * Legacy support, changed scale to scaling
  93587. */
  93588. /**
  93589. * Legacy support, changed scale to scaling
  93590. */
  93591. scale: Vector3;
  93592. /**
  93593. * Legacy support, changed quaternion to rotationQuaternion
  93594. */
  93595. /**
  93596. * Legacy support, changed quaternion to rotationQuaternion
  93597. */
  93598. quaternion: Nullable<Quaternion>;
  93599. /**
  93600. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93601. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93602. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93603. * @returns true if it intersects
  93604. */
  93605. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93606. /**
  93607. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93608. * A particle is in the frustum if its bounding box intersects the frustum
  93609. * @param frustumPlanes defines the frustum to test
  93610. * @returns true if the particle is in the frustum planes
  93611. */
  93612. isInFrustum(frustumPlanes: Plane[]): boolean;
  93613. /**
  93614. * get the rotation matrix of the particle
  93615. * @hidden
  93616. */
  93617. getRotationMatrix(m: Matrix): void;
  93618. }
  93619. /**
  93620. * Represents the shape of the model used by one particle of a solid particle system.
  93621. * SPS internal tool, don't use it manually.
  93622. */
  93623. export class ModelShape {
  93624. /**
  93625. * The shape id
  93626. * @hidden
  93627. */
  93628. shapeID: number;
  93629. /**
  93630. * flat array of model positions (internal use)
  93631. * @hidden
  93632. */
  93633. _shape: Vector3[];
  93634. /**
  93635. * flat array of model UVs (internal use)
  93636. * @hidden
  93637. */
  93638. _shapeUV: number[];
  93639. /**
  93640. * color array of the model
  93641. * @hidden
  93642. */
  93643. _shapeColors: number[];
  93644. /**
  93645. * indices array of the model
  93646. * @hidden
  93647. */
  93648. _indices: number[];
  93649. /**
  93650. * normals array of the model
  93651. * @hidden
  93652. */
  93653. _normals: number[];
  93654. /**
  93655. * length of the shape in the model indices array (internal use)
  93656. * @hidden
  93657. */
  93658. _indicesLength: number;
  93659. /**
  93660. * Custom position function (internal use)
  93661. * @hidden
  93662. */
  93663. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93664. /**
  93665. * Custom vertex function (internal use)
  93666. * @hidden
  93667. */
  93668. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93669. /**
  93670. * 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.
  93671. * SPS internal tool, don't use it manually.
  93672. * @hidden
  93673. */
  93674. 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>);
  93675. }
  93676. /**
  93677. * Represents a Depth Sorted Particle in the solid particle system.
  93678. */
  93679. export class DepthSortedParticle {
  93680. /**
  93681. * Index of the particle in the "indices" array
  93682. */
  93683. ind: number;
  93684. /**
  93685. * Length of the particle shape in the "indices" array
  93686. */
  93687. indicesLength: number;
  93688. /**
  93689. * Squared distance from the particle to the camera
  93690. */
  93691. sqDistance: number;
  93692. }
  93693. }
  93694. declare module BABYLON {
  93695. /**
  93696. * @hidden
  93697. */
  93698. export class _MeshCollisionData {
  93699. _checkCollisions: boolean;
  93700. _collisionMask: number;
  93701. _collisionGroup: number;
  93702. _collider: Nullable<Collider>;
  93703. _oldPositionForCollisions: Vector3;
  93704. _diffPositionForCollisions: Vector3;
  93705. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93706. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93707. }
  93708. }
  93709. declare module BABYLON {
  93710. /** @hidden */
  93711. class _FacetDataStorage {
  93712. facetPositions: Vector3[];
  93713. facetNormals: Vector3[];
  93714. facetPartitioning: number[][];
  93715. facetNb: number;
  93716. partitioningSubdivisions: number;
  93717. partitioningBBoxRatio: number;
  93718. facetDataEnabled: boolean;
  93719. facetParameters: any;
  93720. bbSize: Vector3;
  93721. subDiv: {
  93722. max: number;
  93723. X: number;
  93724. Y: number;
  93725. Z: number;
  93726. };
  93727. facetDepthSort: boolean;
  93728. facetDepthSortEnabled: boolean;
  93729. depthSortedIndices: IndicesArray;
  93730. depthSortedFacets: {
  93731. ind: number;
  93732. sqDistance: number;
  93733. }[];
  93734. facetDepthSortFunction: (f1: {
  93735. ind: number;
  93736. sqDistance: number;
  93737. }, f2: {
  93738. ind: number;
  93739. sqDistance: number;
  93740. }) => number;
  93741. facetDepthSortFrom: Vector3;
  93742. facetDepthSortOrigin: Vector3;
  93743. invertedMatrix: Matrix;
  93744. }
  93745. /**
  93746. * @hidden
  93747. **/
  93748. class _InternalAbstractMeshDataInfo {
  93749. _hasVertexAlpha: boolean;
  93750. _useVertexColors: boolean;
  93751. _numBoneInfluencers: number;
  93752. _applyFog: boolean;
  93753. _receiveShadows: boolean;
  93754. _facetData: _FacetDataStorage;
  93755. _visibility: number;
  93756. _skeleton: Nullable<Skeleton>;
  93757. _layerMask: number;
  93758. _computeBonesUsingShaders: boolean;
  93759. _isActive: boolean;
  93760. _onlyForInstances: boolean;
  93761. _isActiveIntermediate: boolean;
  93762. _onlyForInstancesIntermediate: boolean;
  93763. _actAsRegularMesh: boolean;
  93764. }
  93765. /**
  93766. * Class used to store all common mesh properties
  93767. */
  93768. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93769. /** No occlusion */
  93770. static OCCLUSION_TYPE_NONE: number;
  93771. /** Occlusion set to optimisitic */
  93772. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93773. /** Occlusion set to strict */
  93774. static OCCLUSION_TYPE_STRICT: number;
  93775. /** Use an accurante occlusion algorithm */
  93776. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93777. /** Use a conservative occlusion algorithm */
  93778. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93779. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93780. * Test order :
  93781. * Is the bounding sphere outside the frustum ?
  93782. * If not, are the bounding box vertices outside the frustum ?
  93783. * It not, then the cullable object is in the frustum.
  93784. */
  93785. static readonly CULLINGSTRATEGY_STANDARD: number;
  93786. /** Culling strategy : Bounding Sphere Only.
  93787. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93788. * It's also less accurate than the standard because some not visible objects can still be selected.
  93789. * Test : is the bounding sphere outside the frustum ?
  93790. * If not, then the cullable object is in the frustum.
  93791. */
  93792. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93793. /** Culling strategy : Optimistic Inclusion.
  93794. * This in an inclusion test first, then the standard exclusion test.
  93795. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93796. * 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.
  93797. * Anyway, it's as accurate as the standard strategy.
  93798. * Test :
  93799. * Is the cullable object bounding sphere center in the frustum ?
  93800. * If not, apply the default culling strategy.
  93801. */
  93802. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93803. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93804. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93805. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93806. * 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.
  93807. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93808. * Test :
  93809. * Is the cullable object bounding sphere center in the frustum ?
  93810. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93811. */
  93812. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93813. /**
  93814. * No billboard
  93815. */
  93816. static readonly BILLBOARDMODE_NONE: number;
  93817. /** Billboard on X axis */
  93818. static readonly BILLBOARDMODE_X: number;
  93819. /** Billboard on Y axis */
  93820. static readonly BILLBOARDMODE_Y: number;
  93821. /** Billboard on Z axis */
  93822. static readonly BILLBOARDMODE_Z: number;
  93823. /** Billboard on all axes */
  93824. static readonly BILLBOARDMODE_ALL: number;
  93825. /** Billboard on using position instead of orientation */
  93826. static readonly BILLBOARDMODE_USE_POSITION: number;
  93827. /** @hidden */
  93828. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93829. /**
  93830. * The culling strategy to use to check whether the mesh must be rendered or not.
  93831. * This value can be changed at any time and will be used on the next render mesh selection.
  93832. * The possible values are :
  93833. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93834. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93835. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93836. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93837. * Please read each static variable documentation to get details about the culling process.
  93838. * */
  93839. cullingStrategy: number;
  93840. /**
  93841. * Gets the number of facets in the mesh
  93842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93843. */
  93844. readonly facetNb: number;
  93845. /**
  93846. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93848. */
  93849. partitioningSubdivisions: number;
  93850. /**
  93851. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93852. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93854. */
  93855. partitioningBBoxRatio: number;
  93856. /**
  93857. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93858. * Works only for updatable meshes.
  93859. * Doesn't work with multi-materials
  93860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93861. */
  93862. mustDepthSortFacets: boolean;
  93863. /**
  93864. * The location (Vector3) where the facet depth sort must be computed from.
  93865. * By default, the active camera position.
  93866. * Used only when facet depth sort is enabled
  93867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93868. */
  93869. facetDepthSortFrom: Vector3;
  93870. /**
  93871. * gets a boolean indicating if facetData is enabled
  93872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93873. */
  93874. readonly isFacetDataEnabled: boolean;
  93875. /** @hidden */
  93876. _updateNonUniformScalingState(value: boolean): boolean;
  93877. /**
  93878. * An event triggered when this mesh collides with another one
  93879. */
  93880. onCollideObservable: Observable<AbstractMesh>;
  93881. /** Set a function to call when this mesh collides with another one */
  93882. onCollide: () => void;
  93883. /**
  93884. * An event triggered when the collision's position changes
  93885. */
  93886. onCollisionPositionChangeObservable: Observable<Vector3>;
  93887. /** Set a function to call when the collision's position changes */
  93888. onCollisionPositionChange: () => void;
  93889. /**
  93890. * An event triggered when material is changed
  93891. */
  93892. onMaterialChangedObservable: Observable<AbstractMesh>;
  93893. /**
  93894. * Gets or sets the orientation for POV movement & rotation
  93895. */
  93896. definedFacingForward: boolean;
  93897. /** @hidden */
  93898. _occlusionQuery: Nullable<WebGLQuery>;
  93899. /** @hidden */
  93900. _renderingGroup: Nullable<RenderingGroup>;
  93901. /**
  93902. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93903. */
  93904. /**
  93905. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93906. */
  93907. visibility: number;
  93908. /** Gets or sets the alpha index used to sort transparent meshes
  93909. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93910. */
  93911. alphaIndex: number;
  93912. /**
  93913. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93914. */
  93915. isVisible: boolean;
  93916. /**
  93917. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93918. */
  93919. isPickable: boolean;
  93920. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93921. showSubMeshesBoundingBox: boolean;
  93922. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93923. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93924. */
  93925. isBlocker: boolean;
  93926. /**
  93927. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93928. */
  93929. enablePointerMoveEvents: boolean;
  93930. /**
  93931. * Specifies the rendering group id for this mesh (0 by default)
  93932. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93933. */
  93934. renderingGroupId: number;
  93935. private _material;
  93936. /** Gets or sets current material */
  93937. material: Nullable<Material>;
  93938. /**
  93939. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93940. * @see http://doc.babylonjs.com/babylon101/shadows
  93941. */
  93942. receiveShadows: boolean;
  93943. /** Defines color to use when rendering outline */
  93944. outlineColor: Color3;
  93945. /** Define width to use when rendering outline */
  93946. outlineWidth: number;
  93947. /** Defines color to use when rendering overlay */
  93948. overlayColor: Color3;
  93949. /** Defines alpha to use when rendering overlay */
  93950. overlayAlpha: number;
  93951. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93952. hasVertexAlpha: boolean;
  93953. /** 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) */
  93954. useVertexColors: boolean;
  93955. /**
  93956. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93957. */
  93958. computeBonesUsingShaders: boolean;
  93959. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93960. numBoneInfluencers: number;
  93961. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93962. applyFog: boolean;
  93963. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93964. useOctreeForRenderingSelection: boolean;
  93965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93966. useOctreeForPicking: boolean;
  93967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93968. useOctreeForCollisions: boolean;
  93969. /**
  93970. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93971. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93972. */
  93973. layerMask: number;
  93974. /**
  93975. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93976. */
  93977. alwaysSelectAsActiveMesh: boolean;
  93978. /**
  93979. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93980. */
  93981. doNotSyncBoundingInfo: boolean;
  93982. /**
  93983. * Gets or sets the current action manager
  93984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93985. */
  93986. actionManager: Nullable<AbstractActionManager>;
  93987. private _meshCollisionData;
  93988. /**
  93989. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93991. */
  93992. ellipsoid: Vector3;
  93993. /**
  93994. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93995. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93996. */
  93997. ellipsoidOffset: Vector3;
  93998. /**
  93999. * Gets or sets a collision mask used to mask collisions (default is -1).
  94000. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94001. */
  94002. collisionMask: number;
  94003. /**
  94004. * Gets or sets the current collision group mask (-1 by default).
  94005. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94006. */
  94007. collisionGroup: number;
  94008. /**
  94009. * Defines edge width used when edgesRenderer is enabled
  94010. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94011. */
  94012. edgesWidth: number;
  94013. /**
  94014. * Defines edge color used when edgesRenderer is enabled
  94015. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94016. */
  94017. edgesColor: Color4;
  94018. /** @hidden */
  94019. _edgesRenderer: Nullable<IEdgesRenderer>;
  94020. /** @hidden */
  94021. _masterMesh: Nullable<AbstractMesh>;
  94022. /** @hidden */
  94023. _boundingInfo: Nullable<BoundingInfo>;
  94024. /** @hidden */
  94025. _renderId: number;
  94026. /**
  94027. * Gets or sets the list of subMeshes
  94028. * @see http://doc.babylonjs.com/how_to/multi_materials
  94029. */
  94030. subMeshes: SubMesh[];
  94031. /** @hidden */
  94032. _intersectionsInProgress: AbstractMesh[];
  94033. /** @hidden */
  94034. _unIndexed: boolean;
  94035. /** @hidden */
  94036. _lightSources: Light[];
  94037. /** Gets the list of lights affecting that mesh */
  94038. readonly lightSources: Light[];
  94039. /** @hidden */
  94040. readonly _positions: Nullable<Vector3[]>;
  94041. /** @hidden */
  94042. _waitingData: {
  94043. lods: Nullable<any>;
  94044. actions: Nullable<any>;
  94045. freezeWorldMatrix: Nullable<boolean>;
  94046. };
  94047. /** @hidden */
  94048. _bonesTransformMatrices: Nullable<Float32Array>;
  94049. /** @hidden */
  94050. _transformMatrixTexture: Nullable<RawTexture>;
  94051. /**
  94052. * Gets or sets a skeleton to apply skining transformations
  94053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94054. */
  94055. skeleton: Nullable<Skeleton>;
  94056. /**
  94057. * An event triggered when the mesh is rebuilt.
  94058. */
  94059. onRebuildObservable: Observable<AbstractMesh>;
  94060. /**
  94061. * Creates a new AbstractMesh
  94062. * @param name defines the name of the mesh
  94063. * @param scene defines the hosting scene
  94064. */
  94065. constructor(name: string, scene?: Nullable<Scene>);
  94066. /**
  94067. * Returns the string "AbstractMesh"
  94068. * @returns "AbstractMesh"
  94069. */
  94070. getClassName(): string;
  94071. /**
  94072. * Gets a string representation of the current mesh
  94073. * @param fullDetails defines a boolean indicating if full details must be included
  94074. * @returns a string representation of the current mesh
  94075. */
  94076. toString(fullDetails?: boolean): string;
  94077. /**
  94078. * @hidden
  94079. */
  94080. protected _getEffectiveParent(): Nullable<Node>;
  94081. /** @hidden */
  94082. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94083. /** @hidden */
  94084. _rebuild(): void;
  94085. /** @hidden */
  94086. _resyncLightSources(): void;
  94087. /** @hidden */
  94088. _resyncLighSource(light: Light): void;
  94089. /** @hidden */
  94090. _unBindEffect(): void;
  94091. /** @hidden */
  94092. _removeLightSource(light: Light, dispose: boolean): void;
  94093. private _markSubMeshesAsDirty;
  94094. /** @hidden */
  94095. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94096. /** @hidden */
  94097. _markSubMeshesAsAttributesDirty(): void;
  94098. /** @hidden */
  94099. _markSubMeshesAsMiscDirty(): void;
  94100. /**
  94101. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94102. */
  94103. scaling: Vector3;
  94104. /**
  94105. * Returns true if the mesh is blocked. Implemented by child classes
  94106. */
  94107. readonly isBlocked: boolean;
  94108. /**
  94109. * Returns the mesh itself by default. Implemented by child classes
  94110. * @param camera defines the camera to use to pick the right LOD level
  94111. * @returns the currentAbstractMesh
  94112. */
  94113. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94114. /**
  94115. * Returns 0 by default. Implemented by child classes
  94116. * @returns an integer
  94117. */
  94118. getTotalVertices(): number;
  94119. /**
  94120. * Returns a positive integer : the total number of indices in this mesh geometry.
  94121. * @returns the numner of indices or zero if the mesh has no geometry.
  94122. */
  94123. getTotalIndices(): number;
  94124. /**
  94125. * Returns null by default. Implemented by child classes
  94126. * @returns null
  94127. */
  94128. getIndices(): Nullable<IndicesArray>;
  94129. /**
  94130. * Returns the array of the requested vertex data kind. Implemented by child classes
  94131. * @param kind defines the vertex data kind to use
  94132. * @returns null
  94133. */
  94134. getVerticesData(kind: string): Nullable<FloatArray>;
  94135. /**
  94136. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94137. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94138. * Note that a new underlying VertexBuffer object is created each call.
  94139. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94140. * @param kind defines vertex data kind:
  94141. * * VertexBuffer.PositionKind
  94142. * * VertexBuffer.UVKind
  94143. * * VertexBuffer.UV2Kind
  94144. * * VertexBuffer.UV3Kind
  94145. * * VertexBuffer.UV4Kind
  94146. * * VertexBuffer.UV5Kind
  94147. * * VertexBuffer.UV6Kind
  94148. * * VertexBuffer.ColorKind
  94149. * * VertexBuffer.MatricesIndicesKind
  94150. * * VertexBuffer.MatricesIndicesExtraKind
  94151. * * VertexBuffer.MatricesWeightsKind
  94152. * * VertexBuffer.MatricesWeightsExtraKind
  94153. * @param data defines the data source
  94154. * @param updatable defines if the data must be flagged as updatable (or static)
  94155. * @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
  94156. * @returns the current mesh
  94157. */
  94158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94159. /**
  94160. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94161. * If the mesh has no geometry, it is simply returned as it is.
  94162. * @param kind defines vertex data kind:
  94163. * * VertexBuffer.PositionKind
  94164. * * VertexBuffer.UVKind
  94165. * * VertexBuffer.UV2Kind
  94166. * * VertexBuffer.UV3Kind
  94167. * * VertexBuffer.UV4Kind
  94168. * * VertexBuffer.UV5Kind
  94169. * * VertexBuffer.UV6Kind
  94170. * * VertexBuffer.ColorKind
  94171. * * VertexBuffer.MatricesIndicesKind
  94172. * * VertexBuffer.MatricesIndicesExtraKind
  94173. * * VertexBuffer.MatricesWeightsKind
  94174. * * VertexBuffer.MatricesWeightsExtraKind
  94175. * @param data defines the data source
  94176. * @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
  94177. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94178. * @returns the current mesh
  94179. */
  94180. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94181. /**
  94182. * Sets the mesh indices,
  94183. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94184. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94185. * @param totalVertices Defines the total number of vertices
  94186. * @returns the current mesh
  94187. */
  94188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94189. /**
  94190. * Gets a boolean indicating if specific vertex data is present
  94191. * @param kind defines the vertex data kind to use
  94192. * @returns true is data kind is present
  94193. */
  94194. isVerticesDataPresent(kind: string): boolean;
  94195. /**
  94196. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94197. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94198. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94199. * @returns a BoundingInfo
  94200. */
  94201. getBoundingInfo(): BoundingInfo;
  94202. /**
  94203. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94204. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94205. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94206. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94207. * @returns the current mesh
  94208. */
  94209. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94210. /**
  94211. * Overwrite the current bounding info
  94212. * @param boundingInfo defines the new bounding info
  94213. * @returns the current mesh
  94214. */
  94215. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94216. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94217. readonly useBones: boolean;
  94218. /** @hidden */
  94219. _preActivate(): void;
  94220. /** @hidden */
  94221. _preActivateForIntermediateRendering(renderId: number): void;
  94222. /** @hidden */
  94223. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94224. /** @hidden */
  94225. _postActivate(): void;
  94226. /** @hidden */
  94227. _freeze(): void;
  94228. /** @hidden */
  94229. _unFreeze(): void;
  94230. /**
  94231. * Gets the current world matrix
  94232. * @returns a Matrix
  94233. */
  94234. getWorldMatrix(): Matrix;
  94235. /** @hidden */
  94236. _getWorldMatrixDeterminant(): number;
  94237. /**
  94238. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94239. */
  94240. readonly isAnInstance: boolean;
  94241. /**
  94242. * Gets a boolean indicating if this mesh has instances
  94243. */
  94244. readonly hasInstances: boolean;
  94245. /**
  94246. * Perform relative position change from the point of view of behind the front of the mesh.
  94247. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94248. * Supports definition of mesh facing forward or backward
  94249. * @param amountRight defines the distance on the right axis
  94250. * @param amountUp defines the distance on the up axis
  94251. * @param amountForward defines the distance on the forward axis
  94252. * @returns the current mesh
  94253. */
  94254. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94255. /**
  94256. * Calculate relative position change from the point of view of behind the front of the mesh.
  94257. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94258. * Supports definition of mesh facing forward or backward
  94259. * @param amountRight defines the distance on the right axis
  94260. * @param amountUp defines the distance on the up axis
  94261. * @param amountForward defines the distance on the forward axis
  94262. * @returns the new displacement vector
  94263. */
  94264. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94265. /**
  94266. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94267. * Supports definition of mesh facing forward or backward
  94268. * @param flipBack defines the flip
  94269. * @param twirlClockwise defines the twirl
  94270. * @param tiltRight defines the tilt
  94271. * @returns the current mesh
  94272. */
  94273. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94274. /**
  94275. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94276. * Supports definition of mesh facing forward or backward.
  94277. * @param flipBack defines the flip
  94278. * @param twirlClockwise defines the twirl
  94279. * @param tiltRight defines the tilt
  94280. * @returns the new rotation vector
  94281. */
  94282. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94283. /**
  94284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94285. * This means the mesh underlying bounding box and sphere are recomputed.
  94286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94287. * @returns the current mesh
  94288. */
  94289. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94290. /** @hidden */
  94291. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94292. /** @hidden */
  94293. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94294. /** @hidden */
  94295. _updateBoundingInfo(): AbstractMesh;
  94296. /** @hidden */
  94297. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94298. /** @hidden */
  94299. protected _afterComputeWorldMatrix(): void;
  94300. /** @hidden */
  94301. readonly _effectiveMesh: AbstractMesh;
  94302. /**
  94303. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94304. * A mesh is in the frustum if its bounding box intersects the frustum
  94305. * @param frustumPlanes defines the frustum to test
  94306. * @returns true if the mesh is in the frustum planes
  94307. */
  94308. isInFrustum(frustumPlanes: Plane[]): boolean;
  94309. /**
  94310. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94311. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94312. * @param frustumPlanes defines the frustum to test
  94313. * @returns true if the mesh is completely in the frustum planes
  94314. */
  94315. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94316. /**
  94317. * True if the mesh intersects another mesh or a SolidParticle object
  94318. * @param mesh defines a target mesh or SolidParticle to test
  94319. * @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)
  94320. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94321. * @returns true if there is an intersection
  94322. */
  94323. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94324. /**
  94325. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94326. * @param point defines the point to test
  94327. * @returns true if there is an intersection
  94328. */
  94329. intersectsPoint(point: Vector3): boolean;
  94330. /**
  94331. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94333. */
  94334. checkCollisions: boolean;
  94335. /**
  94336. * Gets Collider object used to compute collisions (not physics)
  94337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94338. */
  94339. readonly collider: Nullable<Collider>;
  94340. /**
  94341. * Move the mesh using collision engine
  94342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94343. * @param displacement defines the requested displacement vector
  94344. * @returns the current mesh
  94345. */
  94346. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94347. private _onCollisionPositionChange;
  94348. /** @hidden */
  94349. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94350. /** @hidden */
  94351. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94352. /** @hidden */
  94353. _checkCollision(collider: Collider): AbstractMesh;
  94354. /** @hidden */
  94355. _generatePointsArray(): boolean;
  94356. /**
  94357. * Checks if the passed Ray intersects with the mesh
  94358. * @param ray defines the ray to use
  94359. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94361. * @returns the picking info
  94362. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94363. */
  94364. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94365. /**
  94366. * Clones the current mesh
  94367. * @param name defines the mesh name
  94368. * @param newParent defines the new mesh parent
  94369. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94370. * @returns the new mesh
  94371. */
  94372. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94373. /**
  94374. * Disposes all the submeshes of the current meshnp
  94375. * @returns the current mesh
  94376. */
  94377. releaseSubMeshes(): AbstractMesh;
  94378. /**
  94379. * Releases resources associated with this abstract mesh.
  94380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94382. */
  94383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94384. /**
  94385. * Adds the passed mesh as a child to the current mesh
  94386. * @param mesh defines the child mesh
  94387. * @returns the current mesh
  94388. */
  94389. addChild(mesh: AbstractMesh): AbstractMesh;
  94390. /**
  94391. * Removes the passed mesh from the current mesh children list
  94392. * @param mesh defines the child mesh
  94393. * @returns the current mesh
  94394. */
  94395. removeChild(mesh: AbstractMesh): AbstractMesh;
  94396. /** @hidden */
  94397. private _initFacetData;
  94398. /**
  94399. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94400. * This method can be called within the render loop.
  94401. * 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
  94402. * @returns the current mesh
  94403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94404. */
  94405. updateFacetData(): AbstractMesh;
  94406. /**
  94407. * Returns the facetLocalNormals array.
  94408. * The normals are expressed in the mesh local spac
  94409. * @returns an array of Vector3
  94410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94411. */
  94412. getFacetLocalNormals(): Vector3[];
  94413. /**
  94414. * Returns the facetLocalPositions array.
  94415. * The facet positions are expressed in the mesh local space
  94416. * @returns an array of Vector3
  94417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94418. */
  94419. getFacetLocalPositions(): Vector3[];
  94420. /**
  94421. * Returns the facetLocalPartioning array
  94422. * @returns an array of array of numbers
  94423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94424. */
  94425. getFacetLocalPartitioning(): number[][];
  94426. /**
  94427. * Returns the i-th facet position in the world system.
  94428. * This method allocates a new Vector3 per call
  94429. * @param i defines the facet index
  94430. * @returns a new Vector3
  94431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94432. */
  94433. getFacetPosition(i: number): Vector3;
  94434. /**
  94435. * Sets the reference Vector3 with the i-th facet position in the world system
  94436. * @param i defines the facet index
  94437. * @param ref defines the target vector
  94438. * @returns the current mesh
  94439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94440. */
  94441. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94442. /**
  94443. * Returns the i-th facet normal in the world system.
  94444. * This method allocates a new Vector3 per call
  94445. * @param i defines the facet index
  94446. * @returns a new Vector3
  94447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94448. */
  94449. getFacetNormal(i: number): Vector3;
  94450. /**
  94451. * Sets the reference Vector3 with the i-th facet normal in the world system
  94452. * @param i defines the facet index
  94453. * @param ref defines the target vector
  94454. * @returns the current mesh
  94455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94456. */
  94457. getFacetNormalToRef(i: number, ref: Vector3): this;
  94458. /**
  94459. * 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)
  94460. * @param x defines x coordinate
  94461. * @param y defines y coordinate
  94462. * @param z defines z coordinate
  94463. * @returns the array of facet indexes
  94464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94465. */
  94466. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94467. /**
  94468. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94469. * @param projected sets as the (x,y,z) world projection on the facet
  94470. * @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
  94471. * @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
  94472. * @param x defines x coordinate
  94473. * @param y defines y coordinate
  94474. * @param z defines z coordinate
  94475. * @returns the face index if found (or null instead)
  94476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94477. */
  94478. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94479. /**
  94480. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94481. * @param projected sets as the (x,y,z) local projection on the facet
  94482. * @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
  94483. * @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
  94484. * @param x defines x coordinate
  94485. * @param y defines y coordinate
  94486. * @param z defines z coordinate
  94487. * @returns the face index if found (or null instead)
  94488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94489. */
  94490. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94491. /**
  94492. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94493. * @returns the parameters
  94494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94495. */
  94496. getFacetDataParameters(): any;
  94497. /**
  94498. * Disables the feature FacetData and frees the related memory
  94499. * @returns the current mesh
  94500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94501. */
  94502. disableFacetData(): AbstractMesh;
  94503. /**
  94504. * Updates the AbstractMesh indices array
  94505. * @param indices defines the data source
  94506. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94507. * @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)
  94508. * @returns the current mesh
  94509. */
  94510. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94511. /**
  94512. * Creates new normals data for the mesh
  94513. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94514. * @returns the current mesh
  94515. */
  94516. createNormals(updatable: boolean): AbstractMesh;
  94517. /**
  94518. * Align the mesh with a normal
  94519. * @param normal defines the normal to use
  94520. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94521. * @returns the current mesh
  94522. */
  94523. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94524. /** @hidden */
  94525. _checkOcclusionQuery(): boolean;
  94526. /**
  94527. * Disables the mesh edge rendering mode
  94528. * @returns the currentAbstractMesh
  94529. */
  94530. disableEdgesRendering(): AbstractMesh;
  94531. /**
  94532. * Enables the edge rendering mode on the mesh.
  94533. * This mode makes the mesh edges visible
  94534. * @param epsilon defines the maximal distance between two angles to detect a face
  94535. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94536. * @returns the currentAbstractMesh
  94537. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94538. */
  94539. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94540. }
  94541. }
  94542. declare module BABYLON {
  94543. /**
  94544. * Interface used to define ActionEvent
  94545. */
  94546. export interface IActionEvent {
  94547. /** The mesh or sprite that triggered the action */
  94548. source: any;
  94549. /** The X mouse cursor position at the time of the event */
  94550. pointerX: number;
  94551. /** The Y mouse cursor position at the time of the event */
  94552. pointerY: number;
  94553. /** The mesh that is currently pointed at (can be null) */
  94554. meshUnderPointer: Nullable<AbstractMesh>;
  94555. /** the original (browser) event that triggered the ActionEvent */
  94556. sourceEvent?: any;
  94557. /** additional data for the event */
  94558. additionalData?: any;
  94559. }
  94560. /**
  94561. * ActionEvent is the event being sent when an action is triggered.
  94562. */
  94563. export class ActionEvent implements IActionEvent {
  94564. /** The mesh or sprite that triggered the action */
  94565. source: any;
  94566. /** The X mouse cursor position at the time of the event */
  94567. pointerX: number;
  94568. /** The Y mouse cursor position at the time of the event */
  94569. pointerY: number;
  94570. /** The mesh that is currently pointed at (can be null) */
  94571. meshUnderPointer: Nullable<AbstractMesh>;
  94572. /** the original (browser) event that triggered the ActionEvent */
  94573. sourceEvent?: any;
  94574. /** additional data for the event */
  94575. additionalData?: any;
  94576. /**
  94577. * Creates a new ActionEvent
  94578. * @param source The mesh or sprite that triggered the action
  94579. * @param pointerX The X mouse cursor position at the time of the event
  94580. * @param pointerY The Y mouse cursor position at the time of the event
  94581. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94582. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94583. * @param additionalData additional data for the event
  94584. */
  94585. constructor(
  94586. /** The mesh or sprite that triggered the action */
  94587. source: any,
  94588. /** The X mouse cursor position at the time of the event */
  94589. pointerX: number,
  94590. /** The Y mouse cursor position at the time of the event */
  94591. pointerY: number,
  94592. /** The mesh that is currently pointed at (can be null) */
  94593. meshUnderPointer: Nullable<AbstractMesh>,
  94594. /** the original (browser) event that triggered the ActionEvent */
  94595. sourceEvent?: any,
  94596. /** additional data for the event */
  94597. additionalData?: any);
  94598. /**
  94599. * Helper function to auto-create an ActionEvent from a source mesh.
  94600. * @param source The source mesh that triggered the event
  94601. * @param evt The original (browser) event
  94602. * @param additionalData additional data for the event
  94603. * @returns the new ActionEvent
  94604. */
  94605. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94606. /**
  94607. * Helper function to auto-create an ActionEvent from a source sprite
  94608. * @param source The source sprite that triggered the event
  94609. * @param scene Scene associated with the sprite
  94610. * @param evt The original (browser) event
  94611. * @param additionalData additional data for the event
  94612. * @returns the new ActionEvent
  94613. */
  94614. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94615. /**
  94616. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94617. * @param scene the scene where the event occurred
  94618. * @param evt The original (browser) event
  94619. * @returns the new ActionEvent
  94620. */
  94621. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94622. /**
  94623. * Helper function to auto-create an ActionEvent from a primitive
  94624. * @param prim defines the target primitive
  94625. * @param pointerPos defines the pointer position
  94626. * @param evt The original (browser) event
  94627. * @param additionalData additional data for the event
  94628. * @returns the new ActionEvent
  94629. */
  94630. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94631. }
  94632. }
  94633. declare module BABYLON {
  94634. /**
  94635. * Abstract class used to decouple action Manager from scene and meshes.
  94636. * Do not instantiate.
  94637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94638. */
  94639. export abstract class AbstractActionManager implements IDisposable {
  94640. /** Gets the list of active triggers */
  94641. static Triggers: {
  94642. [key: string]: number;
  94643. };
  94644. /** Gets the cursor to use when hovering items */
  94645. hoverCursor: string;
  94646. /** Gets the list of actions */
  94647. actions: IAction[];
  94648. /**
  94649. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94650. */
  94651. isRecursive: boolean;
  94652. /**
  94653. * Releases all associated resources
  94654. */
  94655. abstract dispose(): void;
  94656. /**
  94657. * Does this action manager has pointer triggers
  94658. */
  94659. abstract readonly hasPointerTriggers: boolean;
  94660. /**
  94661. * Does this action manager has pick triggers
  94662. */
  94663. abstract readonly hasPickTriggers: boolean;
  94664. /**
  94665. * Process a specific trigger
  94666. * @param trigger defines the trigger to process
  94667. * @param evt defines the event details to be processed
  94668. */
  94669. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94670. /**
  94671. * Does this action manager handles actions of any of the given triggers
  94672. * @param triggers defines the triggers to be tested
  94673. * @return a boolean indicating whether one (or more) of the triggers is handled
  94674. */
  94675. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94676. /**
  94677. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94678. * speed.
  94679. * @param triggerA defines the trigger to be tested
  94680. * @param triggerB defines the trigger to be tested
  94681. * @return a boolean indicating whether one (or more) of the triggers is handled
  94682. */
  94683. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94684. /**
  94685. * Does this action manager handles actions of a given trigger
  94686. * @param trigger defines the trigger to be tested
  94687. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94688. * @return whether the trigger is handled
  94689. */
  94690. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94691. /**
  94692. * Serialize this manager to a JSON object
  94693. * @param name defines the property name to store this manager
  94694. * @returns a JSON representation of this manager
  94695. */
  94696. abstract serialize(name: string): any;
  94697. /**
  94698. * Registers an action to this action manager
  94699. * @param action defines the action to be registered
  94700. * @return the action amended (prepared) after registration
  94701. */
  94702. abstract registerAction(action: IAction): Nullable<IAction>;
  94703. /**
  94704. * Unregisters an action to this action manager
  94705. * @param action defines the action to be unregistered
  94706. * @return a boolean indicating whether the action has been unregistered
  94707. */
  94708. abstract unregisterAction(action: IAction): Boolean;
  94709. /**
  94710. * Does exist one action manager with at least one trigger
  94711. **/
  94712. static readonly HasTriggers: boolean;
  94713. /**
  94714. * Does exist one action manager with at least one pick trigger
  94715. **/
  94716. static readonly HasPickTriggers: boolean;
  94717. /**
  94718. * Does exist one action manager that handles actions of a given trigger
  94719. * @param trigger defines the trigger to be tested
  94720. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94721. **/
  94722. static HasSpecificTrigger(trigger: number): boolean;
  94723. }
  94724. }
  94725. declare module BABYLON {
  94726. /**
  94727. * Defines how a node can be built from a string name.
  94728. */
  94729. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94730. /**
  94731. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94732. */
  94733. export class Node implements IBehaviorAware<Node> {
  94734. /** @hidden */
  94735. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94736. private static _NodeConstructors;
  94737. /**
  94738. * Add a new node constructor
  94739. * @param type defines the type name of the node to construct
  94740. * @param constructorFunc defines the constructor function
  94741. */
  94742. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94743. /**
  94744. * Returns a node constructor based on type name
  94745. * @param type defines the type name
  94746. * @param name defines the new node name
  94747. * @param scene defines the hosting scene
  94748. * @param options defines optional options to transmit to constructors
  94749. * @returns the new constructor or null
  94750. */
  94751. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94752. /**
  94753. * Gets or sets the name of the node
  94754. */
  94755. name: string;
  94756. /**
  94757. * Gets or sets the id of the node
  94758. */
  94759. id: string;
  94760. /**
  94761. * Gets or sets the unique id of the node
  94762. */
  94763. uniqueId: number;
  94764. /**
  94765. * Gets or sets a string used to store user defined state for the node
  94766. */
  94767. state: string;
  94768. /**
  94769. * Gets or sets an object used to store user defined information for the node
  94770. */
  94771. metadata: any;
  94772. /**
  94773. * For internal use only. Please do not use.
  94774. */
  94775. reservedDataStore: any;
  94776. /**
  94777. * List of inspectable custom properties (used by the Inspector)
  94778. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94779. */
  94780. inspectableCustomProperties: IInspectable[];
  94781. private _doNotSerialize;
  94782. /**
  94783. * Gets or sets a boolean used to define if the node must be serialized
  94784. */
  94785. doNotSerialize: boolean;
  94786. /** @hidden */
  94787. _isDisposed: boolean;
  94788. /**
  94789. * Gets a list of Animations associated with the node
  94790. */
  94791. animations: Animation[];
  94792. protected _ranges: {
  94793. [name: string]: Nullable<AnimationRange>;
  94794. };
  94795. /**
  94796. * Callback raised when the node is ready to be used
  94797. */
  94798. onReady: Nullable<(node: Node) => void>;
  94799. private _isEnabled;
  94800. private _isParentEnabled;
  94801. private _isReady;
  94802. /** @hidden */
  94803. _currentRenderId: number;
  94804. private _parentUpdateId;
  94805. /** @hidden */
  94806. _childUpdateId: number;
  94807. /** @hidden */
  94808. _waitingParentId: Nullable<string>;
  94809. /** @hidden */
  94810. _scene: Scene;
  94811. /** @hidden */
  94812. _cache: any;
  94813. private _parentNode;
  94814. private _children;
  94815. /** @hidden */
  94816. _worldMatrix: Matrix;
  94817. /** @hidden */
  94818. _worldMatrixDeterminant: number;
  94819. /** @hidden */
  94820. _worldMatrixDeterminantIsDirty: boolean;
  94821. /** @hidden */
  94822. private _sceneRootNodesIndex;
  94823. /**
  94824. * Gets a boolean indicating if the node has been disposed
  94825. * @returns true if the node was disposed
  94826. */
  94827. isDisposed(): boolean;
  94828. /**
  94829. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94830. * @see https://doc.babylonjs.com/how_to/parenting
  94831. */
  94832. parent: Nullable<Node>;
  94833. /** @hidden */
  94834. _addToSceneRootNodes(): void;
  94835. /** @hidden */
  94836. _removeFromSceneRootNodes(): void;
  94837. private _animationPropertiesOverride;
  94838. /**
  94839. * Gets or sets the animation properties override
  94840. */
  94841. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94842. /**
  94843. * Gets a string idenfifying the name of the class
  94844. * @returns "Node" string
  94845. */
  94846. getClassName(): string;
  94847. /** @hidden */
  94848. readonly _isNode: boolean;
  94849. /**
  94850. * An event triggered when the mesh is disposed
  94851. */
  94852. onDisposeObservable: Observable<Node>;
  94853. private _onDisposeObserver;
  94854. /**
  94855. * Sets a callback that will be raised when the node will be disposed
  94856. */
  94857. onDispose: () => void;
  94858. /**
  94859. * Creates a new Node
  94860. * @param name the name and id to be given to this node
  94861. * @param scene the scene this node will be added to
  94862. */
  94863. constructor(name: string, scene?: Nullable<Scene>);
  94864. /**
  94865. * Gets the scene of the node
  94866. * @returns a scene
  94867. */
  94868. getScene(): Scene;
  94869. /**
  94870. * Gets the engine of the node
  94871. * @returns a Engine
  94872. */
  94873. getEngine(): Engine;
  94874. private _behaviors;
  94875. /**
  94876. * Attach a behavior to the node
  94877. * @see http://doc.babylonjs.com/features/behaviour
  94878. * @param behavior defines the behavior to attach
  94879. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94880. * @returns the current Node
  94881. */
  94882. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94883. /**
  94884. * Remove an attached behavior
  94885. * @see http://doc.babylonjs.com/features/behaviour
  94886. * @param behavior defines the behavior to attach
  94887. * @returns the current Node
  94888. */
  94889. removeBehavior(behavior: Behavior<Node>): Node;
  94890. /**
  94891. * Gets the list of attached behaviors
  94892. * @see http://doc.babylonjs.com/features/behaviour
  94893. */
  94894. readonly behaviors: Behavior<Node>[];
  94895. /**
  94896. * Gets an attached behavior by name
  94897. * @param name defines the name of the behavior to look for
  94898. * @see http://doc.babylonjs.com/features/behaviour
  94899. * @returns null if behavior was not found else the requested behavior
  94900. */
  94901. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94902. /**
  94903. * Returns the latest update of the World matrix
  94904. * @returns a Matrix
  94905. */
  94906. getWorldMatrix(): Matrix;
  94907. /** @hidden */
  94908. _getWorldMatrixDeterminant(): number;
  94909. /**
  94910. * Returns directly the latest state of the mesh World matrix.
  94911. * A Matrix is returned.
  94912. */
  94913. readonly worldMatrixFromCache: Matrix;
  94914. /** @hidden */
  94915. _initCache(): void;
  94916. /** @hidden */
  94917. updateCache(force?: boolean): void;
  94918. /** @hidden */
  94919. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94920. /** @hidden */
  94921. _updateCache(ignoreParentClass?: boolean): void;
  94922. /** @hidden */
  94923. _isSynchronized(): boolean;
  94924. /** @hidden */
  94925. _markSyncedWithParent(): void;
  94926. /** @hidden */
  94927. isSynchronizedWithParent(): boolean;
  94928. /** @hidden */
  94929. isSynchronized(): boolean;
  94930. /**
  94931. * Is this node ready to be used/rendered
  94932. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94933. * @return true if the node is ready
  94934. */
  94935. isReady(completeCheck?: boolean): boolean;
  94936. /**
  94937. * Is this node enabled?
  94938. * 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
  94939. * @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
  94940. * @return whether this node (and its parent) is enabled
  94941. */
  94942. isEnabled(checkAncestors?: boolean): boolean;
  94943. /** @hidden */
  94944. protected _syncParentEnabledState(): void;
  94945. /**
  94946. * Set the enabled state of this node
  94947. * @param value defines the new enabled state
  94948. */
  94949. setEnabled(value: boolean): void;
  94950. /**
  94951. * Is this node a descendant of the given node?
  94952. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94953. * @param ancestor defines the parent node to inspect
  94954. * @returns a boolean indicating if this node is a descendant of the given node
  94955. */
  94956. isDescendantOf(ancestor: Node): boolean;
  94957. /** @hidden */
  94958. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94959. /**
  94960. * Will return all nodes that have this node as ascendant
  94961. * @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
  94962. * @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
  94963. * @return all children nodes of all types
  94964. */
  94965. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94966. /**
  94967. * Get all child-meshes of this node
  94968. * @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)
  94969. * @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
  94970. * @returns an array of AbstractMesh
  94971. */
  94972. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94973. /**
  94974. * Get all direct children of this node
  94975. * @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
  94976. * @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)
  94977. * @returns an array of Node
  94978. */
  94979. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94980. /** @hidden */
  94981. _setReady(state: boolean): void;
  94982. /**
  94983. * Get an animation by name
  94984. * @param name defines the name of the animation to look for
  94985. * @returns null if not found else the requested animation
  94986. */
  94987. getAnimationByName(name: string): Nullable<Animation>;
  94988. /**
  94989. * Creates an animation range for this node
  94990. * @param name defines the name of the range
  94991. * @param from defines the starting key
  94992. * @param to defines the end key
  94993. */
  94994. createAnimationRange(name: string, from: number, to: number): void;
  94995. /**
  94996. * Delete a specific animation range
  94997. * @param name defines the name of the range to delete
  94998. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94999. */
  95000. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95001. /**
  95002. * Get an animation range by name
  95003. * @param name defines the name of the animation range to look for
  95004. * @returns null if not found else the requested animation range
  95005. */
  95006. getAnimationRange(name: string): Nullable<AnimationRange>;
  95007. /**
  95008. * Gets the list of all animation ranges defined on this node
  95009. * @returns an array
  95010. */
  95011. getAnimationRanges(): Nullable<AnimationRange>[];
  95012. /**
  95013. * Will start the animation sequence
  95014. * @param name defines the range frames for animation sequence
  95015. * @param loop defines if the animation should loop (false by default)
  95016. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95017. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95018. * @returns the object created for this animation. If range does not exist, it will return null
  95019. */
  95020. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95021. /**
  95022. * Serialize animation ranges into a JSON compatible object
  95023. * @returns serialization object
  95024. */
  95025. serializeAnimationRanges(): any;
  95026. /**
  95027. * Computes the world matrix of the node
  95028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95029. * @returns the world matrix
  95030. */
  95031. computeWorldMatrix(force?: boolean): Matrix;
  95032. /**
  95033. * Releases resources associated with this node.
  95034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95036. */
  95037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95038. /**
  95039. * Parse animation range data from a serialization object and store them into a given node
  95040. * @param node defines where to store the animation ranges
  95041. * @param parsedNode defines the serialization object to read data from
  95042. * @param scene defines the hosting scene
  95043. */
  95044. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95045. /**
  95046. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95047. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95048. * @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
  95049. * @returns the new bounding vectors
  95050. */
  95051. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95052. min: Vector3;
  95053. max: Vector3;
  95054. };
  95055. }
  95056. }
  95057. declare module BABYLON {
  95058. /**
  95059. * @hidden
  95060. */
  95061. export class _IAnimationState {
  95062. key: number;
  95063. repeatCount: number;
  95064. workValue?: any;
  95065. loopMode?: number;
  95066. offsetValue?: any;
  95067. highLimitValue?: any;
  95068. }
  95069. /**
  95070. * Class used to store any kind of animation
  95071. */
  95072. export class Animation {
  95073. /**Name of the animation */
  95074. name: string;
  95075. /**Property to animate */
  95076. targetProperty: string;
  95077. /**The frames per second of the animation */
  95078. framePerSecond: number;
  95079. /**The data type of the animation */
  95080. dataType: number;
  95081. /**The loop mode of the animation */
  95082. loopMode?: number | undefined;
  95083. /**Specifies if blending should be enabled */
  95084. enableBlending?: boolean | undefined;
  95085. /**
  95086. * Use matrix interpolation instead of using direct key value when animating matrices
  95087. */
  95088. static AllowMatricesInterpolation: boolean;
  95089. /**
  95090. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95091. */
  95092. static AllowMatrixDecomposeForInterpolation: boolean;
  95093. /**
  95094. * Stores the key frames of the animation
  95095. */
  95096. private _keys;
  95097. /**
  95098. * Stores the easing function of the animation
  95099. */
  95100. private _easingFunction;
  95101. /**
  95102. * @hidden Internal use only
  95103. */
  95104. _runtimeAnimations: RuntimeAnimation[];
  95105. /**
  95106. * The set of event that will be linked to this animation
  95107. */
  95108. private _events;
  95109. /**
  95110. * Stores an array of target property paths
  95111. */
  95112. targetPropertyPath: string[];
  95113. /**
  95114. * Stores the blending speed of the animation
  95115. */
  95116. blendingSpeed: number;
  95117. /**
  95118. * Stores the animation ranges for the animation
  95119. */
  95120. private _ranges;
  95121. /**
  95122. * @hidden Internal use
  95123. */
  95124. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95125. /**
  95126. * Sets up an animation
  95127. * @param property The property to animate
  95128. * @param animationType The animation type to apply
  95129. * @param framePerSecond The frames per second of the animation
  95130. * @param easingFunction The easing function used in the animation
  95131. * @returns The created animation
  95132. */
  95133. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95134. /**
  95135. * Create and start an animation on a node
  95136. * @param name defines the name of the global animation that will be run on all nodes
  95137. * @param node defines the root node where the animation will take place
  95138. * @param targetProperty defines property to animate
  95139. * @param framePerSecond defines the number of frame per second yo use
  95140. * @param totalFrame defines the number of frames in total
  95141. * @param from defines the initial value
  95142. * @param to defines the final value
  95143. * @param loopMode defines which loop mode you want to use (off by default)
  95144. * @param easingFunction defines the easing function to use (linear by default)
  95145. * @param onAnimationEnd defines the callback to call when animation end
  95146. * @returns the animatable created for this animation
  95147. */
  95148. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95149. /**
  95150. * Create and start an animation on a node and its descendants
  95151. * @param name defines the name of the global animation that will be run on all nodes
  95152. * @param node defines the root node where the animation will take place
  95153. * @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
  95154. * @param targetProperty defines property to animate
  95155. * @param framePerSecond defines the number of frame per second to use
  95156. * @param totalFrame defines the number of frames in total
  95157. * @param from defines the initial value
  95158. * @param to defines the final value
  95159. * @param loopMode defines which loop mode you want to use (off by default)
  95160. * @param easingFunction defines the easing function to use (linear by default)
  95161. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95162. * @returns the list of animatables created for all nodes
  95163. * @example https://www.babylonjs-playground.com/#MH0VLI
  95164. */
  95165. 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[]>;
  95166. /**
  95167. * Creates a new animation, merges it with the existing animations and starts it
  95168. * @param name Name of the animation
  95169. * @param node Node which contains the scene that begins the animations
  95170. * @param targetProperty Specifies which property to animate
  95171. * @param framePerSecond The frames per second of the animation
  95172. * @param totalFrame The total number of frames
  95173. * @param from The frame at the beginning of the animation
  95174. * @param to The frame at the end of the animation
  95175. * @param loopMode Specifies the loop mode of the animation
  95176. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95177. * @param onAnimationEnd Callback to run once the animation is complete
  95178. * @returns Nullable animation
  95179. */
  95180. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95181. /**
  95182. * Transition property of an host to the target Value
  95183. * @param property The property to transition
  95184. * @param targetValue The target Value of the property
  95185. * @param host The object where the property to animate belongs
  95186. * @param scene Scene used to run the animation
  95187. * @param frameRate Framerate (in frame/s) to use
  95188. * @param transition The transition type we want to use
  95189. * @param duration The duration of the animation, in milliseconds
  95190. * @param onAnimationEnd Callback trigger at the end of the animation
  95191. * @returns Nullable animation
  95192. */
  95193. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95194. /**
  95195. * Return the array of runtime animations currently using this animation
  95196. */
  95197. readonly runtimeAnimations: RuntimeAnimation[];
  95198. /**
  95199. * Specifies if any of the runtime animations are currently running
  95200. */
  95201. readonly hasRunningRuntimeAnimations: boolean;
  95202. /**
  95203. * Initializes the animation
  95204. * @param name Name of the animation
  95205. * @param targetProperty Property to animate
  95206. * @param framePerSecond The frames per second of the animation
  95207. * @param dataType The data type of the animation
  95208. * @param loopMode The loop mode of the animation
  95209. * @param enableBlending Specifies if blending should be enabled
  95210. */
  95211. constructor(
  95212. /**Name of the animation */
  95213. name: string,
  95214. /**Property to animate */
  95215. targetProperty: string,
  95216. /**The frames per second of the animation */
  95217. framePerSecond: number,
  95218. /**The data type of the animation */
  95219. dataType: number,
  95220. /**The loop mode of the animation */
  95221. loopMode?: number | undefined,
  95222. /**Specifies if blending should be enabled */
  95223. enableBlending?: boolean | undefined);
  95224. /**
  95225. * Converts the animation to a string
  95226. * @param fullDetails support for multiple levels of logging within scene loading
  95227. * @returns String form of the animation
  95228. */
  95229. toString(fullDetails?: boolean): string;
  95230. /**
  95231. * Add an event to this animation
  95232. * @param event Event to add
  95233. */
  95234. addEvent(event: AnimationEvent): void;
  95235. /**
  95236. * Remove all events found at the given frame
  95237. * @param frame The frame to remove events from
  95238. */
  95239. removeEvents(frame: number): void;
  95240. /**
  95241. * Retrieves all the events from the animation
  95242. * @returns Events from the animation
  95243. */
  95244. getEvents(): AnimationEvent[];
  95245. /**
  95246. * Creates an animation range
  95247. * @param name Name of the animation range
  95248. * @param from Starting frame of the animation range
  95249. * @param to Ending frame of the animation
  95250. */
  95251. createRange(name: string, from: number, to: number): void;
  95252. /**
  95253. * Deletes an animation range by name
  95254. * @param name Name of the animation range to delete
  95255. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95256. */
  95257. deleteRange(name: string, deleteFrames?: boolean): void;
  95258. /**
  95259. * Gets the animation range by name, or null if not defined
  95260. * @param name Name of the animation range
  95261. * @returns Nullable animation range
  95262. */
  95263. getRange(name: string): Nullable<AnimationRange>;
  95264. /**
  95265. * Gets the key frames from the animation
  95266. * @returns The key frames of the animation
  95267. */
  95268. getKeys(): Array<IAnimationKey>;
  95269. /**
  95270. * Gets the highest frame rate of the animation
  95271. * @returns Highest frame rate of the animation
  95272. */
  95273. getHighestFrame(): number;
  95274. /**
  95275. * Gets the easing function of the animation
  95276. * @returns Easing function of the animation
  95277. */
  95278. getEasingFunction(): IEasingFunction;
  95279. /**
  95280. * Sets the easing function of the animation
  95281. * @param easingFunction A custom mathematical formula for animation
  95282. */
  95283. setEasingFunction(easingFunction: EasingFunction): void;
  95284. /**
  95285. * Interpolates a scalar linearly
  95286. * @param startValue Start value of the animation curve
  95287. * @param endValue End value of the animation curve
  95288. * @param gradient Scalar amount to interpolate
  95289. * @returns Interpolated scalar value
  95290. */
  95291. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95292. /**
  95293. * Interpolates a scalar cubically
  95294. * @param startValue Start value of the animation curve
  95295. * @param outTangent End tangent of the animation
  95296. * @param endValue End value of the animation curve
  95297. * @param inTangent Start tangent of the animation curve
  95298. * @param gradient Scalar amount to interpolate
  95299. * @returns Interpolated scalar value
  95300. */
  95301. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95302. /**
  95303. * Interpolates a quaternion using a spherical linear interpolation
  95304. * @param startValue Start value of the animation curve
  95305. * @param endValue End value of the animation curve
  95306. * @param gradient Scalar amount to interpolate
  95307. * @returns Interpolated quaternion value
  95308. */
  95309. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95310. /**
  95311. * Interpolates a quaternion cubically
  95312. * @param startValue Start value of the animation curve
  95313. * @param outTangent End tangent of the animation curve
  95314. * @param endValue End value of the animation curve
  95315. * @param inTangent Start tangent of the animation curve
  95316. * @param gradient Scalar amount to interpolate
  95317. * @returns Interpolated quaternion value
  95318. */
  95319. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95320. /**
  95321. * Interpolates a Vector3 linearl
  95322. * @param startValue Start value of the animation curve
  95323. * @param endValue End value of the animation curve
  95324. * @param gradient Scalar amount to interpolate
  95325. * @returns Interpolated scalar value
  95326. */
  95327. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95328. /**
  95329. * Interpolates a Vector3 cubically
  95330. * @param startValue Start value of the animation curve
  95331. * @param outTangent End tangent of the animation
  95332. * @param endValue End value of the animation curve
  95333. * @param inTangent Start tangent of the animation curve
  95334. * @param gradient Scalar amount to interpolate
  95335. * @returns InterpolatedVector3 value
  95336. */
  95337. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95338. /**
  95339. * Interpolates a Vector2 linearly
  95340. * @param startValue Start value of the animation curve
  95341. * @param endValue End value of the animation curve
  95342. * @param gradient Scalar amount to interpolate
  95343. * @returns Interpolated Vector2 value
  95344. */
  95345. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95346. /**
  95347. * Interpolates a Vector2 cubically
  95348. * @param startValue Start value of the animation curve
  95349. * @param outTangent End tangent of the animation
  95350. * @param endValue End value of the animation curve
  95351. * @param inTangent Start tangent of the animation curve
  95352. * @param gradient Scalar amount to interpolate
  95353. * @returns Interpolated Vector2 value
  95354. */
  95355. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95356. /**
  95357. * Interpolates a size linearly
  95358. * @param startValue Start value of the animation curve
  95359. * @param endValue End value of the animation curve
  95360. * @param gradient Scalar amount to interpolate
  95361. * @returns Interpolated Size value
  95362. */
  95363. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95364. /**
  95365. * Interpolates a Color3 linearly
  95366. * @param startValue Start value of the animation curve
  95367. * @param endValue End value of the animation curve
  95368. * @param gradient Scalar amount to interpolate
  95369. * @returns Interpolated Color3 value
  95370. */
  95371. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95372. /**
  95373. * Interpolates a Color4 linearly
  95374. * @param startValue Start value of the animation curve
  95375. * @param endValue End value of the animation curve
  95376. * @param gradient Scalar amount to interpolate
  95377. * @returns Interpolated Color3 value
  95378. */
  95379. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95380. /**
  95381. * @hidden Internal use only
  95382. */
  95383. _getKeyValue(value: any): any;
  95384. /**
  95385. * @hidden Internal use only
  95386. */
  95387. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95388. /**
  95389. * Defines the function to use to interpolate matrices
  95390. * @param startValue defines the start matrix
  95391. * @param endValue defines the end matrix
  95392. * @param gradient defines the gradient between both matrices
  95393. * @param result defines an optional target matrix where to store the interpolation
  95394. * @returns the interpolated matrix
  95395. */
  95396. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95397. /**
  95398. * Makes a copy of the animation
  95399. * @returns Cloned animation
  95400. */
  95401. clone(): Animation;
  95402. /**
  95403. * Sets the key frames of the animation
  95404. * @param values The animation key frames to set
  95405. */
  95406. setKeys(values: Array<IAnimationKey>): void;
  95407. /**
  95408. * Serializes the animation to an object
  95409. * @returns Serialized object
  95410. */
  95411. serialize(): any;
  95412. /**
  95413. * Float animation type
  95414. */
  95415. static readonly ANIMATIONTYPE_FLOAT: number;
  95416. /**
  95417. * Vector3 animation type
  95418. */
  95419. static readonly ANIMATIONTYPE_VECTOR3: number;
  95420. /**
  95421. * Quaternion animation type
  95422. */
  95423. static readonly ANIMATIONTYPE_QUATERNION: number;
  95424. /**
  95425. * Matrix animation type
  95426. */
  95427. static readonly ANIMATIONTYPE_MATRIX: number;
  95428. /**
  95429. * Color3 animation type
  95430. */
  95431. static readonly ANIMATIONTYPE_COLOR3: number;
  95432. /**
  95433. * Color3 animation type
  95434. */
  95435. static readonly ANIMATIONTYPE_COLOR4: number;
  95436. /**
  95437. * Vector2 animation type
  95438. */
  95439. static readonly ANIMATIONTYPE_VECTOR2: number;
  95440. /**
  95441. * Size animation type
  95442. */
  95443. static readonly ANIMATIONTYPE_SIZE: number;
  95444. /**
  95445. * Relative Loop Mode
  95446. */
  95447. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95448. /**
  95449. * Cycle Loop Mode
  95450. */
  95451. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95452. /**
  95453. * Constant Loop Mode
  95454. */
  95455. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95456. /** @hidden */
  95457. static _UniversalLerp(left: any, right: any, amount: number): any;
  95458. /**
  95459. * Parses an animation object and creates an animation
  95460. * @param parsedAnimation Parsed animation object
  95461. * @returns Animation object
  95462. */
  95463. static Parse(parsedAnimation: any): Animation;
  95464. /**
  95465. * Appends the serialized animations from the source animations
  95466. * @param source Source containing the animations
  95467. * @param destination Target to store the animations
  95468. */
  95469. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95470. }
  95471. }
  95472. declare module BABYLON {
  95473. /**
  95474. * Interface containing an array of animations
  95475. */
  95476. export interface IAnimatable {
  95477. /**
  95478. * Array of animations
  95479. */
  95480. animations: Nullable<Array<Animation>>;
  95481. }
  95482. }
  95483. declare module BABYLON {
  95484. /**
  95485. * This represents all the required information to add a fresnel effect on a material:
  95486. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95487. */
  95488. export class FresnelParameters {
  95489. private _isEnabled;
  95490. /**
  95491. * Define if the fresnel effect is enable or not.
  95492. */
  95493. isEnabled: boolean;
  95494. /**
  95495. * Define the color used on edges (grazing angle)
  95496. */
  95497. leftColor: Color3;
  95498. /**
  95499. * Define the color used on center
  95500. */
  95501. rightColor: Color3;
  95502. /**
  95503. * Define bias applied to computed fresnel term
  95504. */
  95505. bias: number;
  95506. /**
  95507. * Defined the power exponent applied to fresnel term
  95508. */
  95509. power: number;
  95510. /**
  95511. * Clones the current fresnel and its valuues
  95512. * @returns a clone fresnel configuration
  95513. */
  95514. clone(): FresnelParameters;
  95515. /**
  95516. * Serializes the current fresnel parameters to a JSON representation.
  95517. * @return the JSON serialization
  95518. */
  95519. serialize(): any;
  95520. /**
  95521. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95522. * @param parsedFresnelParameters Define the JSON representation
  95523. * @returns the parsed parameters
  95524. */
  95525. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95526. }
  95527. }
  95528. declare module BABYLON {
  95529. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95530. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95531. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95532. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95533. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95534. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95535. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95536. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95537. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95538. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95539. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95540. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95541. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95542. /**
  95543. * Decorator used to define property that can be serialized as reference to a camera
  95544. * @param sourceName defines the name of the property to decorate
  95545. */
  95546. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95547. /**
  95548. * Class used to help serialization objects
  95549. */
  95550. export class SerializationHelper {
  95551. /** @hidden */
  95552. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95553. /** @hidden */
  95554. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95555. /** @hidden */
  95556. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95557. /** @hidden */
  95558. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95559. /**
  95560. * Appends the serialized animations from the source animations
  95561. * @param source Source containing the animations
  95562. * @param destination Target to store the animations
  95563. */
  95564. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95565. /**
  95566. * Static function used to serialized a specific entity
  95567. * @param entity defines the entity to serialize
  95568. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95569. * @returns a JSON compatible object representing the serialization of the entity
  95570. */
  95571. static Serialize<T>(entity: T, serializationObject?: any): any;
  95572. /**
  95573. * Creates a new entity from a serialization data object
  95574. * @param creationFunction defines a function used to instanciated the new entity
  95575. * @param source defines the source serialization data
  95576. * @param scene defines the hosting scene
  95577. * @param rootUrl defines the root url for resources
  95578. * @returns a new entity
  95579. */
  95580. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95581. /**
  95582. * Clones an object
  95583. * @param creationFunction defines the function used to instanciate the new object
  95584. * @param source defines the source object
  95585. * @returns the cloned object
  95586. */
  95587. static Clone<T>(creationFunction: () => T, source: T): T;
  95588. /**
  95589. * Instanciates a new object based on a source one (some data will be shared between both object)
  95590. * @param creationFunction defines the function used to instanciate the new object
  95591. * @param source defines the source object
  95592. * @returns the new object
  95593. */
  95594. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95595. }
  95596. }
  95597. declare module BABYLON {
  95598. /**
  95599. * Class used to manipulate GUIDs
  95600. */
  95601. export class GUID {
  95602. /**
  95603. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95604. * Be aware Math.random() could cause collisions, but:
  95605. * "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"
  95606. * @returns a pseudo random id
  95607. */
  95608. static RandomId(): string;
  95609. }
  95610. }
  95611. declare module BABYLON {
  95612. /**
  95613. * Base class of all the textures in babylon.
  95614. * It groups all the common properties the materials, post process, lights... might need
  95615. * in order to make a correct use of the texture.
  95616. */
  95617. export class BaseTexture implements IAnimatable {
  95618. /**
  95619. * Default anisotropic filtering level for the application.
  95620. * It is set to 4 as a good tradeoff between perf and quality.
  95621. */
  95622. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95623. /**
  95624. * Gets or sets the unique id of the texture
  95625. */
  95626. uniqueId: number;
  95627. /**
  95628. * Define the name of the texture.
  95629. */
  95630. name: string;
  95631. /**
  95632. * Gets or sets an object used to store user defined information.
  95633. */
  95634. metadata: any;
  95635. /**
  95636. * For internal use only. Please do not use.
  95637. */
  95638. reservedDataStore: any;
  95639. private _hasAlpha;
  95640. /**
  95641. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95642. */
  95643. hasAlpha: boolean;
  95644. /**
  95645. * Defines if the alpha value should be determined via the rgb values.
  95646. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95647. */
  95648. getAlphaFromRGB: boolean;
  95649. /**
  95650. * Intensity or strength of the texture.
  95651. * It is commonly used by materials to fine tune the intensity of the texture
  95652. */
  95653. level: number;
  95654. /**
  95655. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95656. * This is part of the texture as textures usually maps to one uv set.
  95657. */
  95658. coordinatesIndex: number;
  95659. private _coordinatesMode;
  95660. /**
  95661. * How a texture is mapped.
  95662. *
  95663. * | Value | Type | Description |
  95664. * | ----- | ----------------------------------- | ----------- |
  95665. * | 0 | EXPLICIT_MODE | |
  95666. * | 1 | SPHERICAL_MODE | |
  95667. * | 2 | PLANAR_MODE | |
  95668. * | 3 | CUBIC_MODE | |
  95669. * | 4 | PROJECTION_MODE | |
  95670. * | 5 | SKYBOX_MODE | |
  95671. * | 6 | INVCUBIC_MODE | |
  95672. * | 7 | EQUIRECTANGULAR_MODE | |
  95673. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95674. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95675. */
  95676. coordinatesMode: number;
  95677. /**
  95678. * | Value | Type | Description |
  95679. * | ----- | ------------------ | ----------- |
  95680. * | 0 | CLAMP_ADDRESSMODE | |
  95681. * | 1 | WRAP_ADDRESSMODE | |
  95682. * | 2 | MIRROR_ADDRESSMODE | |
  95683. */
  95684. wrapU: number;
  95685. /**
  95686. * | Value | Type | Description |
  95687. * | ----- | ------------------ | ----------- |
  95688. * | 0 | CLAMP_ADDRESSMODE | |
  95689. * | 1 | WRAP_ADDRESSMODE | |
  95690. * | 2 | MIRROR_ADDRESSMODE | |
  95691. */
  95692. wrapV: number;
  95693. /**
  95694. * | Value | Type | Description |
  95695. * | ----- | ------------------ | ----------- |
  95696. * | 0 | CLAMP_ADDRESSMODE | |
  95697. * | 1 | WRAP_ADDRESSMODE | |
  95698. * | 2 | MIRROR_ADDRESSMODE | |
  95699. */
  95700. wrapR: number;
  95701. /**
  95702. * With compliant hardware and browser (supporting anisotropic filtering)
  95703. * this defines the level of anisotropic filtering in the texture.
  95704. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95705. */
  95706. anisotropicFilteringLevel: number;
  95707. /**
  95708. * Define if the texture is a cube texture or if false a 2d texture.
  95709. */
  95710. isCube: boolean;
  95711. /**
  95712. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95713. */
  95714. is3D: boolean;
  95715. /**
  95716. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95717. * HDR texture are usually stored in linear space.
  95718. * This only impacts the PBR and Background materials
  95719. */
  95720. gammaSpace: boolean;
  95721. /**
  95722. * Gets or sets whether or not the texture contains RGBD data.
  95723. */
  95724. isRGBD: boolean;
  95725. /**
  95726. * Is Z inverted in the texture (useful in a cube texture).
  95727. */
  95728. invertZ: boolean;
  95729. /**
  95730. * Are mip maps generated for this texture or not.
  95731. */
  95732. readonly noMipmap: boolean;
  95733. /**
  95734. * @hidden
  95735. */
  95736. lodLevelInAlpha: boolean;
  95737. /**
  95738. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95739. */
  95740. lodGenerationOffset: number;
  95741. /**
  95742. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95743. */
  95744. lodGenerationScale: number;
  95745. /**
  95746. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95747. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95748. * average roughness values.
  95749. */
  95750. linearSpecularLOD: boolean;
  95751. /**
  95752. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95753. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95754. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95755. */
  95756. irradianceTexture: Nullable<BaseTexture>;
  95757. /**
  95758. * Define if the texture is a render target.
  95759. */
  95760. isRenderTarget: boolean;
  95761. /**
  95762. * Define the unique id of the texture in the scene.
  95763. */
  95764. readonly uid: string;
  95765. /**
  95766. * Return a string representation of the texture.
  95767. * @returns the texture as a string
  95768. */
  95769. toString(): string;
  95770. /**
  95771. * Get the class name of the texture.
  95772. * @returns "BaseTexture"
  95773. */
  95774. getClassName(): string;
  95775. /**
  95776. * Define the list of animation attached to the texture.
  95777. */
  95778. animations: Animation[];
  95779. /**
  95780. * An event triggered when the texture is disposed.
  95781. */
  95782. onDisposeObservable: Observable<BaseTexture>;
  95783. private _onDisposeObserver;
  95784. /**
  95785. * Callback triggered when the texture has been disposed.
  95786. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95787. */
  95788. onDispose: () => void;
  95789. /**
  95790. * Define the current state of the loading sequence when in delayed load mode.
  95791. */
  95792. delayLoadState: number;
  95793. private _scene;
  95794. /** @hidden */
  95795. _texture: Nullable<InternalTexture>;
  95796. private _uid;
  95797. /**
  95798. * Define if the texture is preventinga material to render or not.
  95799. * If not and the texture is not ready, the engine will use a default black texture instead.
  95800. */
  95801. readonly isBlocking: boolean;
  95802. /**
  95803. * Instantiates a new BaseTexture.
  95804. * Base class of all the textures in babylon.
  95805. * It groups all the common properties the materials, post process, lights... might need
  95806. * in order to make a correct use of the texture.
  95807. * @param scene Define the scene the texture blongs to
  95808. */
  95809. constructor(scene: Nullable<Scene>);
  95810. /**
  95811. * Get the scene the texture belongs to.
  95812. * @returns the scene or null if undefined
  95813. */
  95814. getScene(): Nullable<Scene>;
  95815. /**
  95816. * Get the texture transform matrix used to offset tile the texture for istance.
  95817. * @returns the transformation matrix
  95818. */
  95819. getTextureMatrix(): Matrix;
  95820. /**
  95821. * Get the texture reflection matrix used to rotate/transform the reflection.
  95822. * @returns the reflection matrix
  95823. */
  95824. getReflectionTextureMatrix(): Matrix;
  95825. /**
  95826. * Get the underlying lower level texture from Babylon.
  95827. * @returns the insternal texture
  95828. */
  95829. getInternalTexture(): Nullable<InternalTexture>;
  95830. /**
  95831. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95832. * @returns true if ready or not blocking
  95833. */
  95834. isReadyOrNotBlocking(): boolean;
  95835. /**
  95836. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95837. * @returns true if fully ready
  95838. */
  95839. isReady(): boolean;
  95840. private _cachedSize;
  95841. /**
  95842. * Get the size of the texture.
  95843. * @returns the texture size.
  95844. */
  95845. getSize(): ISize;
  95846. /**
  95847. * Get the base size of the texture.
  95848. * It can be different from the size if the texture has been resized for POT for instance
  95849. * @returns the base size
  95850. */
  95851. getBaseSize(): ISize;
  95852. /**
  95853. * Update the sampling mode of the texture.
  95854. * Default is Trilinear mode.
  95855. *
  95856. * | Value | Type | Description |
  95857. * | ----- | ------------------ | ----------- |
  95858. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95859. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95860. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95861. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95862. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95863. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95864. * | 7 | NEAREST_LINEAR | |
  95865. * | 8 | NEAREST_NEAREST | |
  95866. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95867. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95868. * | 11 | LINEAR_LINEAR | |
  95869. * | 12 | LINEAR_NEAREST | |
  95870. *
  95871. * > _mag_: magnification filter (close to the viewer)
  95872. * > _min_: minification filter (far from the viewer)
  95873. * > _mip_: filter used between mip map levels
  95874. *@param samplingMode Define the new sampling mode of the texture
  95875. */
  95876. updateSamplingMode(samplingMode: number): void;
  95877. /**
  95878. * Scales the texture if is `canRescale()`
  95879. * @param ratio the resize factor we want to use to rescale
  95880. */
  95881. scale(ratio: number): void;
  95882. /**
  95883. * Get if the texture can rescale.
  95884. */
  95885. readonly canRescale: boolean;
  95886. /** @hidden */
  95887. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95888. /** @hidden */
  95889. _rebuild(): void;
  95890. /**
  95891. * Triggers the load sequence in delayed load mode.
  95892. */
  95893. delayLoad(): void;
  95894. /**
  95895. * Clones the texture.
  95896. * @returns the cloned texture
  95897. */
  95898. clone(): Nullable<BaseTexture>;
  95899. /**
  95900. * Get the texture underlying type (INT, FLOAT...)
  95901. */
  95902. readonly textureType: number;
  95903. /**
  95904. * Get the texture underlying format (RGB, RGBA...)
  95905. */
  95906. readonly textureFormat: number;
  95907. /**
  95908. * Indicates that textures need to be re-calculated for all materials
  95909. */
  95910. protected _markAllSubMeshesAsTexturesDirty(): void;
  95911. /**
  95912. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95913. * This will returns an RGBA array buffer containing either in values (0-255) or
  95914. * float values (0-1) depending of the underlying buffer type.
  95915. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95916. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95917. * @param buffer defines a user defined buffer to fill with data (can be null)
  95918. * @returns The Array buffer containing the pixels data.
  95919. */
  95920. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95921. /**
  95922. * Release and destroy the underlying lower level texture aka internalTexture.
  95923. */
  95924. releaseInternalTexture(): void;
  95925. /** @hidden */
  95926. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95927. /** @hidden */
  95928. readonly _lodTextureMid: Nullable<BaseTexture>;
  95929. /** @hidden */
  95930. readonly _lodTextureLow: Nullable<BaseTexture>;
  95931. /**
  95932. * Dispose the texture and release its associated resources.
  95933. */
  95934. dispose(): void;
  95935. /**
  95936. * Serialize the texture into a JSON representation that can be parsed later on.
  95937. * @returns the JSON representation of the texture
  95938. */
  95939. serialize(): any;
  95940. /**
  95941. * Helper function to be called back once a list of texture contains only ready textures.
  95942. * @param textures Define the list of textures to wait for
  95943. * @param callback Define the callback triggered once the entire list will be ready
  95944. */
  95945. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95946. }
  95947. }
  95948. declare module BABYLON {
  95949. /**
  95950. * Options to be used when creating an effect.
  95951. */
  95952. export interface IEffectCreationOptions {
  95953. /**
  95954. * Atrributes that will be used in the shader.
  95955. */
  95956. attributes: string[];
  95957. /**
  95958. * Uniform varible names that will be set in the shader.
  95959. */
  95960. uniformsNames: string[];
  95961. /**
  95962. * Uniform buffer varible names that will be set in the shader.
  95963. */
  95964. uniformBuffersNames: string[];
  95965. /**
  95966. * Sampler texture variable names that will be set in the shader.
  95967. */
  95968. samplers: string[];
  95969. /**
  95970. * Define statements that will be set in the shader.
  95971. */
  95972. defines: any;
  95973. /**
  95974. * Possible fallbacks for this effect to improve performance when needed.
  95975. */
  95976. fallbacks: Nullable<IEffectFallbacks>;
  95977. /**
  95978. * Callback that will be called when the shader is compiled.
  95979. */
  95980. onCompiled: Nullable<(effect: Effect) => void>;
  95981. /**
  95982. * Callback that will be called if an error occurs during shader compilation.
  95983. */
  95984. onError: Nullable<(effect: Effect, errors: string) => void>;
  95985. /**
  95986. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95987. */
  95988. indexParameters?: any;
  95989. /**
  95990. * Max number of lights that can be used in the shader.
  95991. */
  95992. maxSimultaneousLights?: number;
  95993. /**
  95994. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95995. */
  95996. transformFeedbackVaryings?: Nullable<string[]>;
  95997. }
  95998. /**
  95999. * Effect containing vertex and fragment shader that can be executed on an object.
  96000. */
  96001. export class Effect implements IDisposable {
  96002. /**
  96003. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96004. */
  96005. static ShadersRepository: string;
  96006. /**
  96007. * Name of the effect.
  96008. */
  96009. name: any;
  96010. /**
  96011. * String container all the define statements that should be set on the shader.
  96012. */
  96013. defines: string;
  96014. /**
  96015. * Callback that will be called when the shader is compiled.
  96016. */
  96017. onCompiled: Nullable<(effect: Effect) => void>;
  96018. /**
  96019. * Callback that will be called if an error occurs during shader compilation.
  96020. */
  96021. onError: Nullable<(effect: Effect, errors: string) => void>;
  96022. /**
  96023. * Callback that will be called when effect is bound.
  96024. */
  96025. onBind: Nullable<(effect: Effect) => void>;
  96026. /**
  96027. * Unique ID of the effect.
  96028. */
  96029. uniqueId: number;
  96030. /**
  96031. * Observable that will be called when the shader is compiled.
  96032. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96033. */
  96034. onCompileObservable: Observable<Effect>;
  96035. /**
  96036. * Observable that will be called if an error occurs during shader compilation.
  96037. */
  96038. onErrorObservable: Observable<Effect>;
  96039. /** @hidden */
  96040. _onBindObservable: Nullable<Observable<Effect>>;
  96041. /**
  96042. * Observable that will be called when effect is bound.
  96043. */
  96044. readonly onBindObservable: Observable<Effect>;
  96045. /** @hidden */
  96046. _bonesComputationForcedToCPU: boolean;
  96047. private static _uniqueIdSeed;
  96048. private _engine;
  96049. private _uniformBuffersNames;
  96050. private _uniformsNames;
  96051. private _samplerList;
  96052. private _samplers;
  96053. private _isReady;
  96054. private _compilationError;
  96055. private _allFallbacksProcessed;
  96056. private _attributesNames;
  96057. private _attributes;
  96058. private _uniforms;
  96059. /**
  96060. * Key for the effect.
  96061. * @hidden
  96062. */
  96063. _key: string;
  96064. private _indexParameters;
  96065. private _fallbacks;
  96066. private _vertexSourceCode;
  96067. private _fragmentSourceCode;
  96068. private _vertexSourceCodeOverride;
  96069. private _fragmentSourceCodeOverride;
  96070. private _transformFeedbackVaryings;
  96071. /**
  96072. * Compiled shader to webGL program.
  96073. * @hidden
  96074. */
  96075. _pipelineContext: Nullable<IPipelineContext>;
  96076. private _valueCache;
  96077. private static _baseCache;
  96078. /**
  96079. * Instantiates an effect.
  96080. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96081. * @param baseName Name of the effect.
  96082. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96083. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96084. * @param samplers List of sampler variables that will be passed to the shader.
  96085. * @param engine Engine to be used to render the effect
  96086. * @param defines Define statements to be added to the shader.
  96087. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96088. * @param onCompiled Callback that will be called when the shader is compiled.
  96089. * @param onError Callback that will be called if an error occurs during shader compilation.
  96090. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96091. */
  96092. 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);
  96093. private _useFinalCode;
  96094. /**
  96095. * Unique key for this effect
  96096. */
  96097. readonly key: string;
  96098. /**
  96099. * If the effect has been compiled and prepared.
  96100. * @returns if the effect is compiled and prepared.
  96101. */
  96102. isReady(): boolean;
  96103. private _isReadyInternal;
  96104. /**
  96105. * The engine the effect was initialized with.
  96106. * @returns the engine.
  96107. */
  96108. getEngine(): Engine;
  96109. /**
  96110. * The pipeline context for this effect
  96111. * @returns the associated pipeline context
  96112. */
  96113. getPipelineContext(): Nullable<IPipelineContext>;
  96114. /**
  96115. * The set of names of attribute variables for the shader.
  96116. * @returns An array of attribute names.
  96117. */
  96118. getAttributesNames(): string[];
  96119. /**
  96120. * Returns the attribute at the given index.
  96121. * @param index The index of the attribute.
  96122. * @returns The location of the attribute.
  96123. */
  96124. getAttributeLocation(index: number): number;
  96125. /**
  96126. * Returns the attribute based on the name of the variable.
  96127. * @param name of the attribute to look up.
  96128. * @returns the attribute location.
  96129. */
  96130. getAttributeLocationByName(name: string): number;
  96131. /**
  96132. * The number of attributes.
  96133. * @returns the numnber of attributes.
  96134. */
  96135. getAttributesCount(): number;
  96136. /**
  96137. * Gets the index of a uniform variable.
  96138. * @param uniformName of the uniform to look up.
  96139. * @returns the index.
  96140. */
  96141. getUniformIndex(uniformName: string): number;
  96142. /**
  96143. * Returns the attribute based on the name of the variable.
  96144. * @param uniformName of the uniform to look up.
  96145. * @returns the location of the uniform.
  96146. */
  96147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96148. /**
  96149. * Returns an array of sampler variable names
  96150. * @returns The array of sampler variable neames.
  96151. */
  96152. getSamplers(): string[];
  96153. /**
  96154. * The error from the last compilation.
  96155. * @returns the error string.
  96156. */
  96157. getCompilationError(): string;
  96158. /**
  96159. * Gets a boolean indicating that all fallbacks were used during compilation
  96160. * @returns true if all fallbacks were used
  96161. */
  96162. allFallbacksProcessed(): boolean;
  96163. /**
  96164. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96165. * @param func The callback to be used.
  96166. */
  96167. executeWhenCompiled(func: (effect: Effect) => void): void;
  96168. private _checkIsReady;
  96169. private _loadShader;
  96170. /**
  96171. * Recompiles the webGL program
  96172. * @param vertexSourceCode The source code for the vertex shader.
  96173. * @param fragmentSourceCode The source code for the fragment shader.
  96174. * @param onCompiled Callback called when completed.
  96175. * @param onError Callback called on error.
  96176. * @hidden
  96177. */
  96178. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96179. /**
  96180. * Prepares the effect
  96181. * @hidden
  96182. */
  96183. _prepareEffect(): void;
  96184. private _processCompilationErrors;
  96185. /**
  96186. * Checks if the effect is supported. (Must be called after compilation)
  96187. */
  96188. readonly isSupported: boolean;
  96189. /**
  96190. * Binds a texture to the engine to be used as output of the shader.
  96191. * @param channel Name of the output variable.
  96192. * @param texture Texture to bind.
  96193. * @hidden
  96194. */
  96195. _bindTexture(channel: string, texture: InternalTexture): void;
  96196. /**
  96197. * Sets a texture on the engine to be used in the shader.
  96198. * @param channel Name of the sampler variable.
  96199. * @param texture Texture to set.
  96200. */
  96201. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96202. /**
  96203. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96204. * @param channel Name of the sampler variable.
  96205. * @param texture Texture to set.
  96206. */
  96207. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96208. /**
  96209. * Sets an array of textures on the engine to be used in the shader.
  96210. * @param channel Name of the variable.
  96211. * @param textures Textures to set.
  96212. */
  96213. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96214. /**
  96215. * 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)
  96216. * @param channel Name of the sampler variable.
  96217. * @param postProcess Post process to get the input texture from.
  96218. */
  96219. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96220. /**
  96221. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96222. * 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)
  96223. * @param channel Name of the sampler variable.
  96224. * @param postProcess Post process to get the output texture from.
  96225. */
  96226. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96227. /** @hidden */
  96228. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96229. /** @hidden */
  96230. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96231. /** @hidden */
  96232. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96233. /** @hidden */
  96234. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96235. /**
  96236. * Binds a buffer to a uniform.
  96237. * @param buffer Buffer to bind.
  96238. * @param name Name of the uniform variable to bind to.
  96239. */
  96240. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96241. /**
  96242. * Binds block to a uniform.
  96243. * @param blockName Name of the block to bind.
  96244. * @param index Index to bind.
  96245. */
  96246. bindUniformBlock(blockName: string, index: number): void;
  96247. /**
  96248. * Sets an interger value on a uniform variable.
  96249. * @param uniformName Name of the variable.
  96250. * @param value Value to be set.
  96251. * @returns this effect.
  96252. */
  96253. setInt(uniformName: string, value: number): Effect;
  96254. /**
  96255. * Sets an int array on a uniform variable.
  96256. * @param uniformName Name of the variable.
  96257. * @param array array to be set.
  96258. * @returns this effect.
  96259. */
  96260. setIntArray(uniformName: string, array: Int32Array): Effect;
  96261. /**
  96262. * 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)
  96263. * @param uniformName Name of the variable.
  96264. * @param array array to be set.
  96265. * @returns this effect.
  96266. */
  96267. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96268. /**
  96269. * 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)
  96270. * @param uniformName Name of the variable.
  96271. * @param array array to be set.
  96272. * @returns this effect.
  96273. */
  96274. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96275. /**
  96276. * 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)
  96277. * @param uniformName Name of the variable.
  96278. * @param array array to be set.
  96279. * @returns this effect.
  96280. */
  96281. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96282. /**
  96283. * Sets an float array on a uniform variable.
  96284. * @param uniformName Name of the variable.
  96285. * @param array array to be set.
  96286. * @returns this effect.
  96287. */
  96288. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96289. /**
  96290. * 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)
  96291. * @param uniformName Name of the variable.
  96292. * @param array array to be set.
  96293. * @returns this effect.
  96294. */
  96295. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96296. /**
  96297. * 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)
  96298. * @param uniformName Name of the variable.
  96299. * @param array array to be set.
  96300. * @returns this effect.
  96301. */
  96302. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96303. /**
  96304. * 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)
  96305. * @param uniformName Name of the variable.
  96306. * @param array array to be set.
  96307. * @returns this effect.
  96308. */
  96309. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96310. /**
  96311. * Sets an array on a uniform variable.
  96312. * @param uniformName Name of the variable.
  96313. * @param array array to be set.
  96314. * @returns this effect.
  96315. */
  96316. setArray(uniformName: string, array: number[]): Effect;
  96317. /**
  96318. * 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)
  96319. * @param uniformName Name of the variable.
  96320. * @param array array to be set.
  96321. * @returns this effect.
  96322. */
  96323. setArray2(uniformName: string, array: number[]): Effect;
  96324. /**
  96325. * 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)
  96326. * @param uniformName Name of the variable.
  96327. * @param array array to be set.
  96328. * @returns this effect.
  96329. */
  96330. setArray3(uniformName: string, array: number[]): Effect;
  96331. /**
  96332. * 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)
  96333. * @param uniformName Name of the variable.
  96334. * @param array array to be set.
  96335. * @returns this effect.
  96336. */
  96337. setArray4(uniformName: string, array: number[]): Effect;
  96338. /**
  96339. * Sets matrices on a uniform variable.
  96340. * @param uniformName Name of the variable.
  96341. * @param matrices matrices to be set.
  96342. * @returns this effect.
  96343. */
  96344. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96345. /**
  96346. * Sets matrix on a uniform variable.
  96347. * @param uniformName Name of the variable.
  96348. * @param matrix matrix to be set.
  96349. * @returns this effect.
  96350. */
  96351. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96352. /**
  96353. * 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)
  96354. * @param uniformName Name of the variable.
  96355. * @param matrix matrix to be set.
  96356. * @returns this effect.
  96357. */
  96358. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96359. /**
  96360. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96361. * @param uniformName Name of the variable.
  96362. * @param matrix matrix to be set.
  96363. * @returns this effect.
  96364. */
  96365. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96366. /**
  96367. * Sets a float on a uniform variable.
  96368. * @param uniformName Name of the variable.
  96369. * @param value value to be set.
  96370. * @returns this effect.
  96371. */
  96372. setFloat(uniformName: string, value: number): Effect;
  96373. /**
  96374. * Sets a boolean on a uniform variable.
  96375. * @param uniformName Name of the variable.
  96376. * @param bool value to be set.
  96377. * @returns this effect.
  96378. */
  96379. setBool(uniformName: string, bool: boolean): Effect;
  96380. /**
  96381. * Sets a Vector2 on a uniform variable.
  96382. * @param uniformName Name of the variable.
  96383. * @param vector2 vector2 to be set.
  96384. * @returns this effect.
  96385. */
  96386. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96387. /**
  96388. * Sets a float2 on a uniform variable.
  96389. * @param uniformName Name of the variable.
  96390. * @param x First float in float2.
  96391. * @param y Second float in float2.
  96392. * @returns this effect.
  96393. */
  96394. setFloat2(uniformName: string, x: number, y: number): Effect;
  96395. /**
  96396. * Sets a Vector3 on a uniform variable.
  96397. * @param uniformName Name of the variable.
  96398. * @param vector3 Value to be set.
  96399. * @returns this effect.
  96400. */
  96401. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96402. /**
  96403. * Sets a float3 on a uniform variable.
  96404. * @param uniformName Name of the variable.
  96405. * @param x First float in float3.
  96406. * @param y Second float in float3.
  96407. * @param z Third float in float3.
  96408. * @returns this effect.
  96409. */
  96410. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96411. /**
  96412. * Sets a Vector4 on a uniform variable.
  96413. * @param uniformName Name of the variable.
  96414. * @param vector4 Value to be set.
  96415. * @returns this effect.
  96416. */
  96417. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96418. /**
  96419. * Sets a float4 on a uniform variable.
  96420. * @param uniformName Name of the variable.
  96421. * @param x First float in float4.
  96422. * @param y Second float in float4.
  96423. * @param z Third float in float4.
  96424. * @param w Fourth float in float4.
  96425. * @returns this effect.
  96426. */
  96427. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96428. /**
  96429. * Sets a Color3 on a uniform variable.
  96430. * @param uniformName Name of the variable.
  96431. * @param color3 Value to be set.
  96432. * @returns this effect.
  96433. */
  96434. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96435. /**
  96436. * Sets a Color4 on a uniform variable.
  96437. * @param uniformName Name of the variable.
  96438. * @param color3 Value to be set.
  96439. * @param alpha Alpha value to be set.
  96440. * @returns this effect.
  96441. */
  96442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96443. /**
  96444. * Sets a Color4 on a uniform variable
  96445. * @param uniformName defines the name of the variable
  96446. * @param color4 defines the value to be set
  96447. * @returns this effect.
  96448. */
  96449. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96450. /** Release all associated resources */
  96451. dispose(): void;
  96452. /**
  96453. * This function will add a new shader to the shader store
  96454. * @param name the name of the shader
  96455. * @param pixelShader optional pixel shader content
  96456. * @param vertexShader optional vertex shader content
  96457. */
  96458. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96459. /**
  96460. * Store of each shader (The can be looked up using effect.key)
  96461. */
  96462. static ShadersStore: {
  96463. [key: string]: string;
  96464. };
  96465. /**
  96466. * Store of each included file for a shader (The can be looked up using effect.key)
  96467. */
  96468. static IncludesShadersStore: {
  96469. [key: string]: string;
  96470. };
  96471. /**
  96472. * Resets the cache of effects.
  96473. */
  96474. static ResetCache(): void;
  96475. }
  96476. }
  96477. declare module BABYLON {
  96478. /**
  96479. * Interface used to describe the capabilities of the engine relatively to the current browser
  96480. */
  96481. export interface EngineCapabilities {
  96482. /** Maximum textures units per fragment shader */
  96483. maxTexturesImageUnits: number;
  96484. /** Maximum texture units per vertex shader */
  96485. maxVertexTextureImageUnits: number;
  96486. /** Maximum textures units in the entire pipeline */
  96487. maxCombinedTexturesImageUnits: number;
  96488. /** Maximum texture size */
  96489. maxTextureSize: number;
  96490. /** Maximum cube texture size */
  96491. maxCubemapTextureSize: number;
  96492. /** Maximum render texture size */
  96493. maxRenderTextureSize: number;
  96494. /** Maximum number of vertex attributes */
  96495. maxVertexAttribs: number;
  96496. /** Maximum number of varyings */
  96497. maxVaryingVectors: number;
  96498. /** Maximum number of uniforms per vertex shader */
  96499. maxVertexUniformVectors: number;
  96500. /** Maximum number of uniforms per fragment shader */
  96501. maxFragmentUniformVectors: number;
  96502. /** Defines if standard derivates (dx/dy) are supported */
  96503. standardDerivatives: boolean;
  96504. /** Defines if s3tc texture compression is supported */
  96505. s3tc?: WEBGL_compressed_texture_s3tc;
  96506. /** Defines if pvrtc texture compression is supported */
  96507. pvrtc: any;
  96508. /** Defines if etc1 texture compression is supported */
  96509. etc1: any;
  96510. /** Defines if etc2 texture compression is supported */
  96511. etc2: any;
  96512. /** Defines if astc texture compression is supported */
  96513. astc: any;
  96514. /** Defines if float textures are supported */
  96515. textureFloat: boolean;
  96516. /** Defines if vertex array objects are supported */
  96517. vertexArrayObject: boolean;
  96518. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96519. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96520. /** Gets the maximum level of anisotropy supported */
  96521. maxAnisotropy: number;
  96522. /** Defines if instancing is supported */
  96523. instancedArrays: boolean;
  96524. /** Defines if 32 bits indices are supported */
  96525. uintIndices: boolean;
  96526. /** Defines if high precision shaders are supported */
  96527. highPrecisionShaderSupported: boolean;
  96528. /** Defines if depth reading in the fragment shader is supported */
  96529. fragmentDepthSupported: boolean;
  96530. /** Defines if float texture linear filtering is supported*/
  96531. textureFloatLinearFiltering: boolean;
  96532. /** Defines if rendering to float textures is supported */
  96533. textureFloatRender: boolean;
  96534. /** Defines if half float textures are supported*/
  96535. textureHalfFloat: boolean;
  96536. /** Defines if half float texture linear filtering is supported*/
  96537. textureHalfFloatLinearFiltering: boolean;
  96538. /** Defines if rendering to half float textures is supported */
  96539. textureHalfFloatRender: boolean;
  96540. /** Defines if textureLOD shader command is supported */
  96541. textureLOD: boolean;
  96542. /** Defines if draw buffers extension is supported */
  96543. drawBuffersExtension: boolean;
  96544. /** Defines if depth textures are supported */
  96545. depthTextureExtension: boolean;
  96546. /** Defines if float color buffer are supported */
  96547. colorBufferFloat: boolean;
  96548. /** Gets disjoint timer query extension (null if not supported) */
  96549. timerQuery?: EXT_disjoint_timer_query;
  96550. /** Defines if timestamp can be used with timer query */
  96551. canUseTimestampForTimerQuery: boolean;
  96552. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96553. multiview?: any;
  96554. /** Function used to let the system compiles shaders in background */
  96555. parallelShaderCompile?: {
  96556. COMPLETION_STATUS_KHR: number;
  96557. };
  96558. /** Max number of texture samples for MSAA */
  96559. maxMSAASamples: number;
  96560. /** Defines if the blend min max extension is supported */
  96561. blendMinMax: boolean;
  96562. }
  96563. }
  96564. declare module BABYLON {
  96565. /**
  96566. * @hidden
  96567. **/
  96568. export class DepthCullingState {
  96569. private _isDepthTestDirty;
  96570. private _isDepthMaskDirty;
  96571. private _isDepthFuncDirty;
  96572. private _isCullFaceDirty;
  96573. private _isCullDirty;
  96574. private _isZOffsetDirty;
  96575. private _isFrontFaceDirty;
  96576. private _depthTest;
  96577. private _depthMask;
  96578. private _depthFunc;
  96579. private _cull;
  96580. private _cullFace;
  96581. private _zOffset;
  96582. private _frontFace;
  96583. /**
  96584. * Initializes the state.
  96585. */
  96586. constructor();
  96587. readonly isDirty: boolean;
  96588. zOffset: number;
  96589. cullFace: Nullable<number>;
  96590. cull: Nullable<boolean>;
  96591. depthFunc: Nullable<number>;
  96592. depthMask: boolean;
  96593. depthTest: boolean;
  96594. frontFace: Nullable<number>;
  96595. reset(): void;
  96596. apply(gl: WebGLRenderingContext): void;
  96597. }
  96598. }
  96599. declare module BABYLON {
  96600. /**
  96601. * @hidden
  96602. **/
  96603. export class StencilState {
  96604. /** 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 */
  96605. static readonly ALWAYS: number;
  96606. /** Passed to stencilOperation to specify that stencil value must be kept */
  96607. static readonly KEEP: number;
  96608. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96609. static readonly REPLACE: number;
  96610. private _isStencilTestDirty;
  96611. private _isStencilMaskDirty;
  96612. private _isStencilFuncDirty;
  96613. private _isStencilOpDirty;
  96614. private _stencilTest;
  96615. private _stencilMask;
  96616. private _stencilFunc;
  96617. private _stencilFuncRef;
  96618. private _stencilFuncMask;
  96619. private _stencilOpStencilFail;
  96620. private _stencilOpDepthFail;
  96621. private _stencilOpStencilDepthPass;
  96622. readonly isDirty: boolean;
  96623. stencilFunc: number;
  96624. stencilFuncRef: number;
  96625. stencilFuncMask: number;
  96626. stencilOpStencilFail: number;
  96627. stencilOpDepthFail: number;
  96628. stencilOpStencilDepthPass: number;
  96629. stencilMask: number;
  96630. stencilTest: boolean;
  96631. constructor();
  96632. reset(): void;
  96633. apply(gl: WebGLRenderingContext): void;
  96634. }
  96635. }
  96636. declare module BABYLON {
  96637. /**
  96638. * @hidden
  96639. **/
  96640. export class AlphaState {
  96641. private _isAlphaBlendDirty;
  96642. private _isBlendFunctionParametersDirty;
  96643. private _isBlendEquationParametersDirty;
  96644. private _isBlendConstantsDirty;
  96645. private _alphaBlend;
  96646. private _blendFunctionParameters;
  96647. private _blendEquationParameters;
  96648. private _blendConstants;
  96649. /**
  96650. * Initializes the state.
  96651. */
  96652. constructor();
  96653. readonly isDirty: boolean;
  96654. alphaBlend: boolean;
  96655. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96656. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96657. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96658. reset(): void;
  96659. apply(gl: WebGLRenderingContext): void;
  96660. }
  96661. }
  96662. declare module BABYLON {
  96663. /** @hidden */
  96664. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96665. attributeProcessor(attribute: string): string;
  96666. varyingProcessor(varying: string, isFragment: boolean): string;
  96667. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96668. }
  96669. }
  96670. declare module BABYLON {
  96671. /**
  96672. * Interface for attribute information associated with buffer instanciation
  96673. */
  96674. export interface InstancingAttributeInfo {
  96675. /**
  96676. * Index/offset of the attribute in the vertex shader
  96677. */
  96678. index: number;
  96679. /**
  96680. * size of the attribute, 1, 2, 3 or 4
  96681. */
  96682. attributeSize: number;
  96683. /**
  96684. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96685. * default is FLOAT
  96686. */
  96687. attributeType: number;
  96688. /**
  96689. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96690. */
  96691. normalized: boolean;
  96692. /**
  96693. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96694. */
  96695. offset: number;
  96696. /**
  96697. * Name of the GLSL attribute, for debugging purpose only
  96698. */
  96699. attributeName: string;
  96700. }
  96701. }
  96702. declare module BABYLON {
  96703. interface ThinEngine {
  96704. /**
  96705. * Update a video texture
  96706. * @param texture defines the texture to update
  96707. * @param video defines the video element to use
  96708. * @param invertY defines if data must be stored with Y axis inverted
  96709. */
  96710. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96711. }
  96712. }
  96713. declare module BABYLON {
  96714. /**
  96715. * Settings for finer control over video usage
  96716. */
  96717. export interface VideoTextureSettings {
  96718. /**
  96719. * Applies `autoplay` to video, if specified
  96720. */
  96721. autoPlay?: boolean;
  96722. /**
  96723. * Applies `loop` to video, if specified
  96724. */
  96725. loop?: boolean;
  96726. /**
  96727. * Automatically updates internal texture from video at every frame in the render loop
  96728. */
  96729. autoUpdateTexture: boolean;
  96730. /**
  96731. * Image src displayed during the video loading or until the user interacts with the video.
  96732. */
  96733. poster?: string;
  96734. }
  96735. /**
  96736. * If you want to display a video in your scene, this is the special texture for that.
  96737. * This special texture works similar to other textures, with the exception of a few parameters.
  96738. * @see https://doc.babylonjs.com/how_to/video_texture
  96739. */
  96740. export class VideoTexture extends Texture {
  96741. /**
  96742. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96743. */
  96744. readonly autoUpdateTexture: boolean;
  96745. /**
  96746. * The video instance used by the texture internally
  96747. */
  96748. readonly video: HTMLVideoElement;
  96749. private _onUserActionRequestedObservable;
  96750. /**
  96751. * Event triggerd when a dom action is required by the user to play the video.
  96752. * This happens due to recent changes in browser policies preventing video to auto start.
  96753. */
  96754. readonly onUserActionRequestedObservable: Observable<Texture>;
  96755. private _generateMipMaps;
  96756. private _engine;
  96757. private _stillImageCaptured;
  96758. private _displayingPosterTexture;
  96759. private _settings;
  96760. private _createInternalTextureOnEvent;
  96761. private _frameId;
  96762. /**
  96763. * Creates a video texture.
  96764. * If you want to display a video in your scene, this is the special texture for that.
  96765. * This special texture works similar to other textures, with the exception of a few parameters.
  96766. * @see https://doc.babylonjs.com/how_to/video_texture
  96767. * @param name optional name, will detect from video source, if not defined
  96768. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96769. * @param scene is obviously the current scene.
  96770. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96771. * @param invertY is false by default but can be used to invert video on Y axis
  96772. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96773. * @param settings allows finer control over video usage
  96774. */
  96775. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96776. private _getName;
  96777. private _getVideo;
  96778. private _createInternalTexture;
  96779. private reset;
  96780. /**
  96781. * @hidden Internal method to initiate `update`.
  96782. */
  96783. _rebuild(): void;
  96784. /**
  96785. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96786. */
  96787. update(): void;
  96788. /**
  96789. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96790. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96791. */
  96792. updateTexture(isVisible: boolean): void;
  96793. protected _updateInternalTexture: () => void;
  96794. /**
  96795. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96796. * @param url New url.
  96797. */
  96798. updateURL(url: string): void;
  96799. /**
  96800. * Dispose the texture and release its associated resources.
  96801. */
  96802. dispose(): void;
  96803. /**
  96804. * Creates a video texture straight from a stream.
  96805. * @param scene Define the scene the texture should be created in
  96806. * @param stream Define the stream the texture should be created from
  96807. * @returns The created video texture as a promise
  96808. */
  96809. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96810. /**
  96811. * Creates a video texture straight from your WebCam video feed.
  96812. * @param scene Define the scene the texture should be created in
  96813. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96814. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96815. * @returns The created video texture as a promise
  96816. */
  96817. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96818. minWidth: number;
  96819. maxWidth: number;
  96820. minHeight: number;
  96821. maxHeight: number;
  96822. deviceId: string;
  96823. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96824. /**
  96825. * Creates a video texture straight from your WebCam video feed.
  96826. * @param scene Define the scene the texture should be created in
  96827. * @param onReady Define a callback to triggered once the texture will be ready
  96828. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96829. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96830. */
  96831. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96832. minWidth: number;
  96833. maxWidth: number;
  96834. minHeight: number;
  96835. maxHeight: number;
  96836. deviceId: string;
  96837. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96838. }
  96839. }
  96840. declare module BABYLON {
  96841. /**
  96842. * Defines the interface used by objects working like Scene
  96843. * @hidden
  96844. */
  96845. interface ISceneLike {
  96846. _addPendingData(data: any): void;
  96847. _removePendingData(data: any): void;
  96848. offlineProvider: IOfflineProvider;
  96849. }
  96850. /** Interface defining initialization parameters for Engine class */
  96851. export interface EngineOptions extends WebGLContextAttributes {
  96852. /**
  96853. * Defines if the engine should no exceed a specified device ratio
  96854. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96855. */
  96856. limitDeviceRatio?: number;
  96857. /**
  96858. * Defines if webvr should be enabled automatically
  96859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96860. */
  96861. autoEnableWebVR?: boolean;
  96862. /**
  96863. * Defines if webgl2 should be turned off even if supported
  96864. * @see http://doc.babylonjs.com/features/webgl2
  96865. */
  96866. disableWebGL2Support?: boolean;
  96867. /**
  96868. * Defines if webaudio should be initialized as well
  96869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96870. */
  96871. audioEngine?: boolean;
  96872. /**
  96873. * Defines if animations should run using a deterministic lock step
  96874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96875. */
  96876. deterministicLockstep?: boolean;
  96877. /** Defines the maximum steps to use with deterministic lock step mode */
  96878. lockstepMaxSteps?: number;
  96879. /**
  96880. * Defines that engine should ignore context lost events
  96881. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96882. */
  96883. doNotHandleContextLost?: boolean;
  96884. /**
  96885. * Defines that engine should ignore modifying touch action attribute and style
  96886. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96887. */
  96888. doNotHandleTouchAction?: boolean;
  96889. /**
  96890. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96891. */
  96892. useHighPrecisionFloats?: boolean;
  96893. }
  96894. /**
  96895. * The base engine class (root of all engines)
  96896. */
  96897. export class ThinEngine {
  96898. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96899. static ExceptionList: ({
  96900. key: string;
  96901. capture: string;
  96902. captureConstraint: number;
  96903. targets: string[];
  96904. } | {
  96905. key: string;
  96906. capture: null;
  96907. captureConstraint: null;
  96908. targets: string[];
  96909. })[];
  96910. /** @hidden */
  96911. static _TextureLoaders: IInternalTextureLoader[];
  96912. /**
  96913. * Returns the current npm package of the sdk
  96914. */
  96915. static readonly NpmPackage: string;
  96916. /**
  96917. * Returns the current version of the framework
  96918. */
  96919. static readonly Version: string;
  96920. /**
  96921. * Returns a string describing the current engine
  96922. */
  96923. readonly description: string;
  96924. /**
  96925. * Gets or sets the epsilon value used by collision engine
  96926. */
  96927. static CollisionsEpsilon: number;
  96928. /**
  96929. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96930. */
  96931. static ShadersRepository: string;
  96932. /** @hidden */
  96933. _shaderProcessor: IShaderProcessor;
  96934. /**
  96935. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96936. */
  96937. forcePOTTextures: boolean;
  96938. /**
  96939. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96940. */
  96941. isFullscreen: boolean;
  96942. /**
  96943. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96944. */
  96945. cullBackFaces: boolean;
  96946. /**
  96947. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96948. */
  96949. renderEvenInBackground: boolean;
  96950. /**
  96951. * Gets or sets a boolean indicating that cache can be kept between frames
  96952. */
  96953. preventCacheWipeBetweenFrames: boolean;
  96954. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96955. validateShaderPrograms: boolean;
  96956. /**
  96957. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96958. */
  96959. disableUniformBuffers: boolean;
  96960. /** @hidden */
  96961. _uniformBuffers: UniformBuffer[];
  96962. /**
  96963. * Gets a boolean indicating that the engine supports uniform buffers
  96964. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96965. */
  96966. readonly supportsUniformBuffers: boolean;
  96967. /** @hidden */
  96968. _gl: WebGLRenderingContext;
  96969. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96970. protected _windowIsBackground: boolean;
  96971. protected _webGLVersion: number;
  96972. protected _creationOptions: EngineOptions;
  96973. protected _highPrecisionShadersAllowed: boolean;
  96974. /** @hidden */
  96975. readonly _shouldUseHighPrecisionShader: boolean;
  96976. /**
  96977. * Gets a boolean indicating that only power of 2 textures are supported
  96978. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96979. */
  96980. readonly needPOTTextures: boolean;
  96981. /** @hidden */
  96982. _badOS: boolean;
  96983. /** @hidden */
  96984. _badDesktopOS: boolean;
  96985. private _hardwareScalingLevel;
  96986. /** @hidden */
  96987. _caps: EngineCapabilities;
  96988. private _isStencilEnable;
  96989. protected _colorWrite: boolean;
  96990. private _glVersion;
  96991. private _glRenderer;
  96992. private _glVendor;
  96993. /** @hidden */
  96994. _videoTextureSupported: boolean;
  96995. protected _renderingQueueLaunched: boolean;
  96996. protected _activeRenderLoops: (() => void)[];
  96997. /**
  96998. * Observable signaled when a context lost event is raised
  96999. */
  97000. onContextLostObservable: Observable<ThinEngine>;
  97001. /**
  97002. * Observable signaled when a context restored event is raised
  97003. */
  97004. onContextRestoredObservable: Observable<ThinEngine>;
  97005. private _onContextLost;
  97006. private _onContextRestored;
  97007. protected _contextWasLost: boolean;
  97008. /** @hidden */
  97009. _doNotHandleContextLost: boolean;
  97010. /**
  97011. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97013. */
  97014. doNotHandleContextLost: boolean;
  97015. /**
  97016. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97017. */
  97018. disableVertexArrayObjects: boolean;
  97019. /** @hidden */
  97020. protected _depthCullingState: DepthCullingState;
  97021. /** @hidden */
  97022. protected _stencilState: StencilState;
  97023. /** @hidden */
  97024. protected _alphaState: AlphaState;
  97025. /** @hidden */
  97026. _internalTexturesCache: InternalTexture[];
  97027. /** @hidden */
  97028. protected _activeChannel: number;
  97029. private _currentTextureChannel;
  97030. /** @hidden */
  97031. protected _boundTexturesCache: {
  97032. [key: string]: Nullable<InternalTexture>;
  97033. };
  97034. /** @hidden */
  97035. protected _currentEffect: Nullable<Effect>;
  97036. /** @hidden */
  97037. protected _currentProgram: Nullable<WebGLProgram>;
  97038. private _compiledEffects;
  97039. private _vertexAttribArraysEnabled;
  97040. /** @hidden */
  97041. protected _cachedViewport: Nullable<IViewportLike>;
  97042. private _cachedVertexArrayObject;
  97043. /** @hidden */
  97044. protected _cachedVertexBuffers: any;
  97045. /** @hidden */
  97046. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97047. /** @hidden */
  97048. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97049. /** @hidden */
  97050. _currentRenderTarget: Nullable<InternalTexture>;
  97051. private _uintIndicesCurrentlySet;
  97052. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97053. /** @hidden */
  97054. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97055. private _currentBufferPointers;
  97056. private _currentInstanceLocations;
  97057. private _currentInstanceBuffers;
  97058. private _textureUnits;
  97059. /** @hidden */
  97060. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97061. /** @hidden */
  97062. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97063. /** @hidden */
  97064. _boundRenderFunction: any;
  97065. private _vaoRecordInProgress;
  97066. private _mustWipeVertexAttributes;
  97067. private _emptyTexture;
  97068. private _emptyCubeTexture;
  97069. private _emptyTexture3D;
  97070. /** @hidden */
  97071. _frameHandler: number;
  97072. private _nextFreeTextureSlots;
  97073. private _maxSimultaneousTextures;
  97074. private _activeRequests;
  97075. protected _texturesSupported: string[];
  97076. /** @hidden */
  97077. _textureFormatInUse: Nullable<string>;
  97078. protected readonly _supportsHardwareTextureRescaling: boolean;
  97079. /**
  97080. * Gets the list of texture formats supported
  97081. */
  97082. readonly texturesSupported: Array<string>;
  97083. /**
  97084. * Gets the list of texture formats in use
  97085. */
  97086. readonly textureFormatInUse: Nullable<string>;
  97087. /**
  97088. * Gets the current viewport
  97089. */
  97090. readonly currentViewport: Nullable<IViewportLike>;
  97091. /**
  97092. * Gets the default empty texture
  97093. */
  97094. readonly emptyTexture: InternalTexture;
  97095. /**
  97096. * Gets the default empty 3D texture
  97097. */
  97098. readonly emptyTexture3D: InternalTexture;
  97099. /**
  97100. * Gets the default empty cube texture
  97101. */
  97102. readonly emptyCubeTexture: InternalTexture;
  97103. /**
  97104. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97105. */
  97106. readonly premultipliedAlpha: boolean;
  97107. /**
  97108. * Observable event triggered before each texture is initialized
  97109. */
  97110. onBeforeTextureInitObservable: Observable<Texture>;
  97111. /**
  97112. * Creates a new engine
  97113. * @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
  97114. * @param antialias defines enable antialiasing (default: false)
  97115. * @param options defines further options to be sent to the getContext() function
  97116. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97117. */
  97118. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97119. private _rebuildInternalTextures;
  97120. private _rebuildEffects;
  97121. /**
  97122. * Gets a boolean indicating if all created effects are ready
  97123. * @returns true if all effects are ready
  97124. */
  97125. areAllEffectsReady(): boolean;
  97126. protected _rebuildBuffers(): void;
  97127. private _initGLContext;
  97128. /**
  97129. * Gets version of the current webGL context
  97130. */
  97131. readonly webGLVersion: number;
  97132. /**
  97133. * Gets a string idenfifying the name of the class
  97134. * @returns "Engine" string
  97135. */
  97136. getClassName(): string;
  97137. /**
  97138. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97139. */
  97140. readonly isStencilEnable: boolean;
  97141. /** @hidden */
  97142. _prepareWorkingCanvas(): void;
  97143. /**
  97144. * Reset the texture cache to empty state
  97145. */
  97146. resetTextureCache(): void;
  97147. /**
  97148. * Gets an object containing information about the current webGL context
  97149. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97150. */
  97151. getGlInfo(): {
  97152. vendor: string;
  97153. renderer: string;
  97154. version: string;
  97155. };
  97156. /**
  97157. * Defines the hardware scaling level.
  97158. * By default the hardware scaling level is computed from the window device ratio.
  97159. * 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.
  97160. * @param level defines the level to use
  97161. */
  97162. setHardwareScalingLevel(level: number): void;
  97163. /**
  97164. * Gets the current hardware scaling level.
  97165. * By default the hardware scaling level is computed from the window device ratio.
  97166. * 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.
  97167. * @returns a number indicating the current hardware scaling level
  97168. */
  97169. getHardwareScalingLevel(): number;
  97170. /**
  97171. * Gets the list of loaded textures
  97172. * @returns an array containing all loaded textures
  97173. */
  97174. getLoadedTexturesCache(): InternalTexture[];
  97175. /**
  97176. * Gets the object containing all engine capabilities
  97177. * @returns the EngineCapabilities object
  97178. */
  97179. getCaps(): EngineCapabilities;
  97180. /**
  97181. * stop executing a render loop function and remove it from the execution array
  97182. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97183. */
  97184. stopRenderLoop(renderFunction?: () => void): void;
  97185. /** @hidden */
  97186. _renderLoop(): void;
  97187. /**
  97188. * Gets the HTML canvas attached with the current webGL context
  97189. * @returns a HTML canvas
  97190. */
  97191. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97192. /**
  97193. * Gets host window
  97194. * @returns the host window object
  97195. */
  97196. getHostWindow(): Nullable<Window>;
  97197. /**
  97198. * Gets the current render width
  97199. * @param useScreen defines if screen size must be used (or the current render target if any)
  97200. * @returns a number defining the current render width
  97201. */
  97202. getRenderWidth(useScreen?: boolean): number;
  97203. /**
  97204. * Gets the current render height
  97205. * @param useScreen defines if screen size must be used (or the current render target if any)
  97206. * @returns a number defining the current render height
  97207. */
  97208. getRenderHeight(useScreen?: boolean): number;
  97209. /**
  97210. * Can be used to override the current requestAnimationFrame requester.
  97211. * @hidden
  97212. */
  97213. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97214. /**
  97215. * Register and execute a render loop. The engine can have more than one render function
  97216. * @param renderFunction defines the function to continuously execute
  97217. */
  97218. runRenderLoop(renderFunction: () => void): void;
  97219. /**
  97220. * Clear the current render buffer or the current render target (if any is set up)
  97221. * @param color defines the color to use
  97222. * @param backBuffer defines if the back buffer must be cleared
  97223. * @param depth defines if the depth buffer must be cleared
  97224. * @param stencil defines if the stencil buffer must be cleared
  97225. */
  97226. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97227. private _viewportCached;
  97228. /** @hidden */
  97229. _viewport(x: number, y: number, width: number, height: number): void;
  97230. /**
  97231. * Set the WebGL's viewport
  97232. * @param viewport defines the viewport element to be used
  97233. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97234. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97235. */
  97236. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97237. /**
  97238. * Begin a new frame
  97239. */
  97240. beginFrame(): void;
  97241. /**
  97242. * Enf the current frame
  97243. */
  97244. endFrame(): void;
  97245. /**
  97246. * Resize the view according to the canvas' size
  97247. */
  97248. resize(): void;
  97249. /**
  97250. * Force a specific size of the canvas
  97251. * @param width defines the new canvas' width
  97252. * @param height defines the new canvas' height
  97253. */
  97254. setSize(width: number, height: number): void;
  97255. /**
  97256. * Binds the frame buffer to the specified texture.
  97257. * @param texture The texture to render to or null for the default canvas
  97258. * @param faceIndex The face of the texture to render to in case of cube texture
  97259. * @param requiredWidth The width of the target to render to
  97260. * @param requiredHeight The height of the target to render to
  97261. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97262. * @param depthStencilTexture The depth stencil texture to use to render
  97263. * @param lodLevel defines le lod level to bind to the frame buffer
  97264. */
  97265. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97266. /** @hidden */
  97267. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97268. /**
  97269. * Unbind the current render target texture from the webGL context
  97270. * @param texture defines the render target texture to unbind
  97271. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97272. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97273. */
  97274. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97275. /**
  97276. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97277. */
  97278. flushFramebuffer(): void;
  97279. /**
  97280. * Unbind the current render target and bind the default framebuffer
  97281. */
  97282. restoreDefaultFramebuffer(): void;
  97283. /** @hidden */
  97284. protected _resetVertexBufferBinding(): void;
  97285. /**
  97286. * Creates a vertex buffer
  97287. * @param data the data for the vertex buffer
  97288. * @returns the new WebGL static buffer
  97289. */
  97290. createVertexBuffer(data: DataArray): DataBuffer;
  97291. private _createVertexBuffer;
  97292. /**
  97293. * Creates a dynamic vertex buffer
  97294. * @param data the data for the dynamic vertex buffer
  97295. * @returns the new WebGL dynamic buffer
  97296. */
  97297. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97298. protected _resetIndexBufferBinding(): void;
  97299. /**
  97300. * Creates a new index buffer
  97301. * @param indices defines the content of the index buffer
  97302. * @param updatable defines if the index buffer must be updatable
  97303. * @returns a new webGL buffer
  97304. */
  97305. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97306. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97307. /**
  97308. * Bind a webGL buffer to the webGL context
  97309. * @param buffer defines the buffer to bind
  97310. */
  97311. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97312. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97313. private bindBuffer;
  97314. /**
  97315. * update the bound buffer with the given data
  97316. * @param data defines the data to update
  97317. */
  97318. updateArrayBuffer(data: Float32Array): void;
  97319. private _vertexAttribPointer;
  97320. private _bindIndexBufferWithCache;
  97321. private _bindVertexBuffersAttributes;
  97322. /**
  97323. * Records a vertex array object
  97324. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97325. * @param vertexBuffers defines the list of vertex buffers to store
  97326. * @param indexBuffer defines the index buffer to store
  97327. * @param effect defines the effect to store
  97328. * @returns the new vertex array object
  97329. */
  97330. recordVertexArrayObject(vertexBuffers: {
  97331. [key: string]: VertexBuffer;
  97332. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97333. /**
  97334. * Bind a specific vertex array object
  97335. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97336. * @param vertexArrayObject defines the vertex array object to bind
  97337. * @param indexBuffer defines the index buffer to bind
  97338. */
  97339. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97340. /**
  97341. * Bind webGl buffers directly to the webGL context
  97342. * @param vertexBuffer defines the vertex buffer to bind
  97343. * @param indexBuffer defines the index buffer to bind
  97344. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97345. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97346. * @param effect defines the effect associated with the vertex buffer
  97347. */
  97348. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97349. private _unbindVertexArrayObject;
  97350. /**
  97351. * Bind a list of vertex buffers to the webGL context
  97352. * @param vertexBuffers defines the list of vertex buffers to bind
  97353. * @param indexBuffer defines the index buffer to bind
  97354. * @param effect defines the effect associated with the vertex buffers
  97355. */
  97356. bindBuffers(vertexBuffers: {
  97357. [key: string]: Nullable<VertexBuffer>;
  97358. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97359. /**
  97360. * Unbind all instance attributes
  97361. */
  97362. unbindInstanceAttributes(): void;
  97363. /**
  97364. * Release and free the memory of a vertex array object
  97365. * @param vao defines the vertex array object to delete
  97366. */
  97367. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97368. /** @hidden */
  97369. _releaseBuffer(buffer: DataBuffer): boolean;
  97370. protected _deleteBuffer(buffer: DataBuffer): void;
  97371. /**
  97372. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97373. * @param instancesBuffer defines the webGL buffer to update and bind
  97374. * @param data defines the data to store in the buffer
  97375. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97376. */
  97377. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97378. /**
  97379. * Apply all cached states (depth, culling, stencil and alpha)
  97380. */
  97381. applyStates(): void;
  97382. /**
  97383. * Send a draw order
  97384. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97385. * @param indexStart defines the starting index
  97386. * @param indexCount defines the number of index to draw
  97387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97388. */
  97389. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97390. /**
  97391. * Draw a list of points
  97392. * @param verticesStart defines the index of first vertex to draw
  97393. * @param verticesCount defines the count of vertices to draw
  97394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97395. */
  97396. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97397. /**
  97398. * Draw a list of unindexed primitives
  97399. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97400. * @param verticesStart defines the index of first vertex to draw
  97401. * @param verticesCount defines the count of vertices to draw
  97402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97403. */
  97404. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97405. /**
  97406. * Draw a list of indexed primitives
  97407. * @param fillMode defines the primitive to use
  97408. * @param indexStart defines the starting index
  97409. * @param indexCount defines the number of index to draw
  97410. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97411. */
  97412. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97413. /**
  97414. * Draw a list of unindexed primitives
  97415. * @param fillMode defines the primitive to use
  97416. * @param verticesStart defines the index of first vertex to draw
  97417. * @param verticesCount defines the count of vertices to draw
  97418. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97419. */
  97420. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97421. private _drawMode;
  97422. /** @hidden */
  97423. protected _reportDrawCall(): void;
  97424. /** @hidden */
  97425. _releaseEffect(effect: Effect): void;
  97426. /** @hidden */
  97427. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97428. /**
  97429. * Create a new effect (used to store vertex/fragment shaders)
  97430. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97431. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97432. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97433. * @param samplers defines an array of string used to represent textures
  97434. * @param defines defines the string containing the defines to use to compile the shaders
  97435. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97436. * @param onCompiled defines a function to call when the effect creation is successful
  97437. * @param onError defines a function to call when the effect creation has failed
  97438. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97439. * @returns the new Effect
  97440. */
  97441. 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;
  97442. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97443. private _compileShader;
  97444. private _compileRawShader;
  97445. /**
  97446. * Directly creates a webGL program
  97447. * @param pipelineContext defines the pipeline context to attach to
  97448. * @param vertexCode defines the vertex shader code to use
  97449. * @param fragmentCode defines the fragment shader code to use
  97450. * @param context defines the webGL context to use (if not set, the current one will be used)
  97451. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97452. * @returns the new webGL program
  97453. */
  97454. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97455. /**
  97456. * Creates a webGL program
  97457. * @param pipelineContext defines the pipeline context to attach to
  97458. * @param vertexCode defines the vertex shader code to use
  97459. * @param fragmentCode defines the fragment shader code to use
  97460. * @param defines defines the string containing the defines to use to compile the shaders
  97461. * @param context defines the webGL context to use (if not set, the current one will be used)
  97462. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97463. * @returns the new webGL program
  97464. */
  97465. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97466. /**
  97467. * Creates a new pipeline context
  97468. * @returns the new pipeline
  97469. */
  97470. createPipelineContext(): IPipelineContext;
  97471. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97472. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97473. /** @hidden */
  97474. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97475. /** @hidden */
  97476. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97477. /** @hidden */
  97478. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97479. /**
  97480. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97481. * @param pipelineContext defines the pipeline context to use
  97482. * @param uniformsNames defines the list of uniform names
  97483. * @returns an array of webGL uniform locations
  97484. */
  97485. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97486. /**
  97487. * Gets the lsit of active attributes for a given webGL program
  97488. * @param pipelineContext defines the pipeline context to use
  97489. * @param attributesNames defines the list of attribute names to get
  97490. * @returns an array of indices indicating the offset of each attribute
  97491. */
  97492. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97493. /**
  97494. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97495. * @param effect defines the effect to activate
  97496. */
  97497. enableEffect(effect: Nullable<Effect>): void;
  97498. /**
  97499. * Set the value of an uniform to a number (int)
  97500. * @param uniform defines the webGL uniform location where to store the value
  97501. * @param value defines the int number to store
  97502. */
  97503. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97504. /**
  97505. * Set the value of an uniform to an array of int32
  97506. * @param uniform defines the webGL uniform location where to store the value
  97507. * @param array defines the array of int32 to store
  97508. */
  97509. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97510. /**
  97511. * Set the value of an uniform to an array of int32 (stored as vec2)
  97512. * @param uniform defines the webGL uniform location where to store the value
  97513. * @param array defines the array of int32 to store
  97514. */
  97515. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97516. /**
  97517. * Set the value of an uniform to an array of int32 (stored as vec3)
  97518. * @param uniform defines the webGL uniform location where to store the value
  97519. * @param array defines the array of int32 to store
  97520. */
  97521. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97522. /**
  97523. * Set the value of an uniform to an array of int32 (stored as vec4)
  97524. * @param uniform defines the webGL uniform location where to store the value
  97525. * @param array defines the array of int32 to store
  97526. */
  97527. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97528. /**
  97529. * Set the value of an uniform to an array of number
  97530. * @param uniform defines the webGL uniform location where to store the value
  97531. * @param array defines the array of number to store
  97532. */
  97533. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97534. /**
  97535. * Set the value of an uniform to an array of number (stored as vec2)
  97536. * @param uniform defines the webGL uniform location where to store the value
  97537. * @param array defines the array of number to store
  97538. */
  97539. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97540. /**
  97541. * Set the value of an uniform to an array of number (stored as vec3)
  97542. * @param uniform defines the webGL uniform location where to store the value
  97543. * @param array defines the array of number to store
  97544. */
  97545. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97546. /**
  97547. * Set the value of an uniform to an array of number (stored as vec4)
  97548. * @param uniform defines the webGL uniform location where to store the value
  97549. * @param array defines the array of number to store
  97550. */
  97551. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97552. /**
  97553. * Set the value of an uniform to an array of float32 (stored as matrices)
  97554. * @param uniform defines the webGL uniform location where to store the value
  97555. * @param matrices defines the array of float32 to store
  97556. */
  97557. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97558. /**
  97559. * Set the value of an uniform to a matrix (3x3)
  97560. * @param uniform defines the webGL uniform location where to store the value
  97561. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97562. */
  97563. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97564. /**
  97565. * Set the value of an uniform to a matrix (2x2)
  97566. * @param uniform defines the webGL uniform location where to store the value
  97567. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97568. */
  97569. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97570. /**
  97571. * Set the value of an uniform to a number (float)
  97572. * @param uniform defines the webGL uniform location where to store the value
  97573. * @param value defines the float number to store
  97574. */
  97575. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97576. /**
  97577. * Set the value of an uniform to a vec2
  97578. * @param uniform defines the webGL uniform location where to store the value
  97579. * @param x defines the 1st component of the value
  97580. * @param y defines the 2nd component of the value
  97581. */
  97582. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97583. /**
  97584. * Set the value of an uniform to a vec3
  97585. * @param uniform defines the webGL uniform location where to store the value
  97586. * @param x defines the 1st component of the value
  97587. * @param y defines the 2nd component of the value
  97588. * @param z defines the 3rd component of the value
  97589. */
  97590. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97591. /**
  97592. * Set the value of an uniform to a vec4
  97593. * @param uniform defines the webGL uniform location where to store the value
  97594. * @param x defines the 1st component of the value
  97595. * @param y defines the 2nd component of the value
  97596. * @param z defines the 3rd component of the value
  97597. * @param w defines the 4th component of the value
  97598. */
  97599. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97600. /**
  97601. * Gets the depth culling state manager
  97602. */
  97603. readonly depthCullingState: DepthCullingState;
  97604. /**
  97605. * Gets the alpha state manager
  97606. */
  97607. readonly alphaState: AlphaState;
  97608. /**
  97609. * Gets the stencil state manager
  97610. */
  97611. readonly stencilState: StencilState;
  97612. /**
  97613. * Clears the list of texture accessible through engine.
  97614. * This can help preventing texture load conflict due to name collision.
  97615. */
  97616. clearInternalTexturesCache(): void;
  97617. /**
  97618. * Force the entire cache to be cleared
  97619. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97620. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97621. */
  97622. wipeCaches(bruteForce?: boolean): void;
  97623. /** @hidden */
  97624. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97625. min: number;
  97626. mag: number;
  97627. };
  97628. /** @hidden */
  97629. _createTexture(): WebGLTexture;
  97630. /**
  97631. * Usually called from Texture.ts.
  97632. * Passed information to create a WebGLTexture
  97633. * @param urlArg defines a value which contains one of the following:
  97634. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97635. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97636. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97637. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97638. * @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)
  97639. * @param scene needed for loading to the correct scene
  97640. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97641. * @param onLoad optional callback to be called upon successful completion
  97642. * @param onError optional callback to be called upon failure
  97643. * @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
  97644. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97645. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97646. * @param forcedExtension defines the extension to use to pick the right loader
  97647. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97648. * @param mimeType defines an optional mime type
  97649. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97650. */
  97651. 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;
  97652. /**
  97653. * @hidden
  97654. */
  97655. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97656. /**
  97657. * Creates a raw texture
  97658. * @param data defines the data to store in the texture
  97659. * @param width defines the width of the texture
  97660. * @param height defines the height of the texture
  97661. * @param format defines the format of the data
  97662. * @param generateMipMaps defines if the engine should generate the mip levels
  97663. * @param invertY defines if data must be stored with Y axis inverted
  97664. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97665. * @param compression defines the compression used (null by default)
  97666. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97667. * @returns the raw texture inside an InternalTexture
  97668. */
  97669. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97670. /**
  97671. * Creates a new raw cube texture
  97672. * @param data defines the array of data to use to create each face
  97673. * @param size defines the size of the textures
  97674. * @param format defines the format of the data
  97675. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97676. * @param generateMipMaps defines if the engine should generate the mip levels
  97677. * @param invertY defines if data must be stored with Y axis inverted
  97678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97679. * @param compression defines the compression used (null by default)
  97680. * @returns the cube texture as an InternalTexture
  97681. */
  97682. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97683. /**
  97684. * Creates a new raw 3D texture
  97685. * @param data defines the data used to create the texture
  97686. * @param width defines the width of the texture
  97687. * @param height defines the height of the texture
  97688. * @param depth defines the depth of the texture
  97689. * @param format defines the format of the texture
  97690. * @param generateMipMaps defines if the engine must generate mip levels
  97691. * @param invertY defines if data must be stored with Y axis inverted
  97692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97693. * @param compression defines the compressed used (can be null)
  97694. * @param textureType defines the compressed used (can be null)
  97695. * @returns a new raw 3D texture (stored in an InternalTexture)
  97696. */
  97697. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97698. private _unpackFlipYCached;
  97699. /**
  97700. * In case you are sharing the context with other applications, it might
  97701. * be interested to not cache the unpack flip y state to ensure a consistent
  97702. * value would be set.
  97703. */
  97704. enableUnpackFlipYCached: boolean;
  97705. /** @hidden */
  97706. _unpackFlipY(value: boolean): void;
  97707. /** @hidden */
  97708. _getUnpackAlignement(): number;
  97709. /**
  97710. * Update the sampling mode of a given texture
  97711. * @param samplingMode defines the required sampling mode
  97712. * @param texture defines the texture to update
  97713. */
  97714. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97715. /** @hidden */
  97716. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97717. width: number;
  97718. height: number;
  97719. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97720. /** @hidden */
  97721. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97722. /** @hidden */
  97723. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97724. /** @hidden */
  97725. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97726. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97727. private _prepareWebGLTexture;
  97728. /** @hidden */
  97729. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97730. /** @hidden */
  97731. _releaseFramebufferObjects(texture: InternalTexture): void;
  97732. /** @hidden */
  97733. _releaseTexture(texture: InternalTexture): void;
  97734. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97735. protected _setProgram(program: WebGLProgram): void;
  97736. protected _boundUniforms: {
  97737. [key: number]: WebGLUniformLocation;
  97738. };
  97739. /**
  97740. * Binds an effect to the webGL context
  97741. * @param effect defines the effect to bind
  97742. */
  97743. bindSamplers(effect: Effect): void;
  97744. private _activateCurrentTexture;
  97745. /** @hidden */
  97746. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97747. /** @hidden */
  97748. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97749. /**
  97750. * Unbind all textures from the webGL context
  97751. */
  97752. unbindAllTextures(): void;
  97753. /**
  97754. * Sets a texture to the according uniform.
  97755. * @param channel The texture channel
  97756. * @param uniform The uniform to set
  97757. * @param texture The texture to apply
  97758. */
  97759. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97760. private _bindSamplerUniformToChannel;
  97761. private _getTextureWrapMode;
  97762. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97763. /**
  97764. * Sets an array of texture to the webGL context
  97765. * @param channel defines the channel where the texture array must be set
  97766. * @param uniform defines the associated uniform location
  97767. * @param textures defines the array of textures to bind
  97768. */
  97769. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97770. /** @hidden */
  97771. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97772. private _setTextureParameterFloat;
  97773. private _setTextureParameterInteger;
  97774. /**
  97775. * Unbind all vertex attributes from the webGL context
  97776. */
  97777. unbindAllAttributes(): void;
  97778. /**
  97779. * 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
  97780. */
  97781. releaseEffects(): void;
  97782. /**
  97783. * Dispose and release all associated resources
  97784. */
  97785. dispose(): void;
  97786. /**
  97787. * Attach a new callback raised when context lost event is fired
  97788. * @param callback defines the callback to call
  97789. */
  97790. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97791. /**
  97792. * Attach a new callback raised when context restored event is fired
  97793. * @param callback defines the callback to call
  97794. */
  97795. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97796. /**
  97797. * Get the current error code of the webGL context
  97798. * @returns the error code
  97799. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97800. */
  97801. getError(): number;
  97802. private _canRenderToFloatFramebuffer;
  97803. private _canRenderToHalfFloatFramebuffer;
  97804. private _canRenderToFramebuffer;
  97805. /** @hidden */
  97806. _getWebGLTextureType(type: number): number;
  97807. /** @hidden */
  97808. _getInternalFormat(format: number): number;
  97809. /** @hidden */
  97810. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97811. /** @hidden */
  97812. _getRGBAMultiSampleBufferFormat(type: number): number;
  97813. /** @hidden */
  97814. _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;
  97815. /**
  97816. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97817. * @returns true if the engine can be created
  97818. * @ignorenaming
  97819. */
  97820. static isSupported(): boolean;
  97821. /**
  97822. * Find the next highest power of two.
  97823. * @param x Number to start search from.
  97824. * @return Next highest power of two.
  97825. */
  97826. static CeilingPOT(x: number): number;
  97827. /**
  97828. * Find the next lowest power of two.
  97829. * @param x Number to start search from.
  97830. * @return Next lowest power of two.
  97831. */
  97832. static FloorPOT(x: number): number;
  97833. /**
  97834. * Find the nearest power of two.
  97835. * @param x Number to start search from.
  97836. * @return Next nearest power of two.
  97837. */
  97838. static NearestPOT(x: number): number;
  97839. /**
  97840. * Get the closest exponent of two
  97841. * @param value defines the value to approximate
  97842. * @param max defines the maximum value to return
  97843. * @param mode defines how to define the closest value
  97844. * @returns closest exponent of two of the given value
  97845. */
  97846. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97847. /**
  97848. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97849. * @param func - the function to be called
  97850. * @param requester - the object that will request the next frame. Falls back to window.
  97851. * @returns frame number
  97852. */
  97853. static QueueNewFrame(func: () => void, requester?: any): number;
  97854. }
  97855. }
  97856. declare module BABYLON {
  97857. /**
  97858. * Class representing spherical harmonics coefficients to the 3rd degree
  97859. */
  97860. export class SphericalHarmonics {
  97861. /**
  97862. * Defines whether or not the harmonics have been prescaled for rendering.
  97863. */
  97864. preScaled: boolean;
  97865. /**
  97866. * The l0,0 coefficients of the spherical harmonics
  97867. */
  97868. l00: Vector3;
  97869. /**
  97870. * The l1,-1 coefficients of the spherical harmonics
  97871. */
  97872. l1_1: Vector3;
  97873. /**
  97874. * The l1,0 coefficients of the spherical harmonics
  97875. */
  97876. l10: Vector3;
  97877. /**
  97878. * The l1,1 coefficients of the spherical harmonics
  97879. */
  97880. l11: Vector3;
  97881. /**
  97882. * The l2,-2 coefficients of the spherical harmonics
  97883. */
  97884. l2_2: Vector3;
  97885. /**
  97886. * The l2,-1 coefficients of the spherical harmonics
  97887. */
  97888. l2_1: Vector3;
  97889. /**
  97890. * The l2,0 coefficients of the spherical harmonics
  97891. */
  97892. l20: Vector3;
  97893. /**
  97894. * The l2,1 coefficients of the spherical harmonics
  97895. */
  97896. l21: Vector3;
  97897. /**
  97898. * The l2,2 coefficients of the spherical harmonics
  97899. */
  97900. l22: Vector3;
  97901. /**
  97902. * Adds a light to the spherical harmonics
  97903. * @param direction the direction of the light
  97904. * @param color the color of the light
  97905. * @param deltaSolidAngle the delta solid angle of the light
  97906. */
  97907. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97908. /**
  97909. * Scales the spherical harmonics by the given amount
  97910. * @param scale the amount to scale
  97911. */
  97912. scaleInPlace(scale: number): void;
  97913. /**
  97914. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97915. *
  97916. * ```
  97917. * E_lm = A_l * L_lm
  97918. * ```
  97919. *
  97920. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97921. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97922. * the scaling factors are given in equation 9.
  97923. */
  97924. convertIncidentRadianceToIrradiance(): void;
  97925. /**
  97926. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97927. *
  97928. * ```
  97929. * L = (1/pi) * E * rho
  97930. * ```
  97931. *
  97932. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97933. */
  97934. convertIrradianceToLambertianRadiance(): void;
  97935. /**
  97936. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97937. * required operations at run time.
  97938. *
  97939. * This is simply done by scaling back the SH with Ylm constants parameter.
  97940. * The trigonometric part being applied by the shader at run time.
  97941. */
  97942. preScaleForRendering(): void;
  97943. /**
  97944. * Constructs a spherical harmonics from an array.
  97945. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97946. * @returns the spherical harmonics
  97947. */
  97948. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97949. /**
  97950. * Gets the spherical harmonics from polynomial
  97951. * @param polynomial the spherical polynomial
  97952. * @returns the spherical harmonics
  97953. */
  97954. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97955. }
  97956. /**
  97957. * Class representing spherical polynomial coefficients to the 3rd degree
  97958. */
  97959. export class SphericalPolynomial {
  97960. private _harmonics;
  97961. /**
  97962. * The spherical harmonics used to create the polynomials.
  97963. */
  97964. readonly preScaledHarmonics: SphericalHarmonics;
  97965. /**
  97966. * The x coefficients of the spherical polynomial
  97967. */
  97968. x: Vector3;
  97969. /**
  97970. * The y coefficients of the spherical polynomial
  97971. */
  97972. y: Vector3;
  97973. /**
  97974. * The z coefficients of the spherical polynomial
  97975. */
  97976. z: Vector3;
  97977. /**
  97978. * The xx coefficients of the spherical polynomial
  97979. */
  97980. xx: Vector3;
  97981. /**
  97982. * The yy coefficients of the spherical polynomial
  97983. */
  97984. yy: Vector3;
  97985. /**
  97986. * The zz coefficients of the spherical polynomial
  97987. */
  97988. zz: Vector3;
  97989. /**
  97990. * The xy coefficients of the spherical polynomial
  97991. */
  97992. xy: Vector3;
  97993. /**
  97994. * The yz coefficients of the spherical polynomial
  97995. */
  97996. yz: Vector3;
  97997. /**
  97998. * The zx coefficients of the spherical polynomial
  97999. */
  98000. zx: Vector3;
  98001. /**
  98002. * Adds an ambient color to the spherical polynomial
  98003. * @param color the color to add
  98004. */
  98005. addAmbient(color: Color3): void;
  98006. /**
  98007. * Scales the spherical polynomial by the given amount
  98008. * @param scale the amount to scale
  98009. */
  98010. scaleInPlace(scale: number): void;
  98011. /**
  98012. * Gets the spherical polynomial from harmonics
  98013. * @param harmonics the spherical harmonics
  98014. * @returns the spherical polynomial
  98015. */
  98016. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98017. /**
  98018. * Constructs a spherical polynomial from an array.
  98019. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98020. * @returns the spherical polynomial
  98021. */
  98022. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98023. }
  98024. }
  98025. declare module BABYLON {
  98026. /**
  98027. * Defines the source of the internal texture
  98028. */
  98029. export enum InternalTextureSource {
  98030. /**
  98031. * The source of the texture data is unknown
  98032. */
  98033. Unknown = 0,
  98034. /**
  98035. * Texture data comes from an URL
  98036. */
  98037. Url = 1,
  98038. /**
  98039. * Texture data is only used for temporary storage
  98040. */
  98041. Temp = 2,
  98042. /**
  98043. * Texture data comes from raw data (ArrayBuffer)
  98044. */
  98045. Raw = 3,
  98046. /**
  98047. * Texture content is dynamic (video or dynamic texture)
  98048. */
  98049. Dynamic = 4,
  98050. /**
  98051. * Texture content is generated by rendering to it
  98052. */
  98053. RenderTarget = 5,
  98054. /**
  98055. * Texture content is part of a multi render target process
  98056. */
  98057. MultiRenderTarget = 6,
  98058. /**
  98059. * Texture data comes from a cube data file
  98060. */
  98061. Cube = 7,
  98062. /**
  98063. * Texture data comes from a raw cube data
  98064. */
  98065. CubeRaw = 8,
  98066. /**
  98067. * Texture data come from a prefiltered cube data file
  98068. */
  98069. CubePrefiltered = 9,
  98070. /**
  98071. * Texture content is raw 3D data
  98072. */
  98073. Raw3D = 10,
  98074. /**
  98075. * Texture content is a depth texture
  98076. */
  98077. Depth = 11,
  98078. /**
  98079. * Texture data comes from a raw cube data encoded with RGBD
  98080. */
  98081. CubeRawRGBD = 12
  98082. }
  98083. /**
  98084. * Class used to store data associated with WebGL texture data for the engine
  98085. * This class should not be used directly
  98086. */
  98087. export class InternalTexture {
  98088. /** @hidden */
  98089. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98090. /**
  98091. * Defines if the texture is ready
  98092. */
  98093. isReady: boolean;
  98094. /**
  98095. * Defines if the texture is a cube texture
  98096. */
  98097. isCube: boolean;
  98098. /**
  98099. * Defines if the texture contains 3D data
  98100. */
  98101. is3D: boolean;
  98102. /**
  98103. * Defines if the texture contains multiview data
  98104. */
  98105. isMultiview: boolean;
  98106. /**
  98107. * Gets the URL used to load this texture
  98108. */
  98109. url: string;
  98110. /**
  98111. * Gets the sampling mode of the texture
  98112. */
  98113. samplingMode: number;
  98114. /**
  98115. * Gets a boolean indicating if the texture needs mipmaps generation
  98116. */
  98117. generateMipMaps: boolean;
  98118. /**
  98119. * Gets the number of samples used by the texture (WebGL2+ only)
  98120. */
  98121. samples: number;
  98122. /**
  98123. * Gets the type of the texture (int, float...)
  98124. */
  98125. type: number;
  98126. /**
  98127. * Gets the format of the texture (RGB, RGBA...)
  98128. */
  98129. format: number;
  98130. /**
  98131. * Observable called when the texture is loaded
  98132. */
  98133. onLoadedObservable: Observable<InternalTexture>;
  98134. /**
  98135. * Gets the width of the texture
  98136. */
  98137. width: number;
  98138. /**
  98139. * Gets the height of the texture
  98140. */
  98141. height: number;
  98142. /**
  98143. * Gets the depth of the texture
  98144. */
  98145. depth: number;
  98146. /**
  98147. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98148. */
  98149. baseWidth: number;
  98150. /**
  98151. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98152. */
  98153. baseHeight: number;
  98154. /**
  98155. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98156. */
  98157. baseDepth: number;
  98158. /**
  98159. * Gets a boolean indicating if the texture is inverted on Y axis
  98160. */
  98161. invertY: boolean;
  98162. /** @hidden */
  98163. _invertVScale: boolean;
  98164. /** @hidden */
  98165. _associatedChannel: number;
  98166. /** @hidden */
  98167. _source: InternalTextureSource;
  98168. /** @hidden */
  98169. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98170. /** @hidden */
  98171. _bufferView: Nullable<ArrayBufferView>;
  98172. /** @hidden */
  98173. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98174. /** @hidden */
  98175. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98176. /** @hidden */
  98177. _size: number;
  98178. /** @hidden */
  98179. _extension: string;
  98180. /** @hidden */
  98181. _files: Nullable<string[]>;
  98182. /** @hidden */
  98183. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98184. /** @hidden */
  98185. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98186. /** @hidden */
  98187. _framebuffer: Nullable<WebGLFramebuffer>;
  98188. /** @hidden */
  98189. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98190. /** @hidden */
  98191. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98192. /** @hidden */
  98193. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98194. /** @hidden */
  98195. _attachments: Nullable<number[]>;
  98196. /** @hidden */
  98197. _cachedCoordinatesMode: Nullable<number>;
  98198. /** @hidden */
  98199. _cachedWrapU: Nullable<number>;
  98200. /** @hidden */
  98201. _cachedWrapV: Nullable<number>;
  98202. /** @hidden */
  98203. _cachedWrapR: Nullable<number>;
  98204. /** @hidden */
  98205. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98206. /** @hidden */
  98207. _isDisabled: boolean;
  98208. /** @hidden */
  98209. _compression: Nullable<string>;
  98210. /** @hidden */
  98211. _generateStencilBuffer: boolean;
  98212. /** @hidden */
  98213. _generateDepthBuffer: boolean;
  98214. /** @hidden */
  98215. _comparisonFunction: number;
  98216. /** @hidden */
  98217. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98218. /** @hidden */
  98219. _lodGenerationScale: number;
  98220. /** @hidden */
  98221. _lodGenerationOffset: number;
  98222. /** @hidden */
  98223. _colorTextureArray: Nullable<WebGLTexture>;
  98224. /** @hidden */
  98225. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98226. /** @hidden */
  98227. _lodTextureHigh: Nullable<BaseTexture>;
  98228. /** @hidden */
  98229. _lodTextureMid: Nullable<BaseTexture>;
  98230. /** @hidden */
  98231. _lodTextureLow: Nullable<BaseTexture>;
  98232. /** @hidden */
  98233. _isRGBD: boolean;
  98234. /** @hidden */
  98235. _linearSpecularLOD: boolean;
  98236. /** @hidden */
  98237. _irradianceTexture: Nullable<BaseTexture>;
  98238. /** @hidden */
  98239. _webGLTexture: Nullable<WebGLTexture>;
  98240. /** @hidden */
  98241. _references: number;
  98242. private _engine;
  98243. /**
  98244. * Gets the Engine the texture belongs to.
  98245. * @returns The babylon engine
  98246. */
  98247. getEngine(): ThinEngine;
  98248. /**
  98249. * Gets the data source type of the texture
  98250. */
  98251. readonly source: InternalTextureSource;
  98252. /**
  98253. * Creates a new InternalTexture
  98254. * @param engine defines the engine to use
  98255. * @param source defines the type of data that will be used
  98256. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98257. */
  98258. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98259. /**
  98260. * Increments the number of references (ie. the number of Texture that point to it)
  98261. */
  98262. incrementReferences(): void;
  98263. /**
  98264. * Change the size of the texture (not the size of the content)
  98265. * @param width defines the new width
  98266. * @param height defines the new height
  98267. * @param depth defines the new depth (1 by default)
  98268. */
  98269. updateSize(width: int, height: int, depth?: int): void;
  98270. /** @hidden */
  98271. _rebuild(): void;
  98272. /** @hidden */
  98273. _swapAndDie(target: InternalTexture): void;
  98274. /**
  98275. * Dispose the current allocated resources
  98276. */
  98277. dispose(): void;
  98278. }
  98279. }
  98280. declare module BABYLON {
  98281. /**
  98282. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98284. */
  98285. export class Analyser {
  98286. /**
  98287. * Gets or sets the smoothing
  98288. * @ignorenaming
  98289. */
  98290. SMOOTHING: number;
  98291. /**
  98292. * Gets or sets the FFT table size
  98293. * @ignorenaming
  98294. */
  98295. FFT_SIZE: number;
  98296. /**
  98297. * Gets or sets the bar graph amplitude
  98298. * @ignorenaming
  98299. */
  98300. BARGRAPHAMPLITUDE: number;
  98301. /**
  98302. * Gets or sets the position of the debug canvas
  98303. * @ignorenaming
  98304. */
  98305. DEBUGCANVASPOS: {
  98306. x: number;
  98307. y: number;
  98308. };
  98309. /**
  98310. * Gets or sets the debug canvas size
  98311. * @ignorenaming
  98312. */
  98313. DEBUGCANVASSIZE: {
  98314. width: number;
  98315. height: number;
  98316. };
  98317. private _byteFreqs;
  98318. private _byteTime;
  98319. private _floatFreqs;
  98320. private _webAudioAnalyser;
  98321. private _debugCanvas;
  98322. private _debugCanvasContext;
  98323. private _scene;
  98324. private _registerFunc;
  98325. private _audioEngine;
  98326. /**
  98327. * Creates a new analyser
  98328. * @param scene defines hosting scene
  98329. */
  98330. constructor(scene: Scene);
  98331. /**
  98332. * Get the number of data values you will have to play with for the visualization
  98333. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98334. * @returns a number
  98335. */
  98336. getFrequencyBinCount(): number;
  98337. /**
  98338. * Gets the current frequency data as a byte array
  98339. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98340. * @returns a Uint8Array
  98341. */
  98342. getByteFrequencyData(): Uint8Array;
  98343. /**
  98344. * Gets the current waveform as a byte array
  98345. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98346. * @returns a Uint8Array
  98347. */
  98348. getByteTimeDomainData(): Uint8Array;
  98349. /**
  98350. * Gets the current frequency data as a float array
  98351. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98352. * @returns a Float32Array
  98353. */
  98354. getFloatFrequencyData(): Float32Array;
  98355. /**
  98356. * Renders the debug canvas
  98357. */
  98358. drawDebugCanvas(): void;
  98359. /**
  98360. * Stops rendering the debug canvas and removes it
  98361. */
  98362. stopDebugCanvas(): void;
  98363. /**
  98364. * Connects two audio nodes
  98365. * @param inputAudioNode defines first node to connect
  98366. * @param outputAudioNode defines second node to connect
  98367. */
  98368. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98369. /**
  98370. * Releases all associated resources
  98371. */
  98372. dispose(): void;
  98373. }
  98374. }
  98375. declare module BABYLON {
  98376. /**
  98377. * This represents an audio engine and it is responsible
  98378. * to play, synchronize and analyse sounds throughout the application.
  98379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98380. */
  98381. export interface IAudioEngine extends IDisposable {
  98382. /**
  98383. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98384. */
  98385. readonly canUseWebAudio: boolean;
  98386. /**
  98387. * Gets the current AudioContext if available.
  98388. */
  98389. readonly audioContext: Nullable<AudioContext>;
  98390. /**
  98391. * The master gain node defines the global audio volume of your audio engine.
  98392. */
  98393. readonly masterGain: GainNode;
  98394. /**
  98395. * Gets whether or not mp3 are supported by your browser.
  98396. */
  98397. readonly isMP3supported: boolean;
  98398. /**
  98399. * Gets whether or not ogg are supported by your browser.
  98400. */
  98401. readonly isOGGsupported: boolean;
  98402. /**
  98403. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98404. * @ignoreNaming
  98405. */
  98406. WarnedWebAudioUnsupported: boolean;
  98407. /**
  98408. * Defines if the audio engine relies on a custom unlocked button.
  98409. * In this case, the embedded button will not be displayed.
  98410. */
  98411. useCustomUnlockedButton: boolean;
  98412. /**
  98413. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98414. */
  98415. readonly unlocked: boolean;
  98416. /**
  98417. * Event raised when audio has been unlocked on the browser.
  98418. */
  98419. onAudioUnlockedObservable: Observable<AudioEngine>;
  98420. /**
  98421. * Event raised when audio has been locked on the browser.
  98422. */
  98423. onAudioLockedObservable: Observable<AudioEngine>;
  98424. /**
  98425. * Flags the audio engine in Locked state.
  98426. * This happens due to new browser policies preventing audio to autoplay.
  98427. */
  98428. lock(): void;
  98429. /**
  98430. * Unlocks the audio engine once a user action has been done on the dom.
  98431. * This is helpful to resume play once browser policies have been satisfied.
  98432. */
  98433. unlock(): void;
  98434. }
  98435. /**
  98436. * This represents the default audio engine used in babylon.
  98437. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98439. */
  98440. export class AudioEngine implements IAudioEngine {
  98441. private _audioContext;
  98442. private _audioContextInitialized;
  98443. private _muteButton;
  98444. private _hostElement;
  98445. /**
  98446. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98447. */
  98448. canUseWebAudio: boolean;
  98449. /**
  98450. * The master gain node defines the global audio volume of your audio engine.
  98451. */
  98452. masterGain: GainNode;
  98453. /**
  98454. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98455. * @ignoreNaming
  98456. */
  98457. WarnedWebAudioUnsupported: boolean;
  98458. /**
  98459. * Gets whether or not mp3 are supported by your browser.
  98460. */
  98461. isMP3supported: boolean;
  98462. /**
  98463. * Gets whether or not ogg are supported by your browser.
  98464. */
  98465. isOGGsupported: boolean;
  98466. /**
  98467. * Gets whether audio has been unlocked on the device.
  98468. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98469. * a user interaction has happened.
  98470. */
  98471. unlocked: boolean;
  98472. /**
  98473. * Defines if the audio engine relies on a custom unlocked button.
  98474. * In this case, the embedded button will not be displayed.
  98475. */
  98476. useCustomUnlockedButton: boolean;
  98477. /**
  98478. * Event raised when audio has been unlocked on the browser.
  98479. */
  98480. onAudioUnlockedObservable: Observable<AudioEngine>;
  98481. /**
  98482. * Event raised when audio has been locked on the browser.
  98483. */
  98484. onAudioLockedObservable: Observable<AudioEngine>;
  98485. /**
  98486. * Gets the current AudioContext if available.
  98487. */
  98488. readonly audioContext: Nullable<AudioContext>;
  98489. private _connectedAnalyser;
  98490. /**
  98491. * Instantiates a new audio engine.
  98492. *
  98493. * There should be only one per page as some browsers restrict the number
  98494. * of audio contexts you can create.
  98495. * @param hostElement defines the host element where to display the mute icon if necessary
  98496. */
  98497. constructor(hostElement?: Nullable<HTMLElement>);
  98498. /**
  98499. * Flags the audio engine in Locked state.
  98500. * This happens due to new browser policies preventing audio to autoplay.
  98501. */
  98502. lock(): void;
  98503. /**
  98504. * Unlocks the audio engine once a user action has been done on the dom.
  98505. * This is helpful to resume play once browser policies have been satisfied.
  98506. */
  98507. unlock(): void;
  98508. private _resumeAudioContext;
  98509. private _initializeAudioContext;
  98510. private _tryToRun;
  98511. private _triggerRunningState;
  98512. private _triggerSuspendedState;
  98513. private _displayMuteButton;
  98514. private _moveButtonToTopLeft;
  98515. private _onResize;
  98516. private _hideMuteButton;
  98517. /**
  98518. * Destroy and release the resources associated with the audio ccontext.
  98519. */
  98520. dispose(): void;
  98521. /**
  98522. * Gets the global volume sets on the master gain.
  98523. * @returns the global volume if set or -1 otherwise
  98524. */
  98525. getGlobalVolume(): number;
  98526. /**
  98527. * Sets the global volume of your experience (sets on the master gain).
  98528. * @param newVolume Defines the new global volume of the application
  98529. */
  98530. setGlobalVolume(newVolume: number): void;
  98531. /**
  98532. * Connect the audio engine to an audio analyser allowing some amazing
  98533. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98535. * @param analyser The analyser to connect to the engine
  98536. */
  98537. connectToAnalyser(analyser: Analyser): void;
  98538. }
  98539. }
  98540. declare module BABYLON {
  98541. /**
  98542. * Interface used to present a loading screen while loading a scene
  98543. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98544. */
  98545. export interface ILoadingScreen {
  98546. /**
  98547. * Function called to display the loading screen
  98548. */
  98549. displayLoadingUI: () => void;
  98550. /**
  98551. * Function called to hide the loading screen
  98552. */
  98553. hideLoadingUI: () => void;
  98554. /**
  98555. * Gets or sets the color to use for the background
  98556. */
  98557. loadingUIBackgroundColor: string;
  98558. /**
  98559. * Gets or sets the text to display while loading
  98560. */
  98561. loadingUIText: string;
  98562. }
  98563. /**
  98564. * Class used for the default loading screen
  98565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98566. */
  98567. export class DefaultLoadingScreen implements ILoadingScreen {
  98568. private _renderingCanvas;
  98569. private _loadingText;
  98570. private _loadingDivBackgroundColor;
  98571. private _loadingDiv;
  98572. private _loadingTextDiv;
  98573. /** Gets or sets the logo url to use for the default loading screen */
  98574. static DefaultLogoUrl: string;
  98575. /** Gets or sets the spinner url to use for the default loading screen */
  98576. static DefaultSpinnerUrl: string;
  98577. /**
  98578. * Creates a new default loading screen
  98579. * @param _renderingCanvas defines the canvas used to render the scene
  98580. * @param _loadingText defines the default text to display
  98581. * @param _loadingDivBackgroundColor defines the default background color
  98582. */
  98583. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98584. /**
  98585. * Function called to display the loading screen
  98586. */
  98587. displayLoadingUI(): void;
  98588. /**
  98589. * Function called to hide the loading screen
  98590. */
  98591. hideLoadingUI(): void;
  98592. /**
  98593. * Gets or sets the text to display while loading
  98594. */
  98595. loadingUIText: string;
  98596. /**
  98597. * Gets or sets the color to use for the background
  98598. */
  98599. loadingUIBackgroundColor: string;
  98600. private _resizeLoadingUI;
  98601. }
  98602. }
  98603. declare module BABYLON {
  98604. /**
  98605. * Interface for any object that can request an animation frame
  98606. */
  98607. export interface ICustomAnimationFrameRequester {
  98608. /**
  98609. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98610. */
  98611. renderFunction?: Function;
  98612. /**
  98613. * Called to request the next frame to render to
  98614. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98615. */
  98616. requestAnimationFrame: Function;
  98617. /**
  98618. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98619. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98620. */
  98621. requestID?: number;
  98622. }
  98623. }
  98624. declare module BABYLON {
  98625. /**
  98626. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98627. */
  98628. export class PerformanceMonitor {
  98629. private _enabled;
  98630. private _rollingFrameTime;
  98631. private _lastFrameTimeMs;
  98632. /**
  98633. * constructor
  98634. * @param frameSampleSize The number of samples required to saturate the sliding window
  98635. */
  98636. constructor(frameSampleSize?: number);
  98637. /**
  98638. * Samples current frame
  98639. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98640. */
  98641. sampleFrame(timeMs?: number): void;
  98642. /**
  98643. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98644. */
  98645. readonly averageFrameTime: number;
  98646. /**
  98647. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98648. */
  98649. readonly averageFrameTimeVariance: number;
  98650. /**
  98651. * Returns the frame time of the most recent frame
  98652. */
  98653. readonly instantaneousFrameTime: number;
  98654. /**
  98655. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98656. */
  98657. readonly averageFPS: number;
  98658. /**
  98659. * Returns the average framerate in frames per second using the most recent frame time
  98660. */
  98661. readonly instantaneousFPS: number;
  98662. /**
  98663. * Returns true if enough samples have been taken to completely fill the sliding window
  98664. */
  98665. readonly isSaturated: boolean;
  98666. /**
  98667. * Enables contributions to the sliding window sample set
  98668. */
  98669. enable(): void;
  98670. /**
  98671. * Disables contributions to the sliding window sample set
  98672. * Samples will not be interpolated over the disabled period
  98673. */
  98674. disable(): void;
  98675. /**
  98676. * Returns true if sampling is enabled
  98677. */
  98678. readonly isEnabled: boolean;
  98679. /**
  98680. * Resets performance monitor
  98681. */
  98682. reset(): void;
  98683. }
  98684. /**
  98685. * RollingAverage
  98686. *
  98687. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98688. */
  98689. export class RollingAverage {
  98690. /**
  98691. * Current average
  98692. */
  98693. average: number;
  98694. /**
  98695. * Current variance
  98696. */
  98697. variance: number;
  98698. protected _samples: Array<number>;
  98699. protected _sampleCount: number;
  98700. protected _pos: number;
  98701. protected _m2: number;
  98702. /**
  98703. * constructor
  98704. * @param length The number of samples required to saturate the sliding window
  98705. */
  98706. constructor(length: number);
  98707. /**
  98708. * Adds a sample to the sample set
  98709. * @param v The sample value
  98710. */
  98711. add(v: number): void;
  98712. /**
  98713. * Returns previously added values or null if outside of history or outside the sliding window domain
  98714. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98715. * @return Value previously recorded with add() or null if outside of range
  98716. */
  98717. history(i: number): number;
  98718. /**
  98719. * Returns true if enough samples have been taken to completely fill the sliding window
  98720. * @return true if sample-set saturated
  98721. */
  98722. isSaturated(): boolean;
  98723. /**
  98724. * Resets the rolling average (equivalent to 0 samples taken so far)
  98725. */
  98726. reset(): void;
  98727. /**
  98728. * Wraps a value around the sample range boundaries
  98729. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98730. * @return Wrapped position in sample range
  98731. */
  98732. protected _wrapPosition(i: number): number;
  98733. }
  98734. }
  98735. declare module BABYLON {
  98736. /**
  98737. * This class is used to track a performance counter which is number based.
  98738. * The user has access to many properties which give statistics of different nature.
  98739. *
  98740. * The implementer can track two kinds of Performance Counter: time and count.
  98741. * 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.
  98742. * 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.
  98743. */
  98744. export class PerfCounter {
  98745. /**
  98746. * Gets or sets a global boolean to turn on and off all the counters
  98747. */
  98748. static Enabled: boolean;
  98749. /**
  98750. * Returns the smallest value ever
  98751. */
  98752. readonly min: number;
  98753. /**
  98754. * Returns the biggest value ever
  98755. */
  98756. readonly max: number;
  98757. /**
  98758. * Returns the average value since the performance counter is running
  98759. */
  98760. readonly average: number;
  98761. /**
  98762. * Returns the average value of the last second the counter was monitored
  98763. */
  98764. readonly lastSecAverage: number;
  98765. /**
  98766. * Returns the current value
  98767. */
  98768. readonly current: number;
  98769. /**
  98770. * Gets the accumulated total
  98771. */
  98772. readonly total: number;
  98773. /**
  98774. * Gets the total value count
  98775. */
  98776. readonly count: number;
  98777. /**
  98778. * Creates a new counter
  98779. */
  98780. constructor();
  98781. /**
  98782. * Call this method to start monitoring a new frame.
  98783. * 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.
  98784. */
  98785. fetchNewFrame(): void;
  98786. /**
  98787. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98788. * @param newCount the count value to add to the monitored count
  98789. * @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.
  98790. */
  98791. addCount(newCount: number, fetchResult: boolean): void;
  98792. /**
  98793. * Start monitoring this performance counter
  98794. */
  98795. beginMonitoring(): void;
  98796. /**
  98797. * Compute the time lapsed since the previous beginMonitoring() call.
  98798. * @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
  98799. */
  98800. endMonitoring(newFrame?: boolean): void;
  98801. private _fetchResult;
  98802. private _startMonitoringTime;
  98803. private _min;
  98804. private _max;
  98805. private _average;
  98806. private _current;
  98807. private _totalValueCount;
  98808. private _totalAccumulated;
  98809. private _lastSecAverage;
  98810. private _lastSecAccumulated;
  98811. private _lastSecTime;
  98812. private _lastSecValueCount;
  98813. }
  98814. }
  98815. declare module BABYLON {
  98816. /**
  98817. * Defines the interface used by display changed events
  98818. */
  98819. export interface IDisplayChangedEventArgs {
  98820. /** Gets the vrDisplay object (if any) */
  98821. vrDisplay: Nullable<any>;
  98822. /** Gets a boolean indicating if webVR is supported */
  98823. vrSupported: boolean;
  98824. }
  98825. /**
  98826. * Defines the interface used by objects containing a viewport (like a camera)
  98827. */
  98828. interface IViewportOwnerLike {
  98829. /**
  98830. * Gets or sets the viewport
  98831. */
  98832. viewport: IViewportLike;
  98833. }
  98834. /**
  98835. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98836. */
  98837. export class Engine extends ThinEngine {
  98838. /** Defines that alpha blending is disabled */
  98839. static readonly ALPHA_DISABLE: number;
  98840. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98841. static readonly ALPHA_ADD: number;
  98842. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98843. static readonly ALPHA_COMBINE: number;
  98844. /** Defines that alpha blending to DEST - SRC * DEST */
  98845. static readonly ALPHA_SUBTRACT: number;
  98846. /** Defines that alpha blending to SRC * DEST */
  98847. static readonly ALPHA_MULTIPLY: number;
  98848. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98849. static readonly ALPHA_MAXIMIZED: number;
  98850. /** Defines that alpha blending to SRC + DEST */
  98851. static readonly ALPHA_ONEONE: number;
  98852. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98853. static readonly ALPHA_PREMULTIPLIED: number;
  98854. /**
  98855. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98856. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98857. */
  98858. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98859. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98860. static readonly ALPHA_INTERPOLATE: number;
  98861. /**
  98862. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98863. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98864. */
  98865. static readonly ALPHA_SCREENMODE: number;
  98866. /** Defines that the ressource is not delayed*/
  98867. static readonly DELAYLOADSTATE_NONE: number;
  98868. /** Defines that the ressource was successfully delay loaded */
  98869. static readonly DELAYLOADSTATE_LOADED: number;
  98870. /** Defines that the ressource is currently delay loading */
  98871. static readonly DELAYLOADSTATE_LOADING: number;
  98872. /** Defines that the ressource is delayed and has not started loading */
  98873. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98874. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98875. static readonly NEVER: number;
  98876. /** 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 */
  98877. static readonly ALWAYS: number;
  98878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98879. static readonly LESS: number;
  98880. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98881. static readonly EQUAL: number;
  98882. /** 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 */
  98883. static readonly LEQUAL: number;
  98884. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98885. static readonly GREATER: number;
  98886. /** 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 */
  98887. static readonly GEQUAL: number;
  98888. /** 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 */
  98889. static readonly NOTEQUAL: number;
  98890. /** Passed to stencilOperation to specify that stencil value must be kept */
  98891. static readonly KEEP: number;
  98892. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98893. static readonly REPLACE: number;
  98894. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98895. static readonly INCR: number;
  98896. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98897. static readonly DECR: number;
  98898. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98899. static readonly INVERT: number;
  98900. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98901. static readonly INCR_WRAP: number;
  98902. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98903. static readonly DECR_WRAP: number;
  98904. /** Texture is not repeating outside of 0..1 UVs */
  98905. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98906. /** Texture is repeating outside of 0..1 UVs */
  98907. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98908. /** Texture is repeating and mirrored */
  98909. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98910. /** ALPHA */
  98911. static readonly TEXTUREFORMAT_ALPHA: number;
  98912. /** LUMINANCE */
  98913. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98914. /** LUMINANCE_ALPHA */
  98915. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98916. /** RGB */
  98917. static readonly TEXTUREFORMAT_RGB: number;
  98918. /** RGBA */
  98919. static readonly TEXTUREFORMAT_RGBA: number;
  98920. /** RED */
  98921. static readonly TEXTUREFORMAT_RED: number;
  98922. /** RED (2nd reference) */
  98923. static readonly TEXTUREFORMAT_R: number;
  98924. /** RG */
  98925. static readonly TEXTUREFORMAT_RG: number;
  98926. /** RED_INTEGER */
  98927. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98928. /** RED_INTEGER (2nd reference) */
  98929. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98930. /** RG_INTEGER */
  98931. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98932. /** RGB_INTEGER */
  98933. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98934. /** RGBA_INTEGER */
  98935. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98936. /** UNSIGNED_BYTE */
  98937. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98938. /** UNSIGNED_BYTE (2nd reference) */
  98939. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98940. /** FLOAT */
  98941. static readonly TEXTURETYPE_FLOAT: number;
  98942. /** HALF_FLOAT */
  98943. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98944. /** BYTE */
  98945. static readonly TEXTURETYPE_BYTE: number;
  98946. /** SHORT */
  98947. static readonly TEXTURETYPE_SHORT: number;
  98948. /** UNSIGNED_SHORT */
  98949. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98950. /** INT */
  98951. static readonly TEXTURETYPE_INT: number;
  98952. /** UNSIGNED_INT */
  98953. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98954. /** UNSIGNED_SHORT_4_4_4_4 */
  98955. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98956. /** UNSIGNED_SHORT_5_5_5_1 */
  98957. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98958. /** UNSIGNED_SHORT_5_6_5 */
  98959. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98960. /** UNSIGNED_INT_2_10_10_10_REV */
  98961. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98962. /** UNSIGNED_INT_24_8 */
  98963. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98964. /** UNSIGNED_INT_10F_11F_11F_REV */
  98965. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98966. /** UNSIGNED_INT_5_9_9_9_REV */
  98967. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98968. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98969. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98970. /** nearest is mag = nearest and min = nearest and mip = linear */
  98971. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98972. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98973. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98974. /** Trilinear is mag = linear and min = linear and mip = linear */
  98975. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98976. /** nearest is mag = nearest and min = nearest and mip = linear */
  98977. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98978. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98979. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98980. /** Trilinear is mag = linear and min = linear and mip = linear */
  98981. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98982. /** mag = nearest and min = nearest and mip = nearest */
  98983. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98984. /** mag = nearest and min = linear and mip = nearest */
  98985. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98986. /** mag = nearest and min = linear and mip = linear */
  98987. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98988. /** mag = nearest and min = linear and mip = none */
  98989. static readonly TEXTURE_NEAREST_LINEAR: number;
  98990. /** mag = nearest and min = nearest and mip = none */
  98991. static readonly TEXTURE_NEAREST_NEAREST: number;
  98992. /** mag = linear and min = nearest and mip = nearest */
  98993. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98994. /** mag = linear and min = nearest and mip = linear */
  98995. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98996. /** mag = linear and min = linear and mip = none */
  98997. static readonly TEXTURE_LINEAR_LINEAR: number;
  98998. /** mag = linear and min = nearest and mip = none */
  98999. static readonly TEXTURE_LINEAR_NEAREST: number;
  99000. /** Explicit coordinates mode */
  99001. static readonly TEXTURE_EXPLICIT_MODE: number;
  99002. /** Spherical coordinates mode */
  99003. static readonly TEXTURE_SPHERICAL_MODE: number;
  99004. /** Planar coordinates mode */
  99005. static readonly TEXTURE_PLANAR_MODE: number;
  99006. /** Cubic coordinates mode */
  99007. static readonly TEXTURE_CUBIC_MODE: number;
  99008. /** Projection coordinates mode */
  99009. static readonly TEXTURE_PROJECTION_MODE: number;
  99010. /** Skybox coordinates mode */
  99011. static readonly TEXTURE_SKYBOX_MODE: number;
  99012. /** Inverse Cubic coordinates mode */
  99013. static readonly TEXTURE_INVCUBIC_MODE: number;
  99014. /** Equirectangular coordinates mode */
  99015. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99016. /** Equirectangular Fixed coordinates mode */
  99017. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99018. /** Equirectangular Fixed Mirrored coordinates mode */
  99019. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99020. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99021. static readonly SCALEMODE_FLOOR: number;
  99022. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99023. static readonly SCALEMODE_NEAREST: number;
  99024. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99025. static readonly SCALEMODE_CEILING: number;
  99026. /**
  99027. * Returns the current npm package of the sdk
  99028. */
  99029. static readonly NpmPackage: string;
  99030. /**
  99031. * Returns the current version of the framework
  99032. */
  99033. static readonly Version: string;
  99034. /** Gets the list of created engines */
  99035. static readonly Instances: Engine[];
  99036. /**
  99037. * Gets the latest created engine
  99038. */
  99039. static readonly LastCreatedEngine: Nullable<Engine>;
  99040. /**
  99041. * Gets the latest created scene
  99042. */
  99043. static readonly LastCreatedScene: Nullable<Scene>;
  99044. /**
  99045. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99046. * @param flag defines which part of the materials must be marked as dirty
  99047. * @param predicate defines a predicate used to filter which materials should be affected
  99048. */
  99049. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99050. /**
  99051. * Method called to create the default loading screen.
  99052. * This can be overriden in your own app.
  99053. * @param canvas The rendering canvas element
  99054. * @returns The loading screen
  99055. */
  99056. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99057. /**
  99058. * Method called to create the default rescale post process on each engine.
  99059. */
  99060. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99061. /**
  99062. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99063. **/
  99064. enableOfflineSupport: boolean;
  99065. /**
  99066. * 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)
  99067. **/
  99068. disableManifestCheck: boolean;
  99069. /**
  99070. * Gets the list of created scenes
  99071. */
  99072. scenes: Scene[];
  99073. /**
  99074. * Event raised when a new scene is created
  99075. */
  99076. onNewSceneAddedObservable: Observable<Scene>;
  99077. /**
  99078. * Gets the list of created postprocesses
  99079. */
  99080. postProcesses: PostProcess[];
  99081. /**
  99082. * Gets a boolean indicating if the pointer is currently locked
  99083. */
  99084. isPointerLock: boolean;
  99085. /**
  99086. * Observable event triggered each time the rendering canvas is resized
  99087. */
  99088. onResizeObservable: Observable<Engine>;
  99089. /**
  99090. * Observable event triggered each time the canvas loses focus
  99091. */
  99092. onCanvasBlurObservable: Observable<Engine>;
  99093. /**
  99094. * Observable event triggered each time the canvas gains focus
  99095. */
  99096. onCanvasFocusObservable: Observable<Engine>;
  99097. /**
  99098. * Observable event triggered each time the canvas receives pointerout event
  99099. */
  99100. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99101. /**
  99102. * Observable raised when the engine begins a new frame
  99103. */
  99104. onBeginFrameObservable: Observable<Engine>;
  99105. /**
  99106. * If set, will be used to request the next animation frame for the render loop
  99107. */
  99108. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99109. /**
  99110. * Observable raised when the engine ends the current frame
  99111. */
  99112. onEndFrameObservable: Observable<Engine>;
  99113. /**
  99114. * Observable raised when the engine is about to compile a shader
  99115. */
  99116. onBeforeShaderCompilationObservable: Observable<Engine>;
  99117. /**
  99118. * Observable raised when the engine has jsut compiled a shader
  99119. */
  99120. onAfterShaderCompilationObservable: Observable<Engine>;
  99121. /**
  99122. * Gets the audio engine
  99123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99124. * @ignorenaming
  99125. */
  99126. static audioEngine: IAudioEngine;
  99127. /**
  99128. * Default AudioEngine factory responsible of creating the Audio Engine.
  99129. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99130. */
  99131. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99132. /**
  99133. * Default offline support factory responsible of creating a tool used to store data locally.
  99134. * By default, this will create a Database object if the workload has been embedded.
  99135. */
  99136. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99137. private _loadingScreen;
  99138. private _pointerLockRequested;
  99139. private _dummyFramebuffer;
  99140. private _rescalePostProcess;
  99141. /** @hidden */
  99142. protected _alphaMode: number;
  99143. /** @hidden */
  99144. protected _alphaEquation: number;
  99145. private _deterministicLockstep;
  99146. private _lockstepMaxSteps;
  99147. protected readonly _supportsHardwareTextureRescaling: boolean;
  99148. private _fps;
  99149. private _deltaTime;
  99150. /** @hidden */
  99151. _drawCalls: PerfCounter;
  99152. /**
  99153. * Turn this value on if you want to pause FPS computation when in background
  99154. */
  99155. disablePerformanceMonitorInBackground: boolean;
  99156. private _performanceMonitor;
  99157. /**
  99158. * Gets the performance monitor attached to this engine
  99159. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99160. */
  99161. readonly performanceMonitor: PerformanceMonitor;
  99162. private _onFocus;
  99163. private _onBlur;
  99164. private _onCanvasPointerOut;
  99165. private _onCanvasBlur;
  99166. private _onCanvasFocus;
  99167. private _onFullscreenChange;
  99168. private _onPointerLockChange;
  99169. /**
  99170. * Gets the HTML element used to attach event listeners
  99171. * @returns a HTML element
  99172. */
  99173. getInputElement(): Nullable<HTMLElement>;
  99174. /**
  99175. * Creates a new engine
  99176. * @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
  99177. * @param antialias defines enable antialiasing (default: false)
  99178. * @param options defines further options to be sent to the getContext() function
  99179. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99180. */
  99181. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99182. /**
  99183. * Gets current aspect ratio
  99184. * @param viewportOwner defines the camera to use to get the aspect ratio
  99185. * @param useScreen defines if screen size must be used (or the current render target if any)
  99186. * @returns a number defining the aspect ratio
  99187. */
  99188. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99189. /**
  99190. * Gets current screen aspect ratio
  99191. * @returns a number defining the aspect ratio
  99192. */
  99193. getScreenAspectRatio(): number;
  99194. /**
  99195. * Gets host document
  99196. * @returns the host document object
  99197. */
  99198. getHostDocument(): Document;
  99199. /**
  99200. * Gets the client rect of the HTML canvas attached with the current webGL context
  99201. * @returns a client rectanglee
  99202. */
  99203. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99204. /**
  99205. * Gets the client rect of the HTML element used for events
  99206. * @returns a client rectanglee
  99207. */
  99208. getInputElementClientRect(): Nullable<ClientRect>;
  99209. /**
  99210. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99212. * @returns true if engine is in deterministic lock step mode
  99213. */
  99214. isDeterministicLockStep(): boolean;
  99215. /**
  99216. * Gets the max steps when engine is running in deterministic lock step
  99217. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99218. * @returns the max steps
  99219. */
  99220. getLockstepMaxSteps(): number;
  99221. /**
  99222. * Force the mipmap generation for the given render target texture
  99223. * @param texture defines the render target texture to use
  99224. */
  99225. generateMipMapsForCubemap(texture: InternalTexture): void;
  99226. /** States */
  99227. /**
  99228. * Set various states to the webGL context
  99229. * @param culling defines backface culling state
  99230. * @param zOffset defines the value to apply to zOffset (0 by default)
  99231. * @param force defines if states must be applied even if cache is up to date
  99232. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99233. */
  99234. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99235. /**
  99236. * Set the z offset to apply to current rendering
  99237. * @param value defines the offset to apply
  99238. */
  99239. setZOffset(value: number): void;
  99240. /**
  99241. * Gets the current value of the zOffset
  99242. * @returns the current zOffset state
  99243. */
  99244. getZOffset(): number;
  99245. /**
  99246. * Enable or disable depth buffering
  99247. * @param enable defines the state to set
  99248. */
  99249. setDepthBuffer(enable: boolean): void;
  99250. /**
  99251. * Gets a boolean indicating if depth writing is enabled
  99252. * @returns the current depth writing state
  99253. */
  99254. getDepthWrite(): boolean;
  99255. /**
  99256. * Enable or disable depth writing
  99257. * @param enable defines the state to set
  99258. */
  99259. setDepthWrite(enable: boolean): void;
  99260. /**
  99261. * Enable or disable color writing
  99262. * @param enable defines the state to set
  99263. */
  99264. setColorWrite(enable: boolean): void;
  99265. /**
  99266. * Gets a boolean indicating if color writing is enabled
  99267. * @returns the current color writing state
  99268. */
  99269. getColorWrite(): boolean;
  99270. /**
  99271. * Sets alpha constants used by some alpha blending modes
  99272. * @param r defines the red component
  99273. * @param g defines the green component
  99274. * @param b defines the blue component
  99275. * @param a defines the alpha component
  99276. */
  99277. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99278. /**
  99279. * Sets the current alpha mode
  99280. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99281. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99283. */
  99284. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99285. /**
  99286. * Gets the current alpha mode
  99287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99288. * @returns the current alpha mode
  99289. */
  99290. getAlphaMode(): number;
  99291. /**
  99292. * Sets the current alpha equation
  99293. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99294. */
  99295. setAlphaEquation(equation: number): void;
  99296. /**
  99297. * Gets the current alpha equation.
  99298. * @returns the current alpha equation
  99299. */
  99300. getAlphaEquation(): number;
  99301. /**
  99302. * Gets a boolean indicating if stencil buffer is enabled
  99303. * @returns the current stencil buffer state
  99304. */
  99305. getStencilBuffer(): boolean;
  99306. /**
  99307. * Enable or disable the stencil buffer
  99308. * @param enable defines if the stencil buffer must be enabled or disabled
  99309. */
  99310. setStencilBuffer(enable: boolean): void;
  99311. /**
  99312. * Gets the current stencil mask
  99313. * @returns a number defining the new stencil mask to use
  99314. */
  99315. getStencilMask(): number;
  99316. /**
  99317. * Sets the current stencil mask
  99318. * @param mask defines the new stencil mask to use
  99319. */
  99320. setStencilMask(mask: number): void;
  99321. /**
  99322. * Gets the current stencil function
  99323. * @returns a number defining the stencil function to use
  99324. */
  99325. getStencilFunction(): number;
  99326. /**
  99327. * Gets the current stencil reference value
  99328. * @returns a number defining the stencil reference value to use
  99329. */
  99330. getStencilFunctionReference(): number;
  99331. /**
  99332. * Gets the current stencil mask
  99333. * @returns a number defining the stencil mask to use
  99334. */
  99335. getStencilFunctionMask(): number;
  99336. /**
  99337. * Sets the current stencil function
  99338. * @param stencilFunc defines the new stencil function to use
  99339. */
  99340. setStencilFunction(stencilFunc: number): void;
  99341. /**
  99342. * Sets the current stencil reference
  99343. * @param reference defines the new stencil reference to use
  99344. */
  99345. setStencilFunctionReference(reference: number): void;
  99346. /**
  99347. * Sets the current stencil mask
  99348. * @param mask defines the new stencil mask to use
  99349. */
  99350. setStencilFunctionMask(mask: number): void;
  99351. /**
  99352. * Gets the current stencil operation when stencil fails
  99353. * @returns a number defining stencil operation to use when stencil fails
  99354. */
  99355. getStencilOperationFail(): number;
  99356. /**
  99357. * Gets the current stencil operation when depth fails
  99358. * @returns a number defining stencil operation to use when depth fails
  99359. */
  99360. getStencilOperationDepthFail(): number;
  99361. /**
  99362. * Gets the current stencil operation when stencil passes
  99363. * @returns a number defining stencil operation to use when stencil passes
  99364. */
  99365. getStencilOperationPass(): number;
  99366. /**
  99367. * Sets the stencil operation to use when stencil fails
  99368. * @param operation defines the stencil operation to use when stencil fails
  99369. */
  99370. setStencilOperationFail(operation: number): void;
  99371. /**
  99372. * Sets the stencil operation to use when depth fails
  99373. * @param operation defines the stencil operation to use when depth fails
  99374. */
  99375. setStencilOperationDepthFail(operation: number): void;
  99376. /**
  99377. * Sets the stencil operation to use when stencil passes
  99378. * @param operation defines the stencil operation to use when stencil passes
  99379. */
  99380. setStencilOperationPass(operation: number): void;
  99381. /**
  99382. * Sets a boolean indicating if the dithering state is enabled or disabled
  99383. * @param value defines the dithering state
  99384. */
  99385. setDitheringState(value: boolean): void;
  99386. /**
  99387. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99388. * @param value defines the rasterizer state
  99389. */
  99390. setRasterizerState(value: boolean): void;
  99391. /**
  99392. * Gets the current depth function
  99393. * @returns a number defining the depth function
  99394. */
  99395. getDepthFunction(): Nullable<number>;
  99396. /**
  99397. * Sets the current depth function
  99398. * @param depthFunc defines the function to use
  99399. */
  99400. setDepthFunction(depthFunc: number): void;
  99401. /**
  99402. * Sets the current depth function to GREATER
  99403. */
  99404. setDepthFunctionToGreater(): void;
  99405. /**
  99406. * Sets the current depth function to GEQUAL
  99407. */
  99408. setDepthFunctionToGreaterOrEqual(): void;
  99409. /**
  99410. * Sets the current depth function to LESS
  99411. */
  99412. setDepthFunctionToLess(): void;
  99413. /**
  99414. * Sets the current depth function to LEQUAL
  99415. */
  99416. setDepthFunctionToLessOrEqual(): void;
  99417. private _cachedStencilBuffer;
  99418. private _cachedStencilFunction;
  99419. private _cachedStencilMask;
  99420. private _cachedStencilOperationPass;
  99421. private _cachedStencilOperationFail;
  99422. private _cachedStencilOperationDepthFail;
  99423. private _cachedStencilReference;
  99424. /**
  99425. * Caches the the state of the stencil buffer
  99426. */
  99427. cacheStencilState(): void;
  99428. /**
  99429. * Restores the state of the stencil buffer
  99430. */
  99431. restoreStencilState(): void;
  99432. /**
  99433. * Directly set the WebGL Viewport
  99434. * @param x defines the x coordinate of the viewport (in screen space)
  99435. * @param y defines the y coordinate of the viewport (in screen space)
  99436. * @param width defines the width of the viewport (in screen space)
  99437. * @param height defines the height of the viewport (in screen space)
  99438. * @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
  99439. */
  99440. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99441. /**
  99442. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99443. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99444. * @param y defines the y-coordinate of the corner of the clear rectangle
  99445. * @param width defines the width of the clear rectangle
  99446. * @param height defines the height of the clear rectangle
  99447. * @param clearColor defines the clear color
  99448. */
  99449. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99450. /**
  99451. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99452. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99453. * @param y defines the y-coordinate of the corner of the clear rectangle
  99454. * @param width defines the width of the clear rectangle
  99455. * @param height defines the height of the clear rectangle
  99456. */
  99457. enableScissor(x: number, y: number, width: number, height: number): void;
  99458. /**
  99459. * Disable previously set scissor test rectangle
  99460. */
  99461. disableScissor(): void;
  99462. protected _reportDrawCall(): void;
  99463. /**
  99464. * Initializes a webVR display and starts listening to display change events
  99465. * The onVRDisplayChangedObservable will be notified upon these changes
  99466. * @returns The onVRDisplayChangedObservable
  99467. */
  99468. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99469. /** @hidden */
  99470. _prepareVRComponent(): void;
  99471. /** @hidden */
  99472. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99473. /** @hidden */
  99474. _submitVRFrame(): void;
  99475. /**
  99476. * Call this function to leave webVR mode
  99477. * Will do nothing if webVR is not supported or if there is no webVR device
  99478. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99479. */
  99480. disableVR(): void;
  99481. /**
  99482. * Gets a boolean indicating that the system is in VR mode and is presenting
  99483. * @returns true if VR mode is engaged
  99484. */
  99485. isVRPresenting(): boolean;
  99486. /** @hidden */
  99487. _requestVRFrame(): void;
  99488. /** @hidden */
  99489. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99490. /**
  99491. * Gets the source code of the vertex shader associated with a specific webGL program
  99492. * @param program defines the program to use
  99493. * @returns a string containing the source code of the vertex shader associated with the program
  99494. */
  99495. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99496. /**
  99497. * Gets the source code of the fragment shader associated with a specific webGL program
  99498. * @param program defines the program to use
  99499. * @returns a string containing the source code of the fragment shader associated with the program
  99500. */
  99501. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99502. /**
  99503. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99504. * @param x defines the x coordinate of the rectangle where pixels must be read
  99505. * @param y defines the y coordinate of the rectangle where pixels must be read
  99506. * @param width defines the width of the rectangle where pixels must be read
  99507. * @param height defines the height of the rectangle where pixels must be read
  99508. * @returns a Uint8Array containing RGBA colors
  99509. */
  99510. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99511. /**
  99512. * Sets a depth stencil texture from a render target to the according uniform.
  99513. * @param channel The texture channel
  99514. * @param uniform The uniform to set
  99515. * @param texture The render target texture containing the depth stencil texture to apply
  99516. */
  99517. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99518. /**
  99519. * Sets a texture to the webGL context from a postprocess
  99520. * @param channel defines the channel to use
  99521. * @param postProcess defines the source postprocess
  99522. */
  99523. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99524. /**
  99525. * Binds the output of the passed in post process to the texture channel specified
  99526. * @param channel The channel the texture should be bound to
  99527. * @param postProcess The post process which's output should be bound
  99528. */
  99529. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99530. /** @hidden */
  99531. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99532. protected _rebuildBuffers(): void;
  99533. /** @hidden */
  99534. _renderFrame(): void;
  99535. _renderLoop(): void;
  99536. /** @hidden */
  99537. _renderViews(): boolean;
  99538. /**
  99539. * Toggle full screen mode
  99540. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99541. */
  99542. switchFullscreen(requestPointerLock: boolean): void;
  99543. /**
  99544. * Enters full screen mode
  99545. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99546. */
  99547. enterFullscreen(requestPointerLock: boolean): void;
  99548. /**
  99549. * Exits full screen mode
  99550. */
  99551. exitFullscreen(): void;
  99552. /**
  99553. * Enters Pointerlock mode
  99554. */
  99555. enterPointerlock(): void;
  99556. /**
  99557. * Exits Pointerlock mode
  99558. */
  99559. exitPointerlock(): void;
  99560. /**
  99561. * Begin a new frame
  99562. */
  99563. beginFrame(): void;
  99564. /**
  99565. * Enf the current frame
  99566. */
  99567. endFrame(): void;
  99568. resize(): void;
  99569. /**
  99570. * Set the compressed texture format to use, based on the formats you have, and the formats
  99571. * supported by the hardware / browser.
  99572. *
  99573. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99574. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99575. * to API arguments needed to compressed textures. This puts the burden on the container
  99576. * generator to house the arcane code for determining these for current & future formats.
  99577. *
  99578. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99579. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99580. *
  99581. * Note: The result of this call is not taken into account when a texture is base64.
  99582. *
  99583. * @param formatsAvailable defines the list of those format families you have created
  99584. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99585. *
  99586. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99587. * @returns The extension selected.
  99588. */
  99589. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99590. /**
  99591. * Force a specific size of the canvas
  99592. * @param width defines the new canvas' width
  99593. * @param height defines the new canvas' height
  99594. */
  99595. setSize(width: number, height: number): void;
  99596. /**
  99597. * Updates a dynamic vertex buffer.
  99598. * @param vertexBuffer the vertex buffer to update
  99599. * @param data the data used to update the vertex buffer
  99600. * @param byteOffset the byte offset of the data
  99601. * @param byteLength the byte length of the data
  99602. */
  99603. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99604. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99605. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99606. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99607. _releaseTexture(texture: InternalTexture): void;
  99608. /**
  99609. * @hidden
  99610. * Rescales a texture
  99611. * @param source input texutre
  99612. * @param destination destination texture
  99613. * @param scene scene to use to render the resize
  99614. * @param internalFormat format to use when resizing
  99615. * @param onComplete callback to be called when resize has completed
  99616. */
  99617. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99618. /**
  99619. * Gets the current framerate
  99620. * @returns a number representing the framerate
  99621. */
  99622. getFps(): number;
  99623. /**
  99624. * Gets the time spent between current and previous frame
  99625. * @returns a number representing the delta time in ms
  99626. */
  99627. getDeltaTime(): number;
  99628. private _measureFps;
  99629. /** @hidden */
  99630. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  99631. /**
  99632. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99633. * @param renderTarget The render target to set the frame buffer for
  99634. */
  99635. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99636. /**
  99637. * Update a dynamic index buffer
  99638. * @param indexBuffer defines the target index buffer
  99639. * @param indices defines the data to update
  99640. * @param offset defines the offset in the target index buffer where update should start
  99641. */
  99642. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99643. /**
  99644. * Updates the sample count of a render target texture
  99645. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99646. * @param texture defines the texture to update
  99647. * @param samples defines the sample count to set
  99648. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99649. */
  99650. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99651. /**
  99652. * Updates a depth texture Comparison Mode and Function.
  99653. * If the comparison Function is equal to 0, the mode will be set to none.
  99654. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  99655. * @param texture The texture to set the comparison function for
  99656. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  99657. */
  99658. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  99659. /**
  99660. * Creates a webGL buffer to use with instanciation
  99661. * @param capacity defines the size of the buffer
  99662. * @returns the webGL buffer
  99663. */
  99664. createInstancesBuffer(capacity: number): DataBuffer;
  99665. /**
  99666. * Delete a webGL buffer used with instanciation
  99667. * @param buffer defines the webGL buffer to delete
  99668. */
  99669. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  99670. /** @hidden */
  99671. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99672. dispose(): void;
  99673. private _disableTouchAction;
  99674. /**
  99675. * Display the loading screen
  99676. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99677. */
  99678. displayLoadingUI(): void;
  99679. /**
  99680. * Hide the loading screen
  99681. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99682. */
  99683. hideLoadingUI(): void;
  99684. /**
  99685. * Gets the current loading screen object
  99686. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99687. */
  99688. /**
  99689. * Sets the current loading screen object
  99690. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99691. */
  99692. loadingScreen: ILoadingScreen;
  99693. /**
  99694. * Sets the current loading screen text
  99695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99696. */
  99697. loadingUIText: string;
  99698. /**
  99699. * Sets the current loading screen background color
  99700. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99701. */
  99702. loadingUIBackgroundColor: string;
  99703. /** Pointerlock and fullscreen */
  99704. /**
  99705. * Ask the browser to promote the current element to pointerlock mode
  99706. * @param element defines the DOM element to promote
  99707. */
  99708. static _RequestPointerlock(element: HTMLElement): void;
  99709. /**
  99710. * Asks the browser to exit pointerlock mode
  99711. */
  99712. static _ExitPointerlock(): void;
  99713. /**
  99714. * Ask the browser to promote the current element to fullscreen rendering mode
  99715. * @param element defines the DOM element to promote
  99716. */
  99717. static _RequestFullscreen(element: HTMLElement): void;
  99718. /**
  99719. * Asks the browser to exit fullscreen mode
  99720. */
  99721. static _ExitFullscreen(): void;
  99722. }
  99723. }
  99724. declare module BABYLON {
  99725. /**
  99726. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99727. * during the life time of the application.
  99728. */
  99729. export class EngineStore {
  99730. /** Gets the list of created engines */
  99731. static Instances: Engine[];
  99732. /** @hidden */
  99733. static _LastCreatedScene: Nullable<Scene>;
  99734. /**
  99735. * Gets the latest created engine
  99736. */
  99737. static readonly LastCreatedEngine: Nullable<Engine>;
  99738. /**
  99739. * Gets the latest created scene
  99740. */
  99741. static readonly LastCreatedScene: Nullable<Scene>;
  99742. /**
  99743. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99744. * @ignorenaming
  99745. */
  99746. static UseFallbackTexture: boolean;
  99747. /**
  99748. * Texture content used if a texture cannot loaded
  99749. * @ignorenaming
  99750. */
  99751. static FallbackTexture: string;
  99752. }
  99753. }
  99754. declare module BABYLON {
  99755. /**
  99756. * Helper class that provides a small promise polyfill
  99757. */
  99758. export class PromisePolyfill {
  99759. /**
  99760. * Static function used to check if the polyfill is required
  99761. * If this is the case then the function will inject the polyfill to window.Promise
  99762. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99763. */
  99764. static Apply(force?: boolean): void;
  99765. }
  99766. }
  99767. declare module BABYLON {
  99768. /**
  99769. * Interface for screenshot methods with describe argument called `size` as object with options
  99770. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99771. */
  99772. export interface IScreenshotSize {
  99773. /**
  99774. * number in pixels for canvas height
  99775. */
  99776. height?: number;
  99777. /**
  99778. * multiplier allowing render at a higher or lower resolution
  99779. * If value is defined then height and width will be ignored and taken from camera
  99780. */
  99781. precision?: number;
  99782. /**
  99783. * number in pixels for canvas width
  99784. */
  99785. width?: number;
  99786. }
  99787. }
  99788. declare module BABYLON {
  99789. interface IColor4Like {
  99790. r: float;
  99791. g: float;
  99792. b: float;
  99793. a: float;
  99794. }
  99795. /**
  99796. * Class containing a set of static utilities functions
  99797. */
  99798. export class Tools {
  99799. /**
  99800. * Gets or sets the base URL to use to load assets
  99801. */
  99802. static BaseUrl: string;
  99803. /**
  99804. * Enable/Disable Custom HTTP Request Headers globally.
  99805. * default = false
  99806. * @see CustomRequestHeaders
  99807. */
  99808. static UseCustomRequestHeaders: boolean;
  99809. /**
  99810. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99811. * i.e. when loading files, where the server/service expects an Authorization header
  99812. */
  99813. static CustomRequestHeaders: {
  99814. [key: string]: string;
  99815. };
  99816. /**
  99817. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99818. */
  99819. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99820. /**
  99821. * Default behaviour for cors in the application.
  99822. * It can be a string if the expected behavior is identical in the entire app.
  99823. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99824. */
  99825. static CorsBehavior: string | ((url: string | string[]) => string);
  99826. /**
  99827. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99828. * @ignorenaming
  99829. */
  99830. static UseFallbackTexture: boolean;
  99831. /**
  99832. * Use this object to register external classes like custom textures or material
  99833. * to allow the laoders to instantiate them
  99834. */
  99835. static RegisteredExternalClasses: {
  99836. [key: string]: Object;
  99837. };
  99838. /**
  99839. * Texture content used if a texture cannot loaded
  99840. * @ignorenaming
  99841. */
  99842. static fallbackTexture: string;
  99843. /**
  99844. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99845. * @param u defines the coordinate on X axis
  99846. * @param v defines the coordinate on Y axis
  99847. * @param width defines the width of the source data
  99848. * @param height defines the height of the source data
  99849. * @param pixels defines the source byte array
  99850. * @param color defines the output color
  99851. */
  99852. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99853. /**
  99854. * Interpolates between a and b via alpha
  99855. * @param a The lower value (returned when alpha = 0)
  99856. * @param b The upper value (returned when alpha = 1)
  99857. * @param alpha The interpolation-factor
  99858. * @return The mixed value
  99859. */
  99860. static Mix(a: number, b: number, alpha: number): number;
  99861. /**
  99862. * Tries to instantiate a new object from a given class name
  99863. * @param className defines the class name to instantiate
  99864. * @returns the new object or null if the system was not able to do the instantiation
  99865. */
  99866. static Instantiate(className: string): any;
  99867. /**
  99868. * Provides a slice function that will work even on IE
  99869. * @param data defines the array to slice
  99870. * @param start defines the start of the data (optional)
  99871. * @param end defines the end of the data (optional)
  99872. * @returns the new sliced array
  99873. */
  99874. static Slice<T>(data: T, start?: number, end?: number): T;
  99875. /**
  99876. * Polyfill for setImmediate
  99877. * @param action defines the action to execute after the current execution block
  99878. */
  99879. static SetImmediate(action: () => void): void;
  99880. /**
  99881. * Function indicating if a number is an exponent of 2
  99882. * @param value defines the value to test
  99883. * @returns true if the value is an exponent of 2
  99884. */
  99885. static IsExponentOfTwo(value: number): boolean;
  99886. private static _tmpFloatArray;
  99887. /**
  99888. * Returns the nearest 32-bit single precision float representation of a Number
  99889. * @param value A Number. If the parameter is of a different type, it will get converted
  99890. * to a number or to NaN if it cannot be converted
  99891. * @returns number
  99892. */
  99893. static FloatRound(value: number): number;
  99894. /**
  99895. * Extracts the filename from a path
  99896. * @param path defines the path to use
  99897. * @returns the filename
  99898. */
  99899. static GetFilename(path: string): string;
  99900. /**
  99901. * Extracts the "folder" part of a path (everything before the filename).
  99902. * @param uri The URI to extract the info from
  99903. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99904. * @returns The "folder" part of the path
  99905. */
  99906. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99907. /**
  99908. * Extracts text content from a DOM element hierarchy
  99909. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99910. */
  99911. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99912. /**
  99913. * Convert an angle in radians to degrees
  99914. * @param angle defines the angle to convert
  99915. * @returns the angle in degrees
  99916. */
  99917. static ToDegrees(angle: number): number;
  99918. /**
  99919. * Convert an angle in degrees to radians
  99920. * @param angle defines the angle to convert
  99921. * @returns the angle in radians
  99922. */
  99923. static ToRadians(angle: number): number;
  99924. /**
  99925. * Returns an array if obj is not an array
  99926. * @param obj defines the object to evaluate as an array
  99927. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99928. * @returns either obj directly if obj is an array or a new array containing obj
  99929. */
  99930. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99931. /**
  99932. * Gets the pointer prefix to use
  99933. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99934. */
  99935. static GetPointerPrefix(): string;
  99936. /**
  99937. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99938. * @param url define the url we are trying
  99939. * @param element define the dom element where to configure the cors policy
  99940. */
  99941. static SetCorsBehavior(url: string | string[], element: {
  99942. crossOrigin: string | null;
  99943. }): void;
  99944. /**
  99945. * Removes unwanted characters from an url
  99946. * @param url defines the url to clean
  99947. * @returns the cleaned url
  99948. */
  99949. static CleanUrl(url: string): string;
  99950. /**
  99951. * Gets or sets a function used to pre-process url before using them to load assets
  99952. */
  99953. static PreprocessUrl: (url: string) => string;
  99954. /**
  99955. * Loads an image as an HTMLImageElement.
  99956. * @param input url string, ArrayBuffer, or Blob to load
  99957. * @param onLoad callback called when the image successfully loads
  99958. * @param onError callback called when the image fails to load
  99959. * @param offlineProvider offline provider for caching
  99960. * @param mimeType optional mime type
  99961. * @returns the HTMLImageElement of the loaded image
  99962. */
  99963. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99964. /**
  99965. * Loads a file from a url
  99966. * @param url url string, ArrayBuffer, or Blob to load
  99967. * @param onSuccess callback called when the file successfully loads
  99968. * @param onProgress callback called while file is loading (if the server supports this mode)
  99969. * @param offlineProvider defines the offline provider for caching
  99970. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99971. * @param onError callback called when the file fails to load
  99972. * @returns a file request object
  99973. */
  99974. 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;
  99975. /**
  99976. * Loads a file from a url
  99977. * @param url the file url to load
  99978. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99979. */
  99980. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99981. /**
  99982. * Load a script (identified by an url). When the url returns, the
  99983. * content of this file is added into a new script element, attached to the DOM (body element)
  99984. * @param scriptUrl defines the url of the script to laod
  99985. * @param onSuccess defines the callback called when the script is loaded
  99986. * @param onError defines the callback to call if an error occurs
  99987. * @param scriptId defines the id of the script element
  99988. */
  99989. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99990. /**
  99991. * Load an asynchronous script (identified by an url). When the url returns, the
  99992. * content of this file is added into a new script element, attached to the DOM (body element)
  99993. * @param scriptUrl defines the url of the script to laod
  99994. * @param scriptId defines the id of the script element
  99995. * @returns a promise request object
  99996. */
  99997. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99998. /**
  99999. * Loads a file from a blob
  100000. * @param fileToLoad defines the blob to use
  100001. * @param callback defines the callback to call when data is loaded
  100002. * @param progressCallback defines the callback to call during loading process
  100003. * @returns a file request object
  100004. */
  100005. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100006. /**
  100007. * Reads a file from a File object
  100008. * @param file defines the file to load
  100009. * @param onSuccess defines the callback to call when data is loaded
  100010. * @param onProgress defines the callback to call during loading process
  100011. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100012. * @param onError defines the callback to call when an error occurs
  100013. * @returns a file request object
  100014. */
  100015. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100016. /**
  100017. * Creates a data url from a given string content
  100018. * @param content defines the content to convert
  100019. * @returns the new data url link
  100020. */
  100021. static FileAsURL(content: string): string;
  100022. /**
  100023. * Format the given number to a specific decimal format
  100024. * @param value defines the number to format
  100025. * @param decimals defines the number of decimals to use
  100026. * @returns the formatted string
  100027. */
  100028. static Format(value: number, decimals?: number): string;
  100029. /**
  100030. * Tries to copy an object by duplicating every property
  100031. * @param source defines the source object
  100032. * @param destination defines the target object
  100033. * @param doNotCopyList defines a list of properties to avoid
  100034. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100035. */
  100036. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100037. /**
  100038. * Gets a boolean indicating if the given object has no own property
  100039. * @param obj defines the object to test
  100040. * @returns true if object has no own property
  100041. */
  100042. static IsEmpty(obj: any): boolean;
  100043. /**
  100044. * Function used to register events at window level
  100045. * @param windowElement defines the Window object to use
  100046. * @param events defines the events to register
  100047. */
  100048. static RegisterTopRootEvents(windowElement: Window, events: {
  100049. name: string;
  100050. handler: Nullable<(e: FocusEvent) => any>;
  100051. }[]): void;
  100052. /**
  100053. * Function used to unregister events from window level
  100054. * @param windowElement defines the Window object to use
  100055. * @param events defines the events to unregister
  100056. */
  100057. static UnregisterTopRootEvents(windowElement: Window, events: {
  100058. name: string;
  100059. handler: Nullable<(e: FocusEvent) => any>;
  100060. }[]): void;
  100061. /**
  100062. * @ignore
  100063. */
  100064. static _ScreenshotCanvas: HTMLCanvasElement;
  100065. /**
  100066. * Dumps the current bound framebuffer
  100067. * @param width defines the rendering width
  100068. * @param height defines the rendering height
  100069. * @param engine defines the hosting engine
  100070. * @param successCallback defines the callback triggered once the data are available
  100071. * @param mimeType defines the mime type of the result
  100072. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100073. */
  100074. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100075. /**
  100076. * Converts the canvas data to blob.
  100077. * This acts as a polyfill for browsers not supporting the to blob function.
  100078. * @param canvas Defines the canvas to extract the data from
  100079. * @param successCallback Defines the callback triggered once the data are available
  100080. * @param mimeType Defines the mime type of the result
  100081. */
  100082. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100083. /**
  100084. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100085. * @param successCallback defines the callback triggered once the data are available
  100086. * @param mimeType defines the mime type of the result
  100087. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100088. */
  100089. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100090. /**
  100091. * Downloads a blob in the browser
  100092. * @param blob defines the blob to download
  100093. * @param fileName defines the name of the downloaded file
  100094. */
  100095. static Download(blob: Blob, fileName: string): void;
  100096. /**
  100097. * Captures a screenshot of the current rendering
  100098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100099. * @param engine defines the rendering engine
  100100. * @param camera defines the source camera
  100101. * @param size This parameter can be set to a single number or to an object with the
  100102. * following (optional) properties: precision, width, height. If a single number is passed,
  100103. * it will be used for both width and height. If an object is passed, the screenshot size
  100104. * will be derived from the parameters. The precision property is a multiplier allowing
  100105. * rendering at a higher or lower resolution
  100106. * @param successCallback defines the callback receives a single parameter which contains the
  100107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100108. * src parameter of an <img> to display it
  100109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100110. * Check your browser for supported MIME types
  100111. */
  100112. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100113. /**
  100114. * Captures a screenshot of the current rendering
  100115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100116. * @param engine defines the rendering engine
  100117. * @param camera defines the source camera
  100118. * @param size This parameter can be set to a single number or to an object with the
  100119. * following (optional) properties: precision, width, height. If a single number is passed,
  100120. * it will be used for both width and height. If an object is passed, the screenshot size
  100121. * will be derived from the parameters. The precision property is a multiplier allowing
  100122. * rendering at a higher or lower resolution
  100123. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100124. * Check your browser for supported MIME types
  100125. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100126. * to the src parameter of an <img> to display it
  100127. */
  100128. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100129. /**
  100130. * Generates an image screenshot from the specified camera.
  100131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100132. * @param engine The engine to use for rendering
  100133. * @param camera The camera to use for rendering
  100134. * @param size This parameter can be set to a single number or to an object with the
  100135. * following (optional) properties: precision, width, height. If a single number is passed,
  100136. * it will be used for both width and height. If an object is passed, the screenshot size
  100137. * will be derived from the parameters. The precision property is a multiplier allowing
  100138. * rendering at a higher or lower resolution
  100139. * @param successCallback The callback receives a single parameter which contains the
  100140. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100141. * src parameter of an <img> to display it
  100142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100143. * Check your browser for supported MIME types
  100144. * @param samples Texture samples (default: 1)
  100145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100146. * @param fileName A name for for the downloaded file.
  100147. */
  100148. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100149. /**
  100150. * Generates an image screenshot from the specified camera.
  100151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100152. * @param engine The engine to use for rendering
  100153. * @param camera The camera to use for rendering
  100154. * @param size This parameter can be set to a single number or to an object with the
  100155. * following (optional) properties: precision, width, height. If a single number is passed,
  100156. * it will be used for both width and height. If an object is passed, the screenshot size
  100157. * will be derived from the parameters. The precision property is a multiplier allowing
  100158. * rendering at a higher or lower resolution
  100159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100160. * Check your browser for supported MIME types
  100161. * @param samples Texture samples (default: 1)
  100162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100163. * @param fileName A name for for the downloaded file.
  100164. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100165. * to the src parameter of an <img> to display it
  100166. */
  100167. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100168. /**
  100169. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100170. * Be aware Math.random() could cause collisions, but:
  100171. * "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"
  100172. * @returns a pseudo random id
  100173. */
  100174. static RandomId(): string;
  100175. /**
  100176. * Test if the given uri is a base64 string
  100177. * @param uri The uri to test
  100178. * @return True if the uri is a base64 string or false otherwise
  100179. */
  100180. static IsBase64(uri: string): boolean;
  100181. /**
  100182. * Decode the given base64 uri.
  100183. * @param uri The uri to decode
  100184. * @return The decoded base64 data.
  100185. */
  100186. static DecodeBase64(uri: string): ArrayBuffer;
  100187. /**
  100188. * Gets the absolute url.
  100189. * @param url the input url
  100190. * @return the absolute url
  100191. */
  100192. static GetAbsoluteUrl(url: string): string;
  100193. /**
  100194. * No log
  100195. */
  100196. static readonly NoneLogLevel: number;
  100197. /**
  100198. * Only message logs
  100199. */
  100200. static readonly MessageLogLevel: number;
  100201. /**
  100202. * Only warning logs
  100203. */
  100204. static readonly WarningLogLevel: number;
  100205. /**
  100206. * Only error logs
  100207. */
  100208. static readonly ErrorLogLevel: number;
  100209. /**
  100210. * All logs
  100211. */
  100212. static readonly AllLogLevel: number;
  100213. /**
  100214. * Gets a value indicating the number of loading errors
  100215. * @ignorenaming
  100216. */
  100217. static readonly errorsCount: number;
  100218. /**
  100219. * Callback called when a new log is added
  100220. */
  100221. static OnNewCacheEntry: (entry: string) => void;
  100222. /**
  100223. * Log a message to the console
  100224. * @param message defines the message to log
  100225. */
  100226. static Log(message: string): void;
  100227. /**
  100228. * Write a warning message to the console
  100229. * @param message defines the message to log
  100230. */
  100231. static Warn(message: string): void;
  100232. /**
  100233. * Write an error message to the console
  100234. * @param message defines the message to log
  100235. */
  100236. static Error(message: string): void;
  100237. /**
  100238. * Gets current log cache (list of logs)
  100239. */
  100240. static readonly LogCache: string;
  100241. /**
  100242. * Clears the log cache
  100243. */
  100244. static ClearLogCache(): void;
  100245. /**
  100246. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100247. */
  100248. static LogLevels: number;
  100249. /**
  100250. * Checks if the window object exists
  100251. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100252. */
  100253. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100254. /**
  100255. * No performance log
  100256. */
  100257. static readonly PerformanceNoneLogLevel: number;
  100258. /**
  100259. * Use user marks to log performance
  100260. */
  100261. static readonly PerformanceUserMarkLogLevel: number;
  100262. /**
  100263. * Log performance to the console
  100264. */
  100265. static readonly PerformanceConsoleLogLevel: number;
  100266. private static _performance;
  100267. /**
  100268. * Sets the current performance log level
  100269. */
  100270. static PerformanceLogLevel: number;
  100271. private static _StartPerformanceCounterDisabled;
  100272. private static _EndPerformanceCounterDisabled;
  100273. private static _StartUserMark;
  100274. private static _EndUserMark;
  100275. private static _StartPerformanceConsole;
  100276. private static _EndPerformanceConsole;
  100277. /**
  100278. * Starts a performance counter
  100279. */
  100280. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100281. /**
  100282. * Ends a specific performance coutner
  100283. */
  100284. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100285. /**
  100286. * Gets either window.performance.now() if supported or Date.now() else
  100287. */
  100288. static readonly Now: number;
  100289. /**
  100290. * This method will return the name of the class used to create the instance of the given object.
  100291. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100292. * @param object the object to get the class name from
  100293. * @param isType defines if the object is actually a type
  100294. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100295. */
  100296. static GetClassName(object: any, isType?: boolean): string;
  100297. /**
  100298. * Gets the first element of an array satisfying a given predicate
  100299. * @param array defines the array to browse
  100300. * @param predicate defines the predicate to use
  100301. * @returns null if not found or the element
  100302. */
  100303. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100304. /**
  100305. * This method will return the name of the full name of the class, including its owning module (if any).
  100306. * 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).
  100307. * @param object the object to get the class name from
  100308. * @param isType defines if the object is actually a type
  100309. * @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.
  100310. * @ignorenaming
  100311. */
  100312. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100313. /**
  100314. * Returns a promise that resolves after the given amount of time.
  100315. * @param delay Number of milliseconds to delay
  100316. * @returns Promise that resolves after the given amount of time
  100317. */
  100318. static DelayAsync(delay: number): Promise<void>;
  100319. }
  100320. /**
  100321. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100322. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100323. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100324. * @param name The name of the class, case should be preserved
  100325. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100326. */
  100327. export function className(name: string, module?: string): (target: Object) => void;
  100328. /**
  100329. * An implementation of a loop for asynchronous functions.
  100330. */
  100331. export class AsyncLoop {
  100332. /**
  100333. * Defines the number of iterations for the loop
  100334. */
  100335. iterations: number;
  100336. /**
  100337. * Defines the current index of the loop.
  100338. */
  100339. index: number;
  100340. private _done;
  100341. private _fn;
  100342. private _successCallback;
  100343. /**
  100344. * Constructor.
  100345. * @param iterations the number of iterations.
  100346. * @param func the function to run each iteration
  100347. * @param successCallback the callback that will be called upon succesful execution
  100348. * @param offset starting offset.
  100349. */
  100350. constructor(
  100351. /**
  100352. * Defines the number of iterations for the loop
  100353. */
  100354. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100355. /**
  100356. * Execute the next iteration. Must be called after the last iteration was finished.
  100357. */
  100358. executeNext(): void;
  100359. /**
  100360. * Break the loop and run the success callback.
  100361. */
  100362. breakLoop(): void;
  100363. /**
  100364. * Create and run an async loop.
  100365. * @param iterations the number of iterations.
  100366. * @param fn the function to run each iteration
  100367. * @param successCallback the callback that will be called upon succesful execution
  100368. * @param offset starting offset.
  100369. * @returns the created async loop object
  100370. */
  100371. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100372. /**
  100373. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100374. * @param iterations total number of iterations
  100375. * @param syncedIterations number of synchronous iterations in each async iteration.
  100376. * @param fn the function to call each iteration.
  100377. * @param callback a success call back that will be called when iterating stops.
  100378. * @param breakFunction a break condition (optional)
  100379. * @param timeout timeout settings for the setTimeout function. default - 0.
  100380. * @returns the created async loop object
  100381. */
  100382. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100383. }
  100384. }
  100385. declare module BABYLON {
  100386. /**
  100387. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100388. * The underlying implementation relies on an associative array to ensure the best performances.
  100389. * The value can be anything including 'null' but except 'undefined'
  100390. */
  100391. export class StringDictionary<T> {
  100392. /**
  100393. * This will clear this dictionary and copy the content from the 'source' one.
  100394. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100395. * @param source the dictionary to take the content from and copy to this dictionary
  100396. */
  100397. copyFrom(source: StringDictionary<T>): void;
  100398. /**
  100399. * Get a value based from its key
  100400. * @param key the given key to get the matching value from
  100401. * @return the value if found, otherwise undefined is returned
  100402. */
  100403. get(key: string): T | undefined;
  100404. /**
  100405. * Get a value from its key or add it if it doesn't exist.
  100406. * This method will ensure you that a given key/data will be present in the dictionary.
  100407. * @param key the given key to get the matching value from
  100408. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100409. * The factory will only be invoked if there's no data for the given key.
  100410. * @return the value corresponding to the key.
  100411. */
  100412. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100413. /**
  100414. * Get a value from its key if present in the dictionary otherwise add it
  100415. * @param key the key to get the value from
  100416. * @param val if there's no such key/value pair in the dictionary add it with this value
  100417. * @return the value corresponding to the key
  100418. */
  100419. getOrAdd(key: string, val: T): T;
  100420. /**
  100421. * Check if there's a given key in the dictionary
  100422. * @param key the key to check for
  100423. * @return true if the key is present, false otherwise
  100424. */
  100425. contains(key: string): boolean;
  100426. /**
  100427. * Add a new key and its corresponding value
  100428. * @param key the key to add
  100429. * @param value the value corresponding to the key
  100430. * @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
  100431. */
  100432. add(key: string, value: T): boolean;
  100433. /**
  100434. * Update a specific value associated to a key
  100435. * @param key defines the key to use
  100436. * @param value defines the value to store
  100437. * @returns true if the value was updated (or false if the key was not found)
  100438. */
  100439. set(key: string, value: T): boolean;
  100440. /**
  100441. * Get the element of the given key and remove it from the dictionary
  100442. * @param key defines the key to search
  100443. * @returns the value associated with the key or null if not found
  100444. */
  100445. getAndRemove(key: string): Nullable<T>;
  100446. /**
  100447. * Remove a key/value from the dictionary.
  100448. * @param key the key to remove
  100449. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100450. */
  100451. remove(key: string): boolean;
  100452. /**
  100453. * Clear the whole content of the dictionary
  100454. */
  100455. clear(): void;
  100456. /**
  100457. * Gets the current count
  100458. */
  100459. readonly count: number;
  100460. /**
  100461. * Execute a callback on each key/val of the dictionary.
  100462. * Note that you can remove any element in this dictionary in the callback implementation
  100463. * @param callback the callback to execute on a given key/value pair
  100464. */
  100465. forEach(callback: (key: string, val: T) => void): void;
  100466. /**
  100467. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100468. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100469. * Note that you can remove any element in this dictionary in the callback implementation
  100470. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100471. * @returns the first item
  100472. */
  100473. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100474. private _count;
  100475. private _data;
  100476. }
  100477. }
  100478. declare module BABYLON {
  100479. /** @hidden */
  100480. export interface ICollisionCoordinator {
  100481. createCollider(): Collider;
  100482. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100483. init(scene: Scene): void;
  100484. }
  100485. /** @hidden */
  100486. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100487. private _scene;
  100488. private _scaledPosition;
  100489. private _scaledVelocity;
  100490. private _finalPosition;
  100491. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100492. createCollider(): Collider;
  100493. init(scene: Scene): void;
  100494. private _collideWithWorld;
  100495. }
  100496. }
  100497. declare module BABYLON {
  100498. /**
  100499. * Class used to manage all inputs for the scene.
  100500. */
  100501. export class InputManager {
  100502. /** The distance in pixel that you have to move to prevent some events */
  100503. static DragMovementThreshold: number;
  100504. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100505. static LongPressDelay: number;
  100506. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100507. static DoubleClickDelay: number;
  100508. /** If you need to check double click without raising a single click at first click, enable this flag */
  100509. static ExclusiveDoubleClickMode: boolean;
  100510. private _wheelEventName;
  100511. private _onPointerMove;
  100512. private _onPointerDown;
  100513. private _onPointerUp;
  100514. private _initClickEvent;
  100515. private _initActionManager;
  100516. private _delayedSimpleClick;
  100517. private _delayedSimpleClickTimeout;
  100518. private _previousDelayedSimpleClickTimeout;
  100519. private _meshPickProceed;
  100520. private _previousButtonPressed;
  100521. private _currentPickResult;
  100522. private _previousPickResult;
  100523. private _totalPointersPressed;
  100524. private _doubleClickOccured;
  100525. private _pointerOverMesh;
  100526. private _pickedDownMesh;
  100527. private _pickedUpMesh;
  100528. private _pointerX;
  100529. private _pointerY;
  100530. private _unTranslatedPointerX;
  100531. private _unTranslatedPointerY;
  100532. private _startingPointerPosition;
  100533. private _previousStartingPointerPosition;
  100534. private _startingPointerTime;
  100535. private _previousStartingPointerTime;
  100536. private _pointerCaptures;
  100537. private _onKeyDown;
  100538. private _onKeyUp;
  100539. private _onCanvasFocusObserver;
  100540. private _onCanvasBlurObserver;
  100541. private _scene;
  100542. /**
  100543. * Creates a new InputManager
  100544. * @param scene defines the hosting scene
  100545. */
  100546. constructor(scene: Scene);
  100547. /**
  100548. * Gets the mesh that is currently under the pointer
  100549. */
  100550. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100551. /**
  100552. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100553. */
  100554. readonly unTranslatedPointer: Vector2;
  100555. /**
  100556. * Gets or sets the current on-screen X position of the pointer
  100557. */
  100558. pointerX: number;
  100559. /**
  100560. * Gets or sets the current on-screen Y position of the pointer
  100561. */
  100562. pointerY: number;
  100563. private _updatePointerPosition;
  100564. private _processPointerMove;
  100565. private _setRayOnPointerInfo;
  100566. private _checkPrePointerObservable;
  100567. /**
  100568. * Use this method to simulate a pointer move on a mesh
  100569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100572. */
  100573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100574. /**
  100575. * Use this method to simulate a pointer down on a mesh
  100576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100579. */
  100580. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100581. private _processPointerDown;
  100582. /** @hidden */
  100583. _isPointerSwiping(): boolean;
  100584. /**
  100585. * Use this method to simulate a pointer up on a mesh
  100586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100589. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100590. */
  100591. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100592. private _processPointerUp;
  100593. /**
  100594. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100595. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100596. * @returns true if the pointer was captured
  100597. */
  100598. isPointerCaptured(pointerId?: number): boolean;
  100599. /**
  100600. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100601. * @param attachUp defines if you want to attach events to pointerup
  100602. * @param attachDown defines if you want to attach events to pointerdown
  100603. * @param attachMove defines if you want to attach events to pointermove
  100604. */
  100605. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100606. /**
  100607. * Detaches all event handlers
  100608. */
  100609. detachControl(): void;
  100610. /**
  100611. * Force the value of meshUnderPointer
  100612. * @param mesh defines the mesh to use
  100613. */
  100614. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100615. /**
  100616. * Gets the mesh under the pointer
  100617. * @returns a Mesh or null if no mesh is under the pointer
  100618. */
  100619. getPointerOverMesh(): Nullable<AbstractMesh>;
  100620. }
  100621. }
  100622. declare module BABYLON {
  100623. /**
  100624. * Helper class used to generate session unique ID
  100625. */
  100626. export class UniqueIdGenerator {
  100627. private static _UniqueIdCounter;
  100628. /**
  100629. * Gets an unique (relatively to the current scene) Id
  100630. */
  100631. static readonly UniqueId: number;
  100632. }
  100633. }
  100634. declare module BABYLON {
  100635. /**
  100636. * This class defines the direct association between an animation and a target
  100637. */
  100638. export class TargetedAnimation {
  100639. /**
  100640. * Animation to perform
  100641. */
  100642. animation: Animation;
  100643. /**
  100644. * Target to animate
  100645. */
  100646. target: any;
  100647. /**
  100648. * Serialize the object
  100649. * @returns the JSON object representing the current entity
  100650. */
  100651. serialize(): any;
  100652. }
  100653. /**
  100654. * Use this class to create coordinated animations on multiple targets
  100655. */
  100656. export class AnimationGroup implements IDisposable {
  100657. /** The name of the animation group */
  100658. name: string;
  100659. private _scene;
  100660. private _targetedAnimations;
  100661. private _animatables;
  100662. private _from;
  100663. private _to;
  100664. private _isStarted;
  100665. private _isPaused;
  100666. private _speedRatio;
  100667. private _loopAnimation;
  100668. /**
  100669. * Gets or sets the unique id of the node
  100670. */
  100671. uniqueId: number;
  100672. /**
  100673. * This observable will notify when one animation have ended
  100674. */
  100675. onAnimationEndObservable: Observable<TargetedAnimation>;
  100676. /**
  100677. * Observer raised when one animation loops
  100678. */
  100679. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100680. /**
  100681. * Observer raised when all animations have looped
  100682. */
  100683. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  100684. /**
  100685. * This observable will notify when all animations have ended.
  100686. */
  100687. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100688. /**
  100689. * This observable will notify when all animations have paused.
  100690. */
  100691. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100692. /**
  100693. * This observable will notify when all animations are playing.
  100694. */
  100695. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100696. /**
  100697. * Gets the first frame
  100698. */
  100699. readonly from: number;
  100700. /**
  100701. * Gets the last frame
  100702. */
  100703. readonly to: number;
  100704. /**
  100705. * Define if the animations are started
  100706. */
  100707. readonly isStarted: boolean;
  100708. /**
  100709. * Gets a value indicating that the current group is playing
  100710. */
  100711. readonly isPlaying: boolean;
  100712. /**
  100713. * Gets or sets the speed ratio to use for all animations
  100714. */
  100715. /**
  100716. * Gets or sets the speed ratio to use for all animations
  100717. */
  100718. speedRatio: number;
  100719. /**
  100720. * Gets or sets if all animations should loop or not
  100721. */
  100722. loopAnimation: boolean;
  100723. /**
  100724. * Gets the targeted animations for this animation group
  100725. */
  100726. readonly targetedAnimations: Array<TargetedAnimation>;
  100727. /**
  100728. * returning the list of animatables controlled by this animation group.
  100729. */
  100730. readonly animatables: Array<Animatable>;
  100731. /**
  100732. * Instantiates a new Animation Group.
  100733. * This helps managing several animations at once.
  100734. * @see http://doc.babylonjs.com/how_to/group
  100735. * @param name Defines the name of the group
  100736. * @param scene Defines the scene the group belongs to
  100737. */
  100738. constructor(
  100739. /** The name of the animation group */
  100740. name: string, scene?: Nullable<Scene>);
  100741. /**
  100742. * Add an animation (with its target) in the group
  100743. * @param animation defines the animation we want to add
  100744. * @param target defines the target of the animation
  100745. * @returns the TargetedAnimation object
  100746. */
  100747. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100748. /**
  100749. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100750. * It can add constant keys at begin or end
  100751. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100752. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100753. * @returns the animation group
  100754. */
  100755. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100756. private _animationLoopCount;
  100757. private _animationLoopFlags;
  100758. private _processLoop;
  100759. /**
  100760. * Start all animations on given targets
  100761. * @param loop defines if animations must loop
  100762. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100763. * @param from defines the from key (optional)
  100764. * @param to defines the to key (optional)
  100765. * @returns the current animation group
  100766. */
  100767. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100768. /**
  100769. * Pause all animations
  100770. * @returns the animation group
  100771. */
  100772. pause(): AnimationGroup;
  100773. /**
  100774. * Play all animations to initial state
  100775. * This function will start() the animations if they were not started or will restart() them if they were paused
  100776. * @param loop defines if animations must loop
  100777. * @returns the animation group
  100778. */
  100779. play(loop?: boolean): AnimationGroup;
  100780. /**
  100781. * Reset all animations to initial state
  100782. * @returns the animation group
  100783. */
  100784. reset(): AnimationGroup;
  100785. /**
  100786. * Restart animations from key 0
  100787. * @returns the animation group
  100788. */
  100789. restart(): AnimationGroup;
  100790. /**
  100791. * Stop all animations
  100792. * @returns the animation group
  100793. */
  100794. stop(): AnimationGroup;
  100795. /**
  100796. * Set animation weight for all animatables
  100797. * @param weight defines the weight to use
  100798. * @return the animationGroup
  100799. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100800. */
  100801. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100802. /**
  100803. * Synchronize and normalize all animatables with a source animatable
  100804. * @param root defines the root animatable to synchronize with
  100805. * @return the animationGroup
  100806. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100807. */
  100808. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100809. /**
  100810. * Goes to a specific frame in this animation group
  100811. * @param frame the frame number to go to
  100812. * @return the animationGroup
  100813. */
  100814. goToFrame(frame: number): AnimationGroup;
  100815. /**
  100816. * Dispose all associated resources
  100817. */
  100818. dispose(): void;
  100819. private _checkAnimationGroupEnded;
  100820. /**
  100821. * Clone the current animation group and returns a copy
  100822. * @param newName defines the name of the new group
  100823. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100824. * @returns the new aniamtion group
  100825. */
  100826. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100827. /**
  100828. * Serializes the animationGroup to an object
  100829. * @returns Serialized object
  100830. */
  100831. serialize(): any;
  100832. /**
  100833. * Returns a new AnimationGroup object parsed from the source provided.
  100834. * @param parsedAnimationGroup defines the source
  100835. * @param scene defines the scene that will receive the animationGroup
  100836. * @returns a new AnimationGroup
  100837. */
  100838. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100839. /**
  100840. * Returns the string "AnimationGroup"
  100841. * @returns "AnimationGroup"
  100842. */
  100843. getClassName(): string;
  100844. /**
  100845. * Creates a detailled string about the object
  100846. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100847. * @returns a string representing the object
  100848. */
  100849. toString(fullDetails?: boolean): string;
  100850. }
  100851. }
  100852. declare module BABYLON {
  100853. /**
  100854. * Define an interface for all classes that will hold resources
  100855. */
  100856. export interface IDisposable {
  100857. /**
  100858. * Releases all held resources
  100859. */
  100860. dispose(): void;
  100861. }
  100862. /** Interface defining initialization parameters for Scene class */
  100863. export interface SceneOptions {
  100864. /**
  100865. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100866. * It will improve performance when the number of geometries becomes important.
  100867. */
  100868. useGeometryUniqueIdsMap?: boolean;
  100869. /**
  100870. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100871. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100872. */
  100873. useMaterialMeshMap?: boolean;
  100874. /**
  100875. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100876. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100877. */
  100878. useClonedMeshhMap?: boolean;
  100879. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100880. virtual?: boolean;
  100881. }
  100882. /**
  100883. * Represents a scene to be rendered by the engine.
  100884. * @see http://doc.babylonjs.com/features/scene
  100885. */
  100886. export class Scene extends AbstractScene implements IAnimatable {
  100887. /** The fog is deactivated */
  100888. static readonly FOGMODE_NONE: number;
  100889. /** The fog density is following an exponential function */
  100890. static readonly FOGMODE_EXP: number;
  100891. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100892. static readonly FOGMODE_EXP2: number;
  100893. /** The fog density is following a linear function. */
  100894. static readonly FOGMODE_LINEAR: number;
  100895. /**
  100896. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100898. */
  100899. static MinDeltaTime: number;
  100900. /**
  100901. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100903. */
  100904. static MaxDeltaTime: number;
  100905. /**
  100906. * Factory used to create the default material.
  100907. * @param name The name of the material to create
  100908. * @param scene The scene to create the material for
  100909. * @returns The default material
  100910. */
  100911. static DefaultMaterialFactory(scene: Scene): Material;
  100912. /**
  100913. * Factory used to create the a collision coordinator.
  100914. * @returns The collision coordinator
  100915. */
  100916. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100917. /** @hidden */
  100918. _inputManager: InputManager;
  100919. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100920. cameraToUseForPointers: Nullable<Camera>;
  100921. /** @hidden */
  100922. readonly _isScene: boolean;
  100923. /**
  100924. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100925. */
  100926. autoClear: boolean;
  100927. /**
  100928. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100929. */
  100930. autoClearDepthAndStencil: boolean;
  100931. /**
  100932. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100933. */
  100934. clearColor: Color4;
  100935. /**
  100936. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100937. */
  100938. ambientColor: Color3;
  100939. /**
  100940. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100941. * It should only be one of the following (if not the default embedded one):
  100942. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100943. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100944. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100945. * The material properties need to be setup according to the type of texture in use.
  100946. */
  100947. environmentBRDFTexture: BaseTexture;
  100948. /** @hidden */
  100949. protected _environmentTexture: Nullable<BaseTexture>;
  100950. /**
  100951. * Texture used in all pbr material as the reflection texture.
  100952. * As in the majority of the scene they are the same (exception for multi room and so on),
  100953. * this is easier to reference from here than from all the materials.
  100954. */
  100955. /**
  100956. * Texture used in all pbr material as the reflection texture.
  100957. * As in the majority of the scene they are the same (exception for multi room and so on),
  100958. * this is easier to set here than in all the materials.
  100959. */
  100960. environmentTexture: Nullable<BaseTexture>;
  100961. /** @hidden */
  100962. protected _environmentIntensity: number;
  100963. /**
  100964. * Intensity of the environment in all pbr material.
  100965. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100966. * As in the majority of the scene they are the same (exception for multi room and so on),
  100967. * this is easier to reference from here than from all the materials.
  100968. */
  100969. /**
  100970. * Intensity of the environment in all pbr material.
  100971. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100972. * As in the majority of the scene they are the same (exception for multi room and so on),
  100973. * this is easier to set here than in all the materials.
  100974. */
  100975. environmentIntensity: number;
  100976. /** @hidden */
  100977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100978. /**
  100979. * Default image processing configuration used either in the rendering
  100980. * Forward main pass or through the imageProcessingPostProcess if present.
  100981. * As in the majority of the scene they are the same (exception for multi camera),
  100982. * this is easier to reference from here than from all the materials and post process.
  100983. *
  100984. * No setter as we it is a shared configuration, you can set the values instead.
  100985. */
  100986. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100987. private _forceWireframe;
  100988. /**
  100989. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100990. */
  100991. forceWireframe: boolean;
  100992. private _forcePointsCloud;
  100993. /**
  100994. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100995. */
  100996. forcePointsCloud: boolean;
  100997. /**
  100998. * Gets or sets the active clipplane 1
  100999. */
  101000. clipPlane: Nullable<Plane>;
  101001. /**
  101002. * Gets or sets the active clipplane 2
  101003. */
  101004. clipPlane2: Nullable<Plane>;
  101005. /**
  101006. * Gets or sets the active clipplane 3
  101007. */
  101008. clipPlane3: Nullable<Plane>;
  101009. /**
  101010. * Gets or sets the active clipplane 4
  101011. */
  101012. clipPlane4: Nullable<Plane>;
  101013. /**
  101014. * Gets or sets a boolean indicating if animations are enabled
  101015. */
  101016. animationsEnabled: boolean;
  101017. private _animationPropertiesOverride;
  101018. /**
  101019. * Gets or sets the animation properties override
  101020. */
  101021. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101022. /**
  101023. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101024. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101025. */
  101026. useConstantAnimationDeltaTime: boolean;
  101027. /**
  101028. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101029. * Please note that it requires to run a ray cast through the scene on every frame
  101030. */
  101031. constantlyUpdateMeshUnderPointer: boolean;
  101032. /**
  101033. * Defines the HTML cursor to use when hovering over interactive elements
  101034. */
  101035. hoverCursor: string;
  101036. /**
  101037. * Defines the HTML default cursor to use (empty by default)
  101038. */
  101039. defaultCursor: string;
  101040. /**
  101041. * Defines wether cursors are handled by the scene.
  101042. */
  101043. doNotHandleCursors: boolean;
  101044. /**
  101045. * This is used to call preventDefault() on pointer down
  101046. * in order to block unwanted artifacts like system double clicks
  101047. */
  101048. preventDefaultOnPointerDown: boolean;
  101049. /**
  101050. * This is used to call preventDefault() on pointer up
  101051. * in order to block unwanted artifacts like system double clicks
  101052. */
  101053. preventDefaultOnPointerUp: boolean;
  101054. /**
  101055. * Gets or sets user defined metadata
  101056. */
  101057. metadata: any;
  101058. /**
  101059. * For internal use only. Please do not use.
  101060. */
  101061. reservedDataStore: any;
  101062. /**
  101063. * Gets the name of the plugin used to load this scene (null by default)
  101064. */
  101065. loadingPluginName: string;
  101066. /**
  101067. * Use this array to add regular expressions used to disable offline support for specific urls
  101068. */
  101069. disableOfflineSupportExceptionRules: RegExp[];
  101070. /**
  101071. * An event triggered when the scene is disposed.
  101072. */
  101073. onDisposeObservable: Observable<Scene>;
  101074. private _onDisposeObserver;
  101075. /** Sets a function to be executed when this scene is disposed. */
  101076. onDispose: () => void;
  101077. /**
  101078. * An event triggered before rendering the scene (right after animations and physics)
  101079. */
  101080. onBeforeRenderObservable: Observable<Scene>;
  101081. private _onBeforeRenderObserver;
  101082. /** Sets a function to be executed before rendering this scene */
  101083. beforeRender: Nullable<() => void>;
  101084. /**
  101085. * An event triggered after rendering the scene
  101086. */
  101087. onAfterRenderObservable: Observable<Scene>;
  101088. /**
  101089. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101090. */
  101091. onAfterRenderCameraObservable: Observable<Camera>;
  101092. private _onAfterRenderObserver;
  101093. /** Sets a function to be executed after rendering this scene */
  101094. afterRender: Nullable<() => void>;
  101095. /**
  101096. * An event triggered before animating the scene
  101097. */
  101098. onBeforeAnimationsObservable: Observable<Scene>;
  101099. /**
  101100. * An event triggered after animations processing
  101101. */
  101102. onAfterAnimationsObservable: Observable<Scene>;
  101103. /**
  101104. * An event triggered before draw calls are ready to be sent
  101105. */
  101106. onBeforeDrawPhaseObservable: Observable<Scene>;
  101107. /**
  101108. * An event triggered after draw calls have been sent
  101109. */
  101110. onAfterDrawPhaseObservable: Observable<Scene>;
  101111. /**
  101112. * An event triggered when the scene is ready
  101113. */
  101114. onReadyObservable: Observable<Scene>;
  101115. /**
  101116. * An event triggered before rendering a camera
  101117. */
  101118. onBeforeCameraRenderObservable: Observable<Camera>;
  101119. private _onBeforeCameraRenderObserver;
  101120. /** Sets a function to be executed before rendering a camera*/
  101121. beforeCameraRender: () => void;
  101122. /**
  101123. * An event triggered after rendering a camera
  101124. */
  101125. onAfterCameraRenderObservable: Observable<Camera>;
  101126. private _onAfterCameraRenderObserver;
  101127. /** Sets a function to be executed after rendering a camera*/
  101128. afterCameraRender: () => void;
  101129. /**
  101130. * An event triggered when active meshes evaluation is about to start
  101131. */
  101132. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101133. /**
  101134. * An event triggered when active meshes evaluation is done
  101135. */
  101136. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101137. /**
  101138. * An event triggered when particles rendering is about to start
  101139. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101140. */
  101141. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101142. /**
  101143. * An event triggered when particles rendering is done
  101144. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101145. */
  101146. onAfterParticlesRenderingObservable: Observable<Scene>;
  101147. /**
  101148. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101149. */
  101150. onDataLoadedObservable: Observable<Scene>;
  101151. /**
  101152. * An event triggered when a camera is created
  101153. */
  101154. onNewCameraAddedObservable: Observable<Camera>;
  101155. /**
  101156. * An event triggered when a camera is removed
  101157. */
  101158. onCameraRemovedObservable: Observable<Camera>;
  101159. /**
  101160. * An event triggered when a light is created
  101161. */
  101162. onNewLightAddedObservable: Observable<Light>;
  101163. /**
  101164. * An event triggered when a light is removed
  101165. */
  101166. onLightRemovedObservable: Observable<Light>;
  101167. /**
  101168. * An event triggered when a geometry is created
  101169. */
  101170. onNewGeometryAddedObservable: Observable<Geometry>;
  101171. /**
  101172. * An event triggered when a geometry is removed
  101173. */
  101174. onGeometryRemovedObservable: Observable<Geometry>;
  101175. /**
  101176. * An event triggered when a transform node is created
  101177. */
  101178. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101179. /**
  101180. * An event triggered when a transform node is removed
  101181. */
  101182. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101183. /**
  101184. * An event triggered when a mesh is created
  101185. */
  101186. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101187. /**
  101188. * An event triggered when a mesh is removed
  101189. */
  101190. onMeshRemovedObservable: Observable<AbstractMesh>;
  101191. /**
  101192. * An event triggered when a skeleton is created
  101193. */
  101194. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101195. /**
  101196. * An event triggered when a skeleton is removed
  101197. */
  101198. onSkeletonRemovedObservable: Observable<Skeleton>;
  101199. /**
  101200. * An event triggered when a material is created
  101201. */
  101202. onNewMaterialAddedObservable: Observable<Material>;
  101203. /**
  101204. * An event triggered when a material is removed
  101205. */
  101206. onMaterialRemovedObservable: Observable<Material>;
  101207. /**
  101208. * An event triggered when a texture is created
  101209. */
  101210. onNewTextureAddedObservable: Observable<BaseTexture>;
  101211. /**
  101212. * An event triggered when a texture is removed
  101213. */
  101214. onTextureRemovedObservable: Observable<BaseTexture>;
  101215. /**
  101216. * An event triggered when render targets are about to be rendered
  101217. * Can happen multiple times per frame.
  101218. */
  101219. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101220. /**
  101221. * An event triggered when render targets were rendered.
  101222. * Can happen multiple times per frame.
  101223. */
  101224. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101225. /**
  101226. * An event triggered before calculating deterministic simulation step
  101227. */
  101228. onBeforeStepObservable: Observable<Scene>;
  101229. /**
  101230. * An event triggered after calculating deterministic simulation step
  101231. */
  101232. onAfterStepObservable: Observable<Scene>;
  101233. /**
  101234. * An event triggered when the activeCamera property is updated
  101235. */
  101236. onActiveCameraChanged: Observable<Scene>;
  101237. /**
  101238. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101239. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101240. * 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)
  101241. */
  101242. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101243. /**
  101244. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101245. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101246. * 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)
  101247. */
  101248. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101249. /**
  101250. * This Observable will when a mesh has been imported into the scene.
  101251. */
  101252. onMeshImportedObservable: Observable<AbstractMesh>;
  101253. /**
  101254. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101255. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101256. */
  101257. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101258. /** @hidden */
  101259. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101260. /**
  101261. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101262. */
  101263. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101264. /**
  101265. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101266. */
  101267. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101268. /**
  101269. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101270. */
  101271. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101272. /** Callback called when a pointer move is detected */
  101273. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101274. /** Callback called when a pointer down is detected */
  101275. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101276. /** Callback called when a pointer up is detected */
  101277. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101278. /** Callback called when a pointer pick is detected */
  101279. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101280. /**
  101281. * 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).
  101282. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101283. */
  101284. onPrePointerObservable: Observable<PointerInfoPre>;
  101285. /**
  101286. * Observable event triggered each time an input event is received from the rendering canvas
  101287. */
  101288. onPointerObservable: Observable<PointerInfo>;
  101289. /**
  101290. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101291. */
  101292. readonly unTranslatedPointer: Vector2;
  101293. /**
  101294. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101295. */
  101296. static DragMovementThreshold: number;
  101297. /**
  101298. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101299. */
  101300. static LongPressDelay: number;
  101301. /**
  101302. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101303. */
  101304. static DoubleClickDelay: number;
  101305. /** If you need to check double click without raising a single click at first click, enable this flag */
  101306. static ExclusiveDoubleClickMode: boolean;
  101307. /** @hidden */
  101308. _mirroredCameraPosition: Nullable<Vector3>;
  101309. /**
  101310. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101311. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101312. */
  101313. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101314. /**
  101315. * Observable event triggered each time an keyboard event is received from the hosting window
  101316. */
  101317. onKeyboardObservable: Observable<KeyboardInfo>;
  101318. private _useRightHandedSystem;
  101319. /**
  101320. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101321. */
  101322. useRightHandedSystem: boolean;
  101323. private _timeAccumulator;
  101324. private _currentStepId;
  101325. private _currentInternalStep;
  101326. /**
  101327. * Sets the step Id used by deterministic lock step
  101328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101329. * @param newStepId defines the step Id
  101330. */
  101331. setStepId(newStepId: number): void;
  101332. /**
  101333. * Gets the step Id used by deterministic lock step
  101334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101335. * @returns the step Id
  101336. */
  101337. getStepId(): number;
  101338. /**
  101339. * Gets the internal step used by deterministic lock step
  101340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101341. * @returns the internal step
  101342. */
  101343. getInternalStep(): number;
  101344. private _fogEnabled;
  101345. /**
  101346. * Gets or sets a boolean indicating if fog is enabled on this scene
  101347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101348. * (Default is true)
  101349. */
  101350. fogEnabled: boolean;
  101351. private _fogMode;
  101352. /**
  101353. * Gets or sets the fog mode to use
  101354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101355. * | mode | value |
  101356. * | --- | --- |
  101357. * | FOGMODE_NONE | 0 |
  101358. * | FOGMODE_EXP | 1 |
  101359. * | FOGMODE_EXP2 | 2 |
  101360. * | FOGMODE_LINEAR | 3 |
  101361. */
  101362. fogMode: number;
  101363. /**
  101364. * Gets or sets the fog color to use
  101365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101366. * (Default is Color3(0.2, 0.2, 0.3))
  101367. */
  101368. fogColor: Color3;
  101369. /**
  101370. * Gets or sets the fog density to use
  101371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101372. * (Default is 0.1)
  101373. */
  101374. fogDensity: number;
  101375. /**
  101376. * Gets or sets the fog start distance to use
  101377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101378. * (Default is 0)
  101379. */
  101380. fogStart: number;
  101381. /**
  101382. * Gets or sets the fog end distance to use
  101383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101384. * (Default is 1000)
  101385. */
  101386. fogEnd: number;
  101387. private _shadowsEnabled;
  101388. /**
  101389. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101390. */
  101391. shadowsEnabled: boolean;
  101392. private _lightsEnabled;
  101393. /**
  101394. * Gets or sets a boolean indicating if lights are enabled on this scene
  101395. */
  101396. lightsEnabled: boolean;
  101397. /** All of the active cameras added to this scene. */
  101398. activeCameras: Camera[];
  101399. /** @hidden */
  101400. _activeCamera: Nullable<Camera>;
  101401. /** Gets or sets the current active camera */
  101402. activeCamera: Nullable<Camera>;
  101403. private _defaultMaterial;
  101404. /** The default material used on meshes when no material is affected */
  101405. /** The default material used on meshes when no material is affected */
  101406. defaultMaterial: Material;
  101407. private _texturesEnabled;
  101408. /**
  101409. * Gets or sets a boolean indicating if textures are enabled on this scene
  101410. */
  101411. texturesEnabled: boolean;
  101412. /**
  101413. * Gets or sets a boolean indicating if particles are enabled on this scene
  101414. */
  101415. particlesEnabled: boolean;
  101416. /**
  101417. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101418. */
  101419. spritesEnabled: boolean;
  101420. private _skeletonsEnabled;
  101421. /**
  101422. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101423. */
  101424. skeletonsEnabled: boolean;
  101425. /**
  101426. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101427. */
  101428. lensFlaresEnabled: boolean;
  101429. /**
  101430. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101432. */
  101433. collisionsEnabled: boolean;
  101434. private _collisionCoordinator;
  101435. /** @hidden */
  101436. readonly collisionCoordinator: ICollisionCoordinator;
  101437. /**
  101438. * Defines the gravity applied to this scene (used only for collisions)
  101439. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101440. */
  101441. gravity: Vector3;
  101442. /**
  101443. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101444. */
  101445. postProcessesEnabled: boolean;
  101446. /**
  101447. * The list of postprocesses added to the scene
  101448. */
  101449. postProcesses: PostProcess[];
  101450. /**
  101451. * Gets the current postprocess manager
  101452. */
  101453. postProcessManager: PostProcessManager;
  101454. /**
  101455. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101456. */
  101457. renderTargetsEnabled: boolean;
  101458. /**
  101459. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101460. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101461. */
  101462. dumpNextRenderTargets: boolean;
  101463. /**
  101464. * The list of user defined render targets added to the scene
  101465. */
  101466. customRenderTargets: RenderTargetTexture[];
  101467. /**
  101468. * Defines if texture loading must be delayed
  101469. * If true, textures will only be loaded when they need to be rendered
  101470. */
  101471. useDelayedTextureLoading: boolean;
  101472. /**
  101473. * Gets the list of meshes imported to the scene through SceneLoader
  101474. */
  101475. importedMeshesFiles: String[];
  101476. /**
  101477. * Gets or sets a boolean indicating if probes are enabled on this scene
  101478. */
  101479. probesEnabled: boolean;
  101480. /**
  101481. * Gets or sets the current offline provider to use to store scene data
  101482. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101483. */
  101484. offlineProvider: IOfflineProvider;
  101485. /**
  101486. * Gets or sets the action manager associated with the scene
  101487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101488. */
  101489. actionManager: AbstractActionManager;
  101490. private _meshesForIntersections;
  101491. /**
  101492. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101493. */
  101494. proceduralTexturesEnabled: boolean;
  101495. private _engine;
  101496. private _totalVertices;
  101497. /** @hidden */
  101498. _activeIndices: PerfCounter;
  101499. /** @hidden */
  101500. _activeParticles: PerfCounter;
  101501. /** @hidden */
  101502. _activeBones: PerfCounter;
  101503. private _animationRatio;
  101504. /** @hidden */
  101505. _animationTimeLast: number;
  101506. /** @hidden */
  101507. _animationTime: number;
  101508. /**
  101509. * Gets or sets a general scale for animation speed
  101510. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101511. */
  101512. animationTimeScale: number;
  101513. /** @hidden */
  101514. _cachedMaterial: Nullable<Material>;
  101515. /** @hidden */
  101516. _cachedEffect: Nullable<Effect>;
  101517. /** @hidden */
  101518. _cachedVisibility: Nullable<number>;
  101519. private _renderId;
  101520. private _frameId;
  101521. private _executeWhenReadyTimeoutId;
  101522. private _intermediateRendering;
  101523. private _viewUpdateFlag;
  101524. private _projectionUpdateFlag;
  101525. /** @hidden */
  101526. _toBeDisposed: Nullable<IDisposable>[];
  101527. private _activeRequests;
  101528. /** @hidden */
  101529. _pendingData: any[];
  101530. private _isDisposed;
  101531. /**
  101532. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101533. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101534. */
  101535. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101536. private _activeMeshes;
  101537. private _processedMaterials;
  101538. private _renderTargets;
  101539. /** @hidden */
  101540. _activeParticleSystems: SmartArray<IParticleSystem>;
  101541. private _activeSkeletons;
  101542. private _softwareSkinnedMeshes;
  101543. private _renderingManager;
  101544. /** @hidden */
  101545. _activeAnimatables: Animatable[];
  101546. private _transformMatrix;
  101547. private _sceneUbo;
  101548. /** @hidden */
  101549. _viewMatrix: Matrix;
  101550. private _projectionMatrix;
  101551. /** @hidden */
  101552. _forcedViewPosition: Nullable<Vector3>;
  101553. /** @hidden */
  101554. _frustumPlanes: Plane[];
  101555. /**
  101556. * Gets the list of frustum planes (built from the active camera)
  101557. */
  101558. readonly frustumPlanes: Plane[];
  101559. /**
  101560. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101561. * This is useful if there are more lights that the maximum simulteanous authorized
  101562. */
  101563. requireLightSorting: boolean;
  101564. /** @hidden */
  101565. readonly useMaterialMeshMap: boolean;
  101566. /** @hidden */
  101567. readonly useClonedMeshhMap: boolean;
  101568. private _externalData;
  101569. private _uid;
  101570. /**
  101571. * @hidden
  101572. * Backing store of defined scene components.
  101573. */
  101574. _components: ISceneComponent[];
  101575. /**
  101576. * @hidden
  101577. * Backing store of defined scene components.
  101578. */
  101579. _serializableComponents: ISceneSerializableComponent[];
  101580. /**
  101581. * List of components to register on the next registration step.
  101582. */
  101583. private _transientComponents;
  101584. /**
  101585. * Registers the transient components if needed.
  101586. */
  101587. private _registerTransientComponents;
  101588. /**
  101589. * @hidden
  101590. * Add a component to the scene.
  101591. * Note that the ccomponent could be registered on th next frame if this is called after
  101592. * the register component stage.
  101593. * @param component Defines the component to add to the scene
  101594. */
  101595. _addComponent(component: ISceneComponent): void;
  101596. /**
  101597. * @hidden
  101598. * Gets a component from the scene.
  101599. * @param name defines the name of the component to retrieve
  101600. * @returns the component or null if not present
  101601. */
  101602. _getComponent(name: string): Nullable<ISceneComponent>;
  101603. /**
  101604. * @hidden
  101605. * Defines the actions happening before camera updates.
  101606. */
  101607. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101608. /**
  101609. * @hidden
  101610. * Defines the actions happening before clear the canvas.
  101611. */
  101612. _beforeClearStage: Stage<SimpleStageAction>;
  101613. /**
  101614. * @hidden
  101615. * Defines the actions when collecting render targets for the frame.
  101616. */
  101617. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101618. /**
  101619. * @hidden
  101620. * Defines the actions happening for one camera in the frame.
  101621. */
  101622. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101623. /**
  101624. * @hidden
  101625. * Defines the actions happening during the per mesh ready checks.
  101626. */
  101627. _isReadyForMeshStage: Stage<MeshStageAction>;
  101628. /**
  101629. * @hidden
  101630. * Defines the actions happening before evaluate active mesh checks.
  101631. */
  101632. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101633. /**
  101634. * @hidden
  101635. * Defines the actions happening during the evaluate sub mesh checks.
  101636. */
  101637. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101638. /**
  101639. * @hidden
  101640. * Defines the actions happening during the active mesh stage.
  101641. */
  101642. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101643. /**
  101644. * @hidden
  101645. * Defines the actions happening during the per camera render target step.
  101646. */
  101647. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101648. /**
  101649. * @hidden
  101650. * Defines the actions happening just before the active camera is drawing.
  101651. */
  101652. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101653. /**
  101654. * @hidden
  101655. * Defines the actions happening just before a render target is drawing.
  101656. */
  101657. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101658. /**
  101659. * @hidden
  101660. * Defines the actions happening just before a rendering group is drawing.
  101661. */
  101662. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101663. /**
  101664. * @hidden
  101665. * Defines the actions happening just before a mesh is drawing.
  101666. */
  101667. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101668. /**
  101669. * @hidden
  101670. * Defines the actions happening just after a mesh has been drawn.
  101671. */
  101672. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101673. /**
  101674. * @hidden
  101675. * Defines the actions happening just after a rendering group has been drawn.
  101676. */
  101677. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101678. /**
  101679. * @hidden
  101680. * Defines the actions happening just after the active camera has been drawn.
  101681. */
  101682. _afterCameraDrawStage: Stage<CameraStageAction>;
  101683. /**
  101684. * @hidden
  101685. * Defines the actions happening just after a render target has been drawn.
  101686. */
  101687. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101688. /**
  101689. * @hidden
  101690. * Defines the actions happening just after rendering all cameras and computing intersections.
  101691. */
  101692. _afterRenderStage: Stage<SimpleStageAction>;
  101693. /**
  101694. * @hidden
  101695. * Defines the actions happening when a pointer move event happens.
  101696. */
  101697. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101698. /**
  101699. * @hidden
  101700. * Defines the actions happening when a pointer down event happens.
  101701. */
  101702. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101703. /**
  101704. * @hidden
  101705. * Defines the actions happening when a pointer up event happens.
  101706. */
  101707. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101708. /**
  101709. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101710. */
  101711. private geometriesByUniqueId;
  101712. /**
  101713. * Creates a new Scene
  101714. * @param engine defines the engine to use to render this scene
  101715. * @param options defines the scene options
  101716. */
  101717. constructor(engine: Engine, options?: SceneOptions);
  101718. /**
  101719. * Gets a string idenfifying the name of the class
  101720. * @returns "Scene" string
  101721. */
  101722. getClassName(): string;
  101723. private _defaultMeshCandidates;
  101724. /**
  101725. * @hidden
  101726. */
  101727. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101728. private _defaultSubMeshCandidates;
  101729. /**
  101730. * @hidden
  101731. */
  101732. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101733. /**
  101734. * Sets the default candidate providers for the scene.
  101735. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101736. * and getCollidingSubMeshCandidates to their default function
  101737. */
  101738. setDefaultCandidateProviders(): void;
  101739. /**
  101740. * Gets the mesh that is currently under the pointer
  101741. */
  101742. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101743. /**
  101744. * Gets or sets the current on-screen X position of the pointer
  101745. */
  101746. pointerX: number;
  101747. /**
  101748. * Gets or sets the current on-screen Y position of the pointer
  101749. */
  101750. pointerY: number;
  101751. /**
  101752. * Gets the cached material (ie. the latest rendered one)
  101753. * @returns the cached material
  101754. */
  101755. getCachedMaterial(): Nullable<Material>;
  101756. /**
  101757. * Gets the cached effect (ie. the latest rendered one)
  101758. * @returns the cached effect
  101759. */
  101760. getCachedEffect(): Nullable<Effect>;
  101761. /**
  101762. * Gets the cached visibility state (ie. the latest rendered one)
  101763. * @returns the cached visibility state
  101764. */
  101765. getCachedVisibility(): Nullable<number>;
  101766. /**
  101767. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101768. * @param material defines the current material
  101769. * @param effect defines the current effect
  101770. * @param visibility defines the current visibility state
  101771. * @returns true if one parameter is not cached
  101772. */
  101773. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101774. /**
  101775. * Gets the engine associated with the scene
  101776. * @returns an Engine
  101777. */
  101778. getEngine(): Engine;
  101779. /**
  101780. * Gets the total number of vertices rendered per frame
  101781. * @returns the total number of vertices rendered per frame
  101782. */
  101783. getTotalVertices(): number;
  101784. /**
  101785. * Gets the performance counter for total vertices
  101786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101787. */
  101788. readonly totalVerticesPerfCounter: PerfCounter;
  101789. /**
  101790. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101791. * @returns the total number of active indices rendered per frame
  101792. */
  101793. getActiveIndices(): number;
  101794. /**
  101795. * Gets the performance counter for active indices
  101796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101797. */
  101798. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101799. /**
  101800. * Gets the total number of active particles rendered per frame
  101801. * @returns the total number of active particles rendered per frame
  101802. */
  101803. getActiveParticles(): number;
  101804. /**
  101805. * Gets the performance counter for active particles
  101806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101807. */
  101808. readonly activeParticlesPerfCounter: PerfCounter;
  101809. /**
  101810. * Gets the total number of active bones rendered per frame
  101811. * @returns the total number of active bones rendered per frame
  101812. */
  101813. getActiveBones(): number;
  101814. /**
  101815. * Gets the performance counter for active bones
  101816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101817. */
  101818. readonly activeBonesPerfCounter: PerfCounter;
  101819. /**
  101820. * Gets the array of active meshes
  101821. * @returns an array of AbstractMesh
  101822. */
  101823. getActiveMeshes(): SmartArray<AbstractMesh>;
  101824. /**
  101825. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101826. * @returns a number
  101827. */
  101828. getAnimationRatio(): number;
  101829. /**
  101830. * Gets an unique Id for the current render phase
  101831. * @returns a number
  101832. */
  101833. getRenderId(): number;
  101834. /**
  101835. * Gets an unique Id for the current frame
  101836. * @returns a number
  101837. */
  101838. getFrameId(): number;
  101839. /** Call this function if you want to manually increment the render Id*/
  101840. incrementRenderId(): void;
  101841. private _createUbo;
  101842. /**
  101843. * Use this method to simulate a pointer move on a mesh
  101844. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101845. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101846. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101847. * @returns the current scene
  101848. */
  101849. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101850. /**
  101851. * Use this method to simulate a pointer down on a mesh
  101852. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101853. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101854. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101855. * @returns the current scene
  101856. */
  101857. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101858. /**
  101859. * Use this method to simulate a pointer up on a mesh
  101860. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101861. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101862. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101863. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101864. * @returns the current scene
  101865. */
  101866. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101867. /**
  101868. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101869. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101870. * @returns true if the pointer was captured
  101871. */
  101872. isPointerCaptured(pointerId?: number): boolean;
  101873. /**
  101874. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101875. * @param attachUp defines if you want to attach events to pointerup
  101876. * @param attachDown defines if you want to attach events to pointerdown
  101877. * @param attachMove defines if you want to attach events to pointermove
  101878. */
  101879. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101880. /** Detaches all event handlers*/
  101881. detachControl(): void;
  101882. /**
  101883. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101884. * Delay loaded resources are not taking in account
  101885. * @return true if all required resources are ready
  101886. */
  101887. isReady(): boolean;
  101888. /** Resets all cached information relative to material (including effect and visibility) */
  101889. resetCachedMaterial(): void;
  101890. /**
  101891. * Registers a function to be called before every frame render
  101892. * @param func defines the function to register
  101893. */
  101894. registerBeforeRender(func: () => void): void;
  101895. /**
  101896. * Unregisters a function called before every frame render
  101897. * @param func defines the function to unregister
  101898. */
  101899. unregisterBeforeRender(func: () => void): void;
  101900. /**
  101901. * Registers a function to be called after every frame render
  101902. * @param func defines the function to register
  101903. */
  101904. registerAfterRender(func: () => void): void;
  101905. /**
  101906. * Unregisters a function called after every frame render
  101907. * @param func defines the function to unregister
  101908. */
  101909. unregisterAfterRender(func: () => void): void;
  101910. private _executeOnceBeforeRender;
  101911. /**
  101912. * The provided function will run before render once and will be disposed afterwards.
  101913. * A timeout delay can be provided so that the function will be executed in N ms.
  101914. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101915. * @param func The function to be executed.
  101916. * @param timeout optional delay in ms
  101917. */
  101918. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101919. /** @hidden */
  101920. _addPendingData(data: any): void;
  101921. /** @hidden */
  101922. _removePendingData(data: any): void;
  101923. /**
  101924. * Returns the number of items waiting to be loaded
  101925. * @returns the number of items waiting to be loaded
  101926. */
  101927. getWaitingItemsCount(): number;
  101928. /**
  101929. * Returns a boolean indicating if the scene is still loading data
  101930. */
  101931. readonly isLoading: boolean;
  101932. /**
  101933. * Registers a function to be executed when the scene is ready
  101934. * @param {Function} func - the function to be executed
  101935. */
  101936. executeWhenReady(func: () => void): void;
  101937. /**
  101938. * Returns a promise that resolves when the scene is ready
  101939. * @returns A promise that resolves when the scene is ready
  101940. */
  101941. whenReadyAsync(): Promise<void>;
  101942. /** @hidden */
  101943. _checkIsReady(): void;
  101944. /**
  101945. * Gets all animatable attached to the scene
  101946. */
  101947. readonly animatables: Animatable[];
  101948. /**
  101949. * Resets the last animation time frame.
  101950. * Useful to override when animations start running when loading a scene for the first time.
  101951. */
  101952. resetLastAnimationTimeFrame(): void;
  101953. /**
  101954. * Gets the current view matrix
  101955. * @returns a Matrix
  101956. */
  101957. getViewMatrix(): Matrix;
  101958. /**
  101959. * Gets the current projection matrix
  101960. * @returns a Matrix
  101961. */
  101962. getProjectionMatrix(): Matrix;
  101963. /**
  101964. * Gets the current transform matrix
  101965. * @returns a Matrix made of View * Projection
  101966. */
  101967. getTransformMatrix(): Matrix;
  101968. /**
  101969. * Sets the current transform matrix
  101970. * @param viewL defines the View matrix to use
  101971. * @param projectionL defines the Projection matrix to use
  101972. * @param viewR defines the right View matrix to use (if provided)
  101973. * @param projectionR defines the right Projection matrix to use (if provided)
  101974. */
  101975. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101976. /**
  101977. * Gets the uniform buffer used to store scene data
  101978. * @returns a UniformBuffer
  101979. */
  101980. getSceneUniformBuffer(): UniformBuffer;
  101981. /**
  101982. * Gets an unique (relatively to the current scene) Id
  101983. * @returns an unique number for the scene
  101984. */
  101985. getUniqueId(): number;
  101986. /**
  101987. * Add a mesh to the list of scene's meshes
  101988. * @param newMesh defines the mesh to add
  101989. * @param recursive if all child meshes should also be added to the scene
  101990. */
  101991. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101992. /**
  101993. * Remove a mesh for the list of scene's meshes
  101994. * @param toRemove defines the mesh to remove
  101995. * @param recursive if all child meshes should also be removed from the scene
  101996. * @returns the index where the mesh was in the mesh list
  101997. */
  101998. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101999. /**
  102000. * Add a transform node to the list of scene's transform nodes
  102001. * @param newTransformNode defines the transform node to add
  102002. */
  102003. addTransformNode(newTransformNode: TransformNode): void;
  102004. /**
  102005. * Remove a transform node for the list of scene's transform nodes
  102006. * @param toRemove defines the transform node to remove
  102007. * @returns the index where the transform node was in the transform node list
  102008. */
  102009. removeTransformNode(toRemove: TransformNode): number;
  102010. /**
  102011. * Remove a skeleton for the list of scene's skeletons
  102012. * @param toRemove defines the skeleton to remove
  102013. * @returns the index where the skeleton was in the skeleton list
  102014. */
  102015. removeSkeleton(toRemove: Skeleton): number;
  102016. /**
  102017. * Remove a morph target for the list of scene's morph targets
  102018. * @param toRemove defines the morph target to remove
  102019. * @returns the index where the morph target was in the morph target list
  102020. */
  102021. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102022. /**
  102023. * Remove a light for the list of scene's lights
  102024. * @param toRemove defines the light to remove
  102025. * @returns the index where the light was in the light list
  102026. */
  102027. removeLight(toRemove: Light): number;
  102028. /**
  102029. * Remove a camera for the list of scene's cameras
  102030. * @param toRemove defines the camera to remove
  102031. * @returns the index where the camera was in the camera list
  102032. */
  102033. removeCamera(toRemove: Camera): number;
  102034. /**
  102035. * Remove a particle system for the list of scene's particle systems
  102036. * @param toRemove defines the particle system to remove
  102037. * @returns the index where the particle system was in the particle system list
  102038. */
  102039. removeParticleSystem(toRemove: IParticleSystem): number;
  102040. /**
  102041. * Remove a animation for the list of scene's animations
  102042. * @param toRemove defines the animation to remove
  102043. * @returns the index where the animation was in the animation list
  102044. */
  102045. removeAnimation(toRemove: Animation): number;
  102046. /**
  102047. * Will stop the animation of the given target
  102048. * @param target - the target
  102049. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102050. * @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)
  102051. */
  102052. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102053. /**
  102054. * Removes the given animation group from this scene.
  102055. * @param toRemove The animation group to remove
  102056. * @returns The index of the removed animation group
  102057. */
  102058. removeAnimationGroup(toRemove: AnimationGroup): number;
  102059. /**
  102060. * Removes the given multi-material from this scene.
  102061. * @param toRemove The multi-material to remove
  102062. * @returns The index of the removed multi-material
  102063. */
  102064. removeMultiMaterial(toRemove: MultiMaterial): number;
  102065. /**
  102066. * Removes the given material from this scene.
  102067. * @param toRemove The material to remove
  102068. * @returns The index of the removed material
  102069. */
  102070. removeMaterial(toRemove: Material): number;
  102071. /**
  102072. * Removes the given action manager from this scene.
  102073. * @param toRemove The action manager to remove
  102074. * @returns The index of the removed action manager
  102075. */
  102076. removeActionManager(toRemove: AbstractActionManager): number;
  102077. /**
  102078. * Removes the given texture from this scene.
  102079. * @param toRemove The texture to remove
  102080. * @returns The index of the removed texture
  102081. */
  102082. removeTexture(toRemove: BaseTexture): number;
  102083. /**
  102084. * Adds the given light to this scene
  102085. * @param newLight The light to add
  102086. */
  102087. addLight(newLight: Light): void;
  102088. /**
  102089. * Sorts the list list based on light priorities
  102090. */
  102091. sortLightsByPriority(): void;
  102092. /**
  102093. * Adds the given camera to this scene
  102094. * @param newCamera The camera to add
  102095. */
  102096. addCamera(newCamera: Camera): void;
  102097. /**
  102098. * Adds the given skeleton to this scene
  102099. * @param newSkeleton The skeleton to add
  102100. */
  102101. addSkeleton(newSkeleton: Skeleton): void;
  102102. /**
  102103. * Adds the given particle system to this scene
  102104. * @param newParticleSystem The particle system to add
  102105. */
  102106. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102107. /**
  102108. * Adds the given animation to this scene
  102109. * @param newAnimation The animation to add
  102110. */
  102111. addAnimation(newAnimation: Animation): void;
  102112. /**
  102113. * Adds the given animation group to this scene.
  102114. * @param newAnimationGroup The animation group to add
  102115. */
  102116. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102117. /**
  102118. * Adds the given multi-material to this scene
  102119. * @param newMultiMaterial The multi-material to add
  102120. */
  102121. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102122. /**
  102123. * Adds the given material to this scene
  102124. * @param newMaterial The material to add
  102125. */
  102126. addMaterial(newMaterial: Material): void;
  102127. /**
  102128. * Adds the given morph target to this scene
  102129. * @param newMorphTargetManager The morph target to add
  102130. */
  102131. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102132. /**
  102133. * Adds the given geometry to this scene
  102134. * @param newGeometry The geometry to add
  102135. */
  102136. addGeometry(newGeometry: Geometry): void;
  102137. /**
  102138. * Adds the given action manager to this scene
  102139. * @param newActionManager The action manager to add
  102140. */
  102141. addActionManager(newActionManager: AbstractActionManager): void;
  102142. /**
  102143. * Adds the given texture to this scene.
  102144. * @param newTexture The texture to add
  102145. */
  102146. addTexture(newTexture: BaseTexture): void;
  102147. /**
  102148. * Switch active camera
  102149. * @param newCamera defines the new active camera
  102150. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102151. */
  102152. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102153. /**
  102154. * sets the active camera of the scene using its ID
  102155. * @param id defines the camera's ID
  102156. * @return the new active camera or null if none found.
  102157. */
  102158. setActiveCameraByID(id: string): Nullable<Camera>;
  102159. /**
  102160. * sets the active camera of the scene using its name
  102161. * @param name defines the camera's name
  102162. * @returns the new active camera or null if none found.
  102163. */
  102164. setActiveCameraByName(name: string): Nullable<Camera>;
  102165. /**
  102166. * get an animation group using its name
  102167. * @param name defines the material's name
  102168. * @return the animation group or null if none found.
  102169. */
  102170. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102171. /**
  102172. * Get a material using its unique id
  102173. * @param uniqueId defines the material's unique id
  102174. * @return the material or null if none found.
  102175. */
  102176. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102177. /**
  102178. * get a material using its id
  102179. * @param id defines the material's ID
  102180. * @return the material or null if none found.
  102181. */
  102182. getMaterialByID(id: string): Nullable<Material>;
  102183. /**
  102184. * Gets a the last added material using a given id
  102185. * @param id defines the material's ID
  102186. * @return the last material with the given id or null if none found.
  102187. */
  102188. getLastMaterialByID(id: string): Nullable<Material>;
  102189. /**
  102190. * Gets a material using its name
  102191. * @param name defines the material's name
  102192. * @return the material or null if none found.
  102193. */
  102194. getMaterialByName(name: string): Nullable<Material>;
  102195. /**
  102196. * Get a texture using its unique id
  102197. * @param uniqueId defines the texture's unique id
  102198. * @return the texture or null if none found.
  102199. */
  102200. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102201. /**
  102202. * Gets a camera using its id
  102203. * @param id defines the id to look for
  102204. * @returns the camera or null if not found
  102205. */
  102206. getCameraByID(id: string): Nullable<Camera>;
  102207. /**
  102208. * Gets a camera using its unique id
  102209. * @param uniqueId defines the unique id to look for
  102210. * @returns the camera or null if not found
  102211. */
  102212. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102213. /**
  102214. * Gets a camera using its name
  102215. * @param name defines the camera's name
  102216. * @return the camera or null if none found.
  102217. */
  102218. getCameraByName(name: string): Nullable<Camera>;
  102219. /**
  102220. * Gets a bone using its id
  102221. * @param id defines the bone's id
  102222. * @return the bone or null if not found
  102223. */
  102224. getBoneByID(id: string): Nullable<Bone>;
  102225. /**
  102226. * Gets a bone using its id
  102227. * @param name defines the bone's name
  102228. * @return the bone or null if not found
  102229. */
  102230. getBoneByName(name: string): Nullable<Bone>;
  102231. /**
  102232. * Gets a light node using its name
  102233. * @param name defines the the light's name
  102234. * @return the light or null if none found.
  102235. */
  102236. getLightByName(name: string): Nullable<Light>;
  102237. /**
  102238. * Gets a light node using its id
  102239. * @param id defines the light's id
  102240. * @return the light or null if none found.
  102241. */
  102242. getLightByID(id: string): Nullable<Light>;
  102243. /**
  102244. * Gets a light node using its scene-generated unique ID
  102245. * @param uniqueId defines the light's unique id
  102246. * @return the light or null if none found.
  102247. */
  102248. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102249. /**
  102250. * Gets a particle system by id
  102251. * @param id defines the particle system id
  102252. * @return the corresponding system or null if none found
  102253. */
  102254. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102255. /**
  102256. * Gets a geometry using its ID
  102257. * @param id defines the geometry's id
  102258. * @return the geometry or null if none found.
  102259. */
  102260. getGeometryByID(id: string): Nullable<Geometry>;
  102261. private _getGeometryByUniqueID;
  102262. /**
  102263. * Add a new geometry to this scene
  102264. * @param geometry defines the geometry to be added to the scene.
  102265. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102266. * @return a boolean defining if the geometry was added or not
  102267. */
  102268. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102269. /**
  102270. * Removes an existing geometry
  102271. * @param geometry defines the geometry to be removed from the scene
  102272. * @return a boolean defining if the geometry was removed or not
  102273. */
  102274. removeGeometry(geometry: Geometry): boolean;
  102275. /**
  102276. * Gets the list of geometries attached to the scene
  102277. * @returns an array of Geometry
  102278. */
  102279. getGeometries(): Geometry[];
  102280. /**
  102281. * Gets the first added mesh found of a given ID
  102282. * @param id defines the id to search for
  102283. * @return the mesh found or null if not found at all
  102284. */
  102285. getMeshByID(id: string): Nullable<AbstractMesh>;
  102286. /**
  102287. * Gets a list of meshes using their id
  102288. * @param id defines the id to search for
  102289. * @returns a list of meshes
  102290. */
  102291. getMeshesByID(id: string): Array<AbstractMesh>;
  102292. /**
  102293. * Gets the first added transform node found of a given ID
  102294. * @param id defines the id to search for
  102295. * @return the found transform node or null if not found at all.
  102296. */
  102297. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102298. /**
  102299. * Gets a transform node with its auto-generated unique id
  102300. * @param uniqueId efines the unique id to search for
  102301. * @return the found transform node or null if not found at all.
  102302. */
  102303. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102304. /**
  102305. * Gets a list of transform nodes using their id
  102306. * @param id defines the id to search for
  102307. * @returns a list of transform nodes
  102308. */
  102309. getTransformNodesByID(id: string): Array<TransformNode>;
  102310. /**
  102311. * Gets a mesh with its auto-generated unique id
  102312. * @param uniqueId defines the unique id to search for
  102313. * @return the found mesh or null if not found at all.
  102314. */
  102315. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102316. /**
  102317. * Gets a the last added mesh using a given id
  102318. * @param id defines the id to search for
  102319. * @return the found mesh or null if not found at all.
  102320. */
  102321. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102322. /**
  102323. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102324. * @param id defines the id to search for
  102325. * @return the found node or null if not found at all
  102326. */
  102327. getLastEntryByID(id: string): Nullable<Node>;
  102328. /**
  102329. * Gets a node (Mesh, Camera, Light) using a given id
  102330. * @param id defines the id to search for
  102331. * @return the found node or null if not found at all
  102332. */
  102333. getNodeByID(id: string): Nullable<Node>;
  102334. /**
  102335. * Gets a node (Mesh, Camera, Light) using a given name
  102336. * @param name defines the name to search for
  102337. * @return the found node or null if not found at all.
  102338. */
  102339. getNodeByName(name: string): Nullable<Node>;
  102340. /**
  102341. * Gets a mesh using a given name
  102342. * @param name defines the name to search for
  102343. * @return the found mesh or null if not found at all.
  102344. */
  102345. getMeshByName(name: string): Nullable<AbstractMesh>;
  102346. /**
  102347. * Gets a transform node using a given name
  102348. * @param name defines the name to search for
  102349. * @return the found transform node or null if not found at all.
  102350. */
  102351. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102352. /**
  102353. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102354. * @param id defines the id to search for
  102355. * @return the found skeleton or null if not found at all.
  102356. */
  102357. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102358. /**
  102359. * Gets a skeleton using a given auto generated unique id
  102360. * @param uniqueId defines the unique id to search for
  102361. * @return the found skeleton or null if not found at all.
  102362. */
  102363. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102364. /**
  102365. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102366. * @param id defines the id to search for
  102367. * @return the found skeleton or null if not found at all.
  102368. */
  102369. getSkeletonById(id: string): Nullable<Skeleton>;
  102370. /**
  102371. * Gets a skeleton using a given name
  102372. * @param name defines the name to search for
  102373. * @return the found skeleton or null if not found at all.
  102374. */
  102375. getSkeletonByName(name: string): Nullable<Skeleton>;
  102376. /**
  102377. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102378. * @param id defines the id to search for
  102379. * @return the found morph target manager or null if not found at all.
  102380. */
  102381. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102382. /**
  102383. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102384. * @param id defines the id to search for
  102385. * @return the found morph target or null if not found at all.
  102386. */
  102387. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102388. /**
  102389. * Gets a boolean indicating if the given mesh is active
  102390. * @param mesh defines the mesh to look for
  102391. * @returns true if the mesh is in the active list
  102392. */
  102393. isActiveMesh(mesh: AbstractMesh): boolean;
  102394. /**
  102395. * Return a unique id as a string which can serve as an identifier for the scene
  102396. */
  102397. readonly uid: string;
  102398. /**
  102399. * Add an externaly attached data from its key.
  102400. * This method call will fail and return false, if such key already exists.
  102401. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102402. * @param key the unique key that identifies the data
  102403. * @param data the data object to associate to the key for this Engine instance
  102404. * @return true if no such key were already present and the data was added successfully, false otherwise
  102405. */
  102406. addExternalData<T>(key: string, data: T): boolean;
  102407. /**
  102408. * Get an externaly attached data from its key
  102409. * @param key the unique key that identifies the data
  102410. * @return the associated data, if present (can be null), or undefined if not present
  102411. */
  102412. getExternalData<T>(key: string): Nullable<T>;
  102413. /**
  102414. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102415. * @param key the unique key that identifies the data
  102416. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102417. * @return the associated data, can be null if the factory returned null.
  102418. */
  102419. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102420. /**
  102421. * Remove an externaly attached data from the Engine instance
  102422. * @param key the unique key that identifies the data
  102423. * @return true if the data was successfully removed, false if it doesn't exist
  102424. */
  102425. removeExternalData(key: string): boolean;
  102426. private _evaluateSubMesh;
  102427. /**
  102428. * Clear the processed materials smart array preventing retention point in material dispose.
  102429. */
  102430. freeProcessedMaterials(): void;
  102431. private _preventFreeActiveMeshesAndRenderingGroups;
  102432. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102433. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102434. * when disposing several meshes in a row or a hierarchy of meshes.
  102435. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102436. */
  102437. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102438. /**
  102439. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102440. */
  102441. freeActiveMeshes(): void;
  102442. /**
  102443. * Clear the info related to rendering groups preventing retention points during dispose.
  102444. */
  102445. freeRenderingGroups(): void;
  102446. /** @hidden */
  102447. _isInIntermediateRendering(): boolean;
  102448. /**
  102449. * Lambda returning the list of potentially active meshes.
  102450. */
  102451. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102452. /**
  102453. * Lambda returning the list of potentially active sub meshes.
  102454. */
  102455. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102456. /**
  102457. * Lambda returning the list of potentially intersecting sub meshes.
  102458. */
  102459. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102460. /**
  102461. * Lambda returning the list of potentially colliding sub meshes.
  102462. */
  102463. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102464. private _activeMeshesFrozen;
  102465. /**
  102466. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102467. * @returns the current scene
  102468. */
  102469. freezeActiveMeshes(): Scene;
  102470. /**
  102471. * Use this function to restart evaluating active meshes on every frame
  102472. * @returns the current scene
  102473. */
  102474. unfreezeActiveMeshes(): Scene;
  102475. private _evaluateActiveMeshes;
  102476. private _activeMesh;
  102477. /**
  102478. * Update the transform matrix to update from the current active camera
  102479. * @param force defines a boolean used to force the update even if cache is up to date
  102480. */
  102481. updateTransformMatrix(force?: boolean): void;
  102482. private _bindFrameBuffer;
  102483. /** @hidden */
  102484. _allowPostProcessClearColor: boolean;
  102485. /** @hidden */
  102486. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102487. private _processSubCameras;
  102488. private _checkIntersections;
  102489. /** @hidden */
  102490. _advancePhysicsEngineStep(step: number): void;
  102491. /**
  102492. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102493. */
  102494. getDeterministicFrameTime: () => number;
  102495. /** @hidden */
  102496. _animate(): void;
  102497. /** Execute all animations (for a frame) */
  102498. animate(): void;
  102499. /**
  102500. * Render the scene
  102501. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102502. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102503. */
  102504. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102505. /**
  102506. * Freeze all materials
  102507. * A frozen material will not be updatable but should be faster to render
  102508. */
  102509. freezeMaterials(): void;
  102510. /**
  102511. * Unfreeze all materials
  102512. * A frozen material will not be updatable but should be faster to render
  102513. */
  102514. unfreezeMaterials(): void;
  102515. /**
  102516. * Releases all held ressources
  102517. */
  102518. dispose(): void;
  102519. /**
  102520. * Gets if the scene is already disposed
  102521. */
  102522. readonly isDisposed: boolean;
  102523. /**
  102524. * Call this function to reduce memory footprint of the scene.
  102525. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102526. */
  102527. clearCachedVertexData(): void;
  102528. /**
  102529. * This function will remove the local cached buffer data from texture.
  102530. * It will save memory but will prevent the texture from being rebuilt
  102531. */
  102532. cleanCachedTextureBuffer(): void;
  102533. /**
  102534. * Get the world extend vectors with an optional filter
  102535. *
  102536. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102537. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102538. */
  102539. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102540. min: Vector3;
  102541. max: Vector3;
  102542. };
  102543. /**
  102544. * Creates a ray that can be used to pick in the scene
  102545. * @param x defines the x coordinate of the origin (on-screen)
  102546. * @param y defines the y coordinate of the origin (on-screen)
  102547. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102548. * @param camera defines the camera to use for the picking
  102549. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102550. * @returns a Ray
  102551. */
  102552. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102553. /**
  102554. * Creates a ray that can be used to pick in the scene
  102555. * @param x defines the x coordinate of the origin (on-screen)
  102556. * @param y defines the y coordinate of the origin (on-screen)
  102557. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102558. * @param result defines the ray where to store the picking ray
  102559. * @param camera defines the camera to use for the picking
  102560. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102561. * @returns the current scene
  102562. */
  102563. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102564. /**
  102565. * Creates a ray that can be used to pick in the scene
  102566. * @param x defines the x coordinate of the origin (on-screen)
  102567. * @param y defines the y coordinate of the origin (on-screen)
  102568. * @param camera defines the camera to use for the picking
  102569. * @returns a Ray
  102570. */
  102571. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102572. /**
  102573. * Creates a ray that can be used to pick in the scene
  102574. * @param x defines the x coordinate of the origin (on-screen)
  102575. * @param y defines the y coordinate of the origin (on-screen)
  102576. * @param result defines the ray where to store the picking ray
  102577. * @param camera defines the camera to use for the picking
  102578. * @returns the current scene
  102579. */
  102580. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102581. /** Launch a ray to try to pick a mesh in the scene
  102582. * @param x position on screen
  102583. * @param y position on screen
  102584. * @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
  102585. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102586. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102588. * @returns a PickingInfo
  102589. */
  102590. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102591. /** Use the given ray to pick a mesh in the scene
  102592. * @param ray The ray to use to pick meshes
  102593. * @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
  102594. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102596. * @returns a PickingInfo
  102597. */
  102598. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102599. /**
  102600. * Launch a ray to try to pick a mesh in the scene
  102601. * @param x X position on screen
  102602. * @param y Y position on screen
  102603. * @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
  102604. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102605. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102606. * @returns an array of PickingInfo
  102607. */
  102608. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102609. /**
  102610. * Launch a ray to try to pick a mesh in the scene
  102611. * @param ray Ray to use
  102612. * @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
  102613. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102614. * @returns an array of PickingInfo
  102615. */
  102616. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102617. /**
  102618. * Force the value of meshUnderPointer
  102619. * @param mesh defines the mesh to use
  102620. */
  102621. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102622. /**
  102623. * Gets the mesh under the pointer
  102624. * @returns a Mesh or null if no mesh is under the pointer
  102625. */
  102626. getPointerOverMesh(): Nullable<AbstractMesh>;
  102627. /** @hidden */
  102628. _rebuildGeometries(): void;
  102629. /** @hidden */
  102630. _rebuildTextures(): void;
  102631. private _getByTags;
  102632. /**
  102633. * Get a list of meshes by tags
  102634. * @param tagsQuery defines the tags query to use
  102635. * @param forEach defines a predicate used to filter results
  102636. * @returns an array of Mesh
  102637. */
  102638. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102639. /**
  102640. * Get a list of cameras by tags
  102641. * @param tagsQuery defines the tags query to use
  102642. * @param forEach defines a predicate used to filter results
  102643. * @returns an array of Camera
  102644. */
  102645. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102646. /**
  102647. * Get a list of lights by tags
  102648. * @param tagsQuery defines the tags query to use
  102649. * @param forEach defines a predicate used to filter results
  102650. * @returns an array of Light
  102651. */
  102652. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102653. /**
  102654. * Get a list of materials by tags
  102655. * @param tagsQuery defines the tags query to use
  102656. * @param forEach defines a predicate used to filter results
  102657. * @returns an array of Material
  102658. */
  102659. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102660. /**
  102661. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102662. * This allowed control for front to back rendering or reversly depending of the special needs.
  102663. *
  102664. * @param renderingGroupId The rendering group id corresponding to its index
  102665. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102666. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102667. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102668. */
  102669. 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;
  102670. /**
  102671. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102672. *
  102673. * @param renderingGroupId The rendering group id corresponding to its index
  102674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102675. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102676. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102677. */
  102678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102679. /**
  102680. * Gets the current auto clear configuration for one rendering group of the rendering
  102681. * manager.
  102682. * @param index the rendering group index to get the information for
  102683. * @returns The auto clear setup for the requested rendering group
  102684. */
  102685. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102686. private _blockMaterialDirtyMechanism;
  102687. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102688. blockMaterialDirtyMechanism: boolean;
  102689. /**
  102690. * Will flag all materials as dirty to trigger new shader compilation
  102691. * @param flag defines the flag used to specify which material part must be marked as dirty
  102692. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102693. */
  102694. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102695. /** @hidden */
  102696. _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;
  102697. /** @hidden */
  102698. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102699. /** @hidden */
  102700. _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;
  102701. /** @hidden */
  102702. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102703. /** @hidden */
  102704. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102705. /** @hidden */
  102706. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102707. }
  102708. }
  102709. declare module BABYLON {
  102710. /**
  102711. * Set of assets to keep when moving a scene into an asset container.
  102712. */
  102713. export class KeepAssets extends AbstractScene {
  102714. }
  102715. /**
  102716. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  102717. */
  102718. export class InstantiatedEntries {
  102719. /**
  102720. * List of new root nodes (eg. nodes with no parent)
  102721. */
  102722. rootNodes: TransformNode[];
  102723. /**
  102724. * List of new skeletons
  102725. */
  102726. skeletons: Skeleton[];
  102727. /**
  102728. * List of new animation groups
  102729. */
  102730. animationGroups: AnimationGroup[];
  102731. }
  102732. /**
  102733. * Container with a set of assets that can be added or removed from a scene.
  102734. */
  102735. export class AssetContainer extends AbstractScene {
  102736. /**
  102737. * The scene the AssetContainer belongs to.
  102738. */
  102739. scene: Scene;
  102740. /**
  102741. * Instantiates an AssetContainer.
  102742. * @param scene The scene the AssetContainer belongs to.
  102743. */
  102744. constructor(scene: Scene);
  102745. /**
  102746. * Instantiate or clone all meshes and add the new ones to the scene.
  102747. * Skeletons and animation groups will all be cloned
  102748. * @param nameFunction defines an optional function used to get new names for clones
  102749. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  102750. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  102751. */
  102752. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  102753. /**
  102754. * Adds all the assets from the container to the scene.
  102755. */
  102756. addAllToScene(): void;
  102757. /**
  102758. * Removes all the assets in the container from the scene
  102759. */
  102760. removeAllFromScene(): void;
  102761. /**
  102762. * Disposes all the assets in the container
  102763. */
  102764. dispose(): void;
  102765. private _moveAssets;
  102766. /**
  102767. * Removes all the assets contained in the scene and adds them to the container.
  102768. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102769. */
  102770. moveAllFromScene(keepAssets?: KeepAssets): void;
  102771. /**
  102772. * 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.
  102773. * @returns the root mesh
  102774. */
  102775. createRootMesh(): Mesh;
  102776. }
  102777. }
  102778. declare module BABYLON {
  102779. /**
  102780. * Defines how the parser contract is defined.
  102781. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102782. */
  102783. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102784. /**
  102785. * Defines how the individual parser contract is defined.
  102786. * These parser can parse an individual asset
  102787. */
  102788. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102789. /**
  102790. * Base class of the scene acting as a container for the different elements composing a scene.
  102791. * This class is dynamically extended by the different components of the scene increasing
  102792. * flexibility and reducing coupling
  102793. */
  102794. export abstract class AbstractScene {
  102795. /**
  102796. * Stores the list of available parsers in the application.
  102797. */
  102798. private static _BabylonFileParsers;
  102799. /**
  102800. * Stores the list of available individual parsers in the application.
  102801. */
  102802. private static _IndividualBabylonFileParsers;
  102803. /**
  102804. * Adds a parser in the list of available ones
  102805. * @param name Defines the name of the parser
  102806. * @param parser Defines the parser to add
  102807. */
  102808. static AddParser(name: string, parser: BabylonFileParser): void;
  102809. /**
  102810. * Gets a general parser from the list of avaialble ones
  102811. * @param name Defines the name of the parser
  102812. * @returns the requested parser or null
  102813. */
  102814. static GetParser(name: string): Nullable<BabylonFileParser>;
  102815. /**
  102816. * Adds n individual parser in the list of available ones
  102817. * @param name Defines the name of the parser
  102818. * @param parser Defines the parser to add
  102819. */
  102820. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102821. /**
  102822. * Gets an individual parser from the list of avaialble ones
  102823. * @param name Defines the name of the parser
  102824. * @returns the requested parser or null
  102825. */
  102826. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102827. /**
  102828. * Parser json data and populate both a scene and its associated container object
  102829. * @param jsonData Defines the data to parse
  102830. * @param scene Defines the scene to parse the data for
  102831. * @param container Defines the container attached to the parsing sequence
  102832. * @param rootUrl Defines the root url of the data
  102833. */
  102834. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102835. /**
  102836. * Gets the list of root nodes (ie. nodes with no parent)
  102837. */
  102838. rootNodes: Node[];
  102839. /** All of the cameras added to this scene
  102840. * @see http://doc.babylonjs.com/babylon101/cameras
  102841. */
  102842. cameras: Camera[];
  102843. /**
  102844. * All of the lights added to this scene
  102845. * @see http://doc.babylonjs.com/babylon101/lights
  102846. */
  102847. lights: Light[];
  102848. /**
  102849. * All of the (abstract) meshes added to this scene
  102850. */
  102851. meshes: AbstractMesh[];
  102852. /**
  102853. * The list of skeletons added to the scene
  102854. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102855. */
  102856. skeletons: Skeleton[];
  102857. /**
  102858. * All of the particle systems added to this scene
  102859. * @see http://doc.babylonjs.com/babylon101/particles
  102860. */
  102861. particleSystems: IParticleSystem[];
  102862. /**
  102863. * Gets a list of Animations associated with the scene
  102864. */
  102865. animations: Animation[];
  102866. /**
  102867. * All of the animation groups added to this scene
  102868. * @see http://doc.babylonjs.com/how_to/group
  102869. */
  102870. animationGroups: AnimationGroup[];
  102871. /**
  102872. * All of the multi-materials added to this scene
  102873. * @see http://doc.babylonjs.com/how_to/multi_materials
  102874. */
  102875. multiMaterials: MultiMaterial[];
  102876. /**
  102877. * All of the materials added to this scene
  102878. * In the context of a Scene, it is not supposed to be modified manually.
  102879. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  102880. * Note also that the order of the Material within the array is not significant and might change.
  102881. * @see http://doc.babylonjs.com/babylon101/materials
  102882. */
  102883. materials: Material[];
  102884. /**
  102885. * The list of morph target managers added to the scene
  102886. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102887. */
  102888. morphTargetManagers: MorphTargetManager[];
  102889. /**
  102890. * The list of geometries used in the scene.
  102891. */
  102892. geometries: Geometry[];
  102893. /**
  102894. * All of the tranform nodes added to this scene
  102895. * In the context of a Scene, it is not supposed to be modified manually.
  102896. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102897. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102898. * @see http://doc.babylonjs.com/how_to/transformnode
  102899. */
  102900. transformNodes: TransformNode[];
  102901. /**
  102902. * ActionManagers available on the scene.
  102903. */
  102904. actionManagers: AbstractActionManager[];
  102905. /**
  102906. * Textures to keep.
  102907. */
  102908. textures: BaseTexture[];
  102909. /**
  102910. * Environment texture for the scene
  102911. */
  102912. environmentTexture: Nullable<BaseTexture>;
  102913. }
  102914. }
  102915. declare module BABYLON {
  102916. /**
  102917. * Interface used to define options for Sound class
  102918. */
  102919. export interface ISoundOptions {
  102920. /**
  102921. * Does the sound autoplay once loaded.
  102922. */
  102923. autoplay?: boolean;
  102924. /**
  102925. * Does the sound loop after it finishes playing once.
  102926. */
  102927. loop?: boolean;
  102928. /**
  102929. * Sound's volume
  102930. */
  102931. volume?: number;
  102932. /**
  102933. * Is it a spatial sound?
  102934. */
  102935. spatialSound?: boolean;
  102936. /**
  102937. * Maximum distance to hear that sound
  102938. */
  102939. maxDistance?: number;
  102940. /**
  102941. * Uses user defined attenuation function
  102942. */
  102943. useCustomAttenuation?: boolean;
  102944. /**
  102945. * Define the roll off factor of spatial sounds.
  102946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102947. */
  102948. rolloffFactor?: number;
  102949. /**
  102950. * Define the reference distance the sound should be heard perfectly.
  102951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102952. */
  102953. refDistance?: number;
  102954. /**
  102955. * Define the distance attenuation model the sound will follow.
  102956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102957. */
  102958. distanceModel?: string;
  102959. /**
  102960. * Defines the playback speed (1 by default)
  102961. */
  102962. playbackRate?: number;
  102963. /**
  102964. * Defines if the sound is from a streaming source
  102965. */
  102966. streaming?: boolean;
  102967. /**
  102968. * Defines an optional length (in seconds) inside the sound file
  102969. */
  102970. length?: number;
  102971. /**
  102972. * Defines an optional offset (in seconds) inside the sound file
  102973. */
  102974. offset?: number;
  102975. /**
  102976. * If true, URLs will not be required to state the audio file codec to use.
  102977. */
  102978. skipCodecCheck?: boolean;
  102979. }
  102980. /**
  102981. * Defines a sound that can be played in the application.
  102982. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102984. */
  102985. export class Sound {
  102986. /**
  102987. * The name of the sound in the scene.
  102988. */
  102989. name: string;
  102990. /**
  102991. * Does the sound autoplay once loaded.
  102992. */
  102993. autoplay: boolean;
  102994. /**
  102995. * Does the sound loop after it finishes playing once.
  102996. */
  102997. loop: boolean;
  102998. /**
  102999. * Does the sound use a custom attenuation curve to simulate the falloff
  103000. * happening when the source gets further away from the camera.
  103001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103002. */
  103003. useCustomAttenuation: boolean;
  103004. /**
  103005. * The sound track id this sound belongs to.
  103006. */
  103007. soundTrackId: number;
  103008. /**
  103009. * Is this sound currently played.
  103010. */
  103011. isPlaying: boolean;
  103012. /**
  103013. * Is this sound currently paused.
  103014. */
  103015. isPaused: boolean;
  103016. /**
  103017. * Does this sound enables spatial sound.
  103018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103019. */
  103020. spatialSound: boolean;
  103021. /**
  103022. * Define the reference distance the sound should be heard perfectly.
  103023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103024. */
  103025. refDistance: number;
  103026. /**
  103027. * Define the roll off factor of spatial sounds.
  103028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103029. */
  103030. rolloffFactor: number;
  103031. /**
  103032. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103034. */
  103035. maxDistance: number;
  103036. /**
  103037. * Define the distance attenuation model the sound will follow.
  103038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103039. */
  103040. distanceModel: string;
  103041. /**
  103042. * @hidden
  103043. * Back Compat
  103044. **/
  103045. onended: () => any;
  103046. /**
  103047. * Observable event when the current playing sound finishes.
  103048. */
  103049. onEndedObservable: Observable<Sound>;
  103050. private _panningModel;
  103051. private _playbackRate;
  103052. private _streaming;
  103053. private _startTime;
  103054. private _startOffset;
  103055. private _position;
  103056. /** @hidden */
  103057. _positionInEmitterSpace: boolean;
  103058. private _localDirection;
  103059. private _volume;
  103060. private _isReadyToPlay;
  103061. private _isDirectional;
  103062. private _readyToPlayCallback;
  103063. private _audioBuffer;
  103064. private _soundSource;
  103065. private _streamingSource;
  103066. private _soundPanner;
  103067. private _soundGain;
  103068. private _inputAudioNode;
  103069. private _outputAudioNode;
  103070. private _coneInnerAngle;
  103071. private _coneOuterAngle;
  103072. private _coneOuterGain;
  103073. private _scene;
  103074. private _connectedTransformNode;
  103075. private _customAttenuationFunction;
  103076. private _registerFunc;
  103077. private _isOutputConnected;
  103078. private _htmlAudioElement;
  103079. private _urlType;
  103080. private _length?;
  103081. private _offset?;
  103082. /** @hidden */
  103083. static _SceneComponentInitialization: (scene: Scene) => void;
  103084. /**
  103085. * Create a sound and attach it to a scene
  103086. * @param name Name of your sound
  103087. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103088. * @param scene defines the scene the sound belongs to
  103089. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103090. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103091. */
  103092. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103093. /**
  103094. * Release the sound and its associated resources
  103095. */
  103096. dispose(): void;
  103097. /**
  103098. * Gets if the sounds is ready to be played or not.
  103099. * @returns true if ready, otherwise false
  103100. */
  103101. isReady(): boolean;
  103102. private _soundLoaded;
  103103. /**
  103104. * Sets the data of the sound from an audiobuffer
  103105. * @param audioBuffer The audioBuffer containing the data
  103106. */
  103107. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103108. /**
  103109. * Updates the current sounds options such as maxdistance, loop...
  103110. * @param options A JSON object containing values named as the object properties
  103111. */
  103112. updateOptions(options: ISoundOptions): void;
  103113. private _createSpatialParameters;
  103114. private _updateSpatialParameters;
  103115. /**
  103116. * Switch the panning model to HRTF:
  103117. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103119. */
  103120. switchPanningModelToHRTF(): void;
  103121. /**
  103122. * Switch the panning model to Equal Power:
  103123. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103125. */
  103126. switchPanningModelToEqualPower(): void;
  103127. private _switchPanningModel;
  103128. /**
  103129. * Connect this sound to a sound track audio node like gain...
  103130. * @param soundTrackAudioNode the sound track audio node to connect to
  103131. */
  103132. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103133. /**
  103134. * Transform this sound into a directional source
  103135. * @param coneInnerAngle Size of the inner cone in degree
  103136. * @param coneOuterAngle Size of the outer cone in degree
  103137. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103138. */
  103139. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103140. /**
  103141. * Gets or sets the inner angle for the directional cone.
  103142. */
  103143. /**
  103144. * Gets or sets the inner angle for the directional cone.
  103145. */
  103146. directionalConeInnerAngle: number;
  103147. /**
  103148. * Gets or sets the outer angle for the directional cone.
  103149. */
  103150. /**
  103151. * Gets or sets the outer angle for the directional cone.
  103152. */
  103153. directionalConeOuterAngle: number;
  103154. /**
  103155. * Sets the position of the emitter if spatial sound is enabled
  103156. * @param newPosition Defines the new posisiton
  103157. */
  103158. setPosition(newPosition: Vector3): void;
  103159. /**
  103160. * Sets the local direction of the emitter if spatial sound is enabled
  103161. * @param newLocalDirection Defines the new local direction
  103162. */
  103163. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103164. private _updateDirection;
  103165. /** @hidden */
  103166. updateDistanceFromListener(): void;
  103167. /**
  103168. * Sets a new custom attenuation function for the sound.
  103169. * @param callback Defines the function used for the attenuation
  103170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103171. */
  103172. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103173. /**
  103174. * Play the sound
  103175. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103176. * @param offset (optional) Start the sound at a specific time in seconds
  103177. * @param length (optional) Sound duration (in seconds)
  103178. */
  103179. play(time?: number, offset?: number, length?: number): void;
  103180. private _onended;
  103181. /**
  103182. * Stop the sound
  103183. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103184. */
  103185. stop(time?: number): void;
  103186. /**
  103187. * Put the sound in pause
  103188. */
  103189. pause(): void;
  103190. /**
  103191. * Sets a dedicated volume for this sounds
  103192. * @param newVolume Define the new volume of the sound
  103193. * @param time Define time for gradual change to new volume
  103194. */
  103195. setVolume(newVolume: number, time?: number): void;
  103196. /**
  103197. * Set the sound play back rate
  103198. * @param newPlaybackRate Define the playback rate the sound should be played at
  103199. */
  103200. setPlaybackRate(newPlaybackRate: number): void;
  103201. /**
  103202. * Gets the volume of the sound.
  103203. * @returns the volume of the sound
  103204. */
  103205. getVolume(): number;
  103206. /**
  103207. * Attach the sound to a dedicated mesh
  103208. * @param transformNode The transform node to connect the sound with
  103209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103210. */
  103211. attachToMesh(transformNode: TransformNode): void;
  103212. /**
  103213. * Detach the sound from the previously attached mesh
  103214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103215. */
  103216. detachFromMesh(): void;
  103217. private _onRegisterAfterWorldMatrixUpdate;
  103218. /**
  103219. * Clone the current sound in the scene.
  103220. * @returns the new sound clone
  103221. */
  103222. clone(): Nullable<Sound>;
  103223. /**
  103224. * Gets the current underlying audio buffer containing the data
  103225. * @returns the audio buffer
  103226. */
  103227. getAudioBuffer(): Nullable<AudioBuffer>;
  103228. /**
  103229. * Serializes the Sound in a JSON representation
  103230. * @returns the JSON representation of the sound
  103231. */
  103232. serialize(): any;
  103233. /**
  103234. * Parse a JSON representation of a sound to innstantiate in a given scene
  103235. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103236. * @param scene Define the scene the new parsed sound should be created in
  103237. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103238. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103239. * @returns the newly parsed sound
  103240. */
  103241. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103242. }
  103243. }
  103244. declare module BABYLON {
  103245. /**
  103246. * This defines an action helpful to play a defined sound on a triggered action.
  103247. */
  103248. export class PlaySoundAction extends Action {
  103249. private _sound;
  103250. /**
  103251. * Instantiate the action
  103252. * @param triggerOptions defines the trigger options
  103253. * @param sound defines the sound to play
  103254. * @param condition defines the trigger related conditions
  103255. */
  103256. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103257. /** @hidden */
  103258. _prepare(): void;
  103259. /**
  103260. * Execute the action and play the sound.
  103261. */
  103262. execute(): void;
  103263. /**
  103264. * Serializes the actions and its related information.
  103265. * @param parent defines the object to serialize in
  103266. * @returns the serialized object
  103267. */
  103268. serialize(parent: any): any;
  103269. }
  103270. /**
  103271. * This defines an action helpful to stop a defined sound on a triggered action.
  103272. */
  103273. export class StopSoundAction extends Action {
  103274. private _sound;
  103275. /**
  103276. * Instantiate the action
  103277. * @param triggerOptions defines the trigger options
  103278. * @param sound defines the sound to stop
  103279. * @param condition defines the trigger related conditions
  103280. */
  103281. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103282. /** @hidden */
  103283. _prepare(): void;
  103284. /**
  103285. * Execute the action and stop the sound.
  103286. */
  103287. execute(): void;
  103288. /**
  103289. * Serializes the actions and its related information.
  103290. * @param parent defines the object to serialize in
  103291. * @returns the serialized object
  103292. */
  103293. serialize(parent: any): any;
  103294. }
  103295. }
  103296. declare module BABYLON {
  103297. /**
  103298. * This defines an action responsible to change the value of a property
  103299. * by interpolating between its current value and the newly set one once triggered.
  103300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103301. */
  103302. export class InterpolateValueAction extends Action {
  103303. /**
  103304. * Defines the path of the property where the value should be interpolated
  103305. */
  103306. propertyPath: string;
  103307. /**
  103308. * Defines the target value at the end of the interpolation.
  103309. */
  103310. value: any;
  103311. /**
  103312. * Defines the time it will take for the property to interpolate to the value.
  103313. */
  103314. duration: number;
  103315. /**
  103316. * Defines if the other scene animations should be stopped when the action has been triggered
  103317. */
  103318. stopOtherAnimations?: boolean;
  103319. /**
  103320. * Defines a callback raised once the interpolation animation has been done.
  103321. */
  103322. onInterpolationDone?: () => void;
  103323. /**
  103324. * Observable triggered once the interpolation animation has been done.
  103325. */
  103326. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103327. private _target;
  103328. private _effectiveTarget;
  103329. private _property;
  103330. /**
  103331. * Instantiate the action
  103332. * @param triggerOptions defines the trigger options
  103333. * @param target defines the object containing the value to interpolate
  103334. * @param propertyPath defines the path to the property in the target object
  103335. * @param value defines the target value at the end of the interpolation
  103336. * @param duration deines the time it will take for the property to interpolate to the value.
  103337. * @param condition defines the trigger related conditions
  103338. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103339. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103340. */
  103341. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103342. /** @hidden */
  103343. _prepare(): void;
  103344. /**
  103345. * Execute the action starts the value interpolation.
  103346. */
  103347. execute(): void;
  103348. /**
  103349. * Serializes the actions and its related information.
  103350. * @param parent defines the object to serialize in
  103351. * @returns the serialized object
  103352. */
  103353. serialize(parent: any): any;
  103354. }
  103355. }
  103356. declare module BABYLON {
  103357. /**
  103358. * Options allowed during the creation of a sound track.
  103359. */
  103360. export interface ISoundTrackOptions {
  103361. /**
  103362. * The volume the sound track should take during creation
  103363. */
  103364. volume?: number;
  103365. /**
  103366. * Define if the sound track is the main sound track of the scene
  103367. */
  103368. mainTrack?: boolean;
  103369. }
  103370. /**
  103371. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103372. * It will be also used in a future release to apply effects on a specific track.
  103373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103374. */
  103375. export class SoundTrack {
  103376. /**
  103377. * The unique identifier of the sound track in the scene.
  103378. */
  103379. id: number;
  103380. /**
  103381. * The list of sounds included in the sound track.
  103382. */
  103383. soundCollection: Array<Sound>;
  103384. private _outputAudioNode;
  103385. private _scene;
  103386. private _isMainTrack;
  103387. private _connectedAnalyser;
  103388. private _options;
  103389. private _isInitialized;
  103390. /**
  103391. * Creates a new sound track.
  103392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103393. * @param scene Define the scene the sound track belongs to
  103394. * @param options
  103395. */
  103396. constructor(scene: Scene, options?: ISoundTrackOptions);
  103397. private _initializeSoundTrackAudioGraph;
  103398. /**
  103399. * Release the sound track and its associated resources
  103400. */
  103401. dispose(): void;
  103402. /**
  103403. * Adds a sound to this sound track
  103404. * @param sound define the cound to add
  103405. * @ignoreNaming
  103406. */
  103407. AddSound(sound: Sound): void;
  103408. /**
  103409. * Removes a sound to this sound track
  103410. * @param sound define the cound to remove
  103411. * @ignoreNaming
  103412. */
  103413. RemoveSound(sound: Sound): void;
  103414. /**
  103415. * Set a global volume for the full sound track.
  103416. * @param newVolume Define the new volume of the sound track
  103417. */
  103418. setVolume(newVolume: number): void;
  103419. /**
  103420. * Switch the panning model to HRTF:
  103421. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103423. */
  103424. switchPanningModelToHRTF(): void;
  103425. /**
  103426. * Switch the panning model to Equal Power:
  103427. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103429. */
  103430. switchPanningModelToEqualPower(): void;
  103431. /**
  103432. * Connect the sound track to an audio analyser allowing some amazing
  103433. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103435. * @param analyser The analyser to connect to the engine
  103436. */
  103437. connectToAnalyser(analyser: Analyser): void;
  103438. }
  103439. }
  103440. declare module BABYLON {
  103441. interface AbstractScene {
  103442. /**
  103443. * The list of sounds used in the scene.
  103444. */
  103445. sounds: Nullable<Array<Sound>>;
  103446. }
  103447. interface Scene {
  103448. /**
  103449. * @hidden
  103450. * Backing field
  103451. */
  103452. _mainSoundTrack: SoundTrack;
  103453. /**
  103454. * The main sound track played by the scene.
  103455. * It cotains your primary collection of sounds.
  103456. */
  103457. mainSoundTrack: SoundTrack;
  103458. /**
  103459. * The list of sound tracks added to the scene
  103460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103461. */
  103462. soundTracks: Nullable<Array<SoundTrack>>;
  103463. /**
  103464. * Gets a sound using a given name
  103465. * @param name defines the name to search for
  103466. * @return the found sound or null if not found at all.
  103467. */
  103468. getSoundByName(name: string): Nullable<Sound>;
  103469. /**
  103470. * Gets or sets if audio support is enabled
  103471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103472. */
  103473. audioEnabled: boolean;
  103474. /**
  103475. * Gets or sets if audio will be output to headphones
  103476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103477. */
  103478. headphone: boolean;
  103479. /**
  103480. * Gets or sets custom audio listener position provider
  103481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103482. */
  103483. audioListenerPositionProvider: Nullable<() => Vector3>;
  103484. /**
  103485. * Gets or sets a refresh rate when using 3D audio positioning
  103486. */
  103487. audioPositioningRefreshRate: number;
  103488. }
  103489. /**
  103490. * Defines the sound scene component responsible to manage any sounds
  103491. * in a given scene.
  103492. */
  103493. export class AudioSceneComponent implements ISceneSerializableComponent {
  103494. /**
  103495. * The component name helpfull to identify the component in the list of scene components.
  103496. */
  103497. readonly name: string;
  103498. /**
  103499. * The scene the component belongs to.
  103500. */
  103501. scene: Scene;
  103502. private _audioEnabled;
  103503. /**
  103504. * Gets whether audio is enabled or not.
  103505. * Please use related enable/disable method to switch state.
  103506. */
  103507. readonly audioEnabled: boolean;
  103508. private _headphone;
  103509. /**
  103510. * Gets whether audio is outputing to headphone or not.
  103511. * Please use the according Switch methods to change output.
  103512. */
  103513. readonly headphone: boolean;
  103514. /**
  103515. * Gets or sets a refresh rate when using 3D audio positioning
  103516. */
  103517. audioPositioningRefreshRate: number;
  103518. private _audioListenerPositionProvider;
  103519. /**
  103520. * Gets the current audio listener position provider
  103521. */
  103522. /**
  103523. * Sets a custom listener position for all sounds in the scene
  103524. * By default, this is the position of the first active camera
  103525. */
  103526. audioListenerPositionProvider: Nullable<() => Vector3>;
  103527. /**
  103528. * Creates a new instance of the component for the given scene
  103529. * @param scene Defines the scene to register the component in
  103530. */
  103531. constructor(scene: Scene);
  103532. /**
  103533. * Registers the component in a given scene
  103534. */
  103535. register(): void;
  103536. /**
  103537. * Rebuilds the elements related to this component in case of
  103538. * context lost for instance.
  103539. */
  103540. rebuild(): void;
  103541. /**
  103542. * Serializes the component data to the specified json object
  103543. * @param serializationObject The object to serialize to
  103544. */
  103545. serialize(serializationObject: any): void;
  103546. /**
  103547. * Adds all the elements from the container to the scene
  103548. * @param container the container holding the elements
  103549. */
  103550. addFromContainer(container: AbstractScene): void;
  103551. /**
  103552. * Removes all the elements in the container from the scene
  103553. * @param container contains the elements to remove
  103554. * @param dispose if the removed element should be disposed (default: false)
  103555. */
  103556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103557. /**
  103558. * Disposes the component and the associated ressources.
  103559. */
  103560. dispose(): void;
  103561. /**
  103562. * Disables audio in the associated scene.
  103563. */
  103564. disableAudio(): void;
  103565. /**
  103566. * Enables audio in the associated scene.
  103567. */
  103568. enableAudio(): void;
  103569. /**
  103570. * Switch audio to headphone output.
  103571. */
  103572. switchAudioModeForHeadphones(): void;
  103573. /**
  103574. * Switch audio to normal speakers.
  103575. */
  103576. switchAudioModeForNormalSpeakers(): void;
  103577. private _cachedCameraDirection;
  103578. private _cachedCameraPosition;
  103579. private _lastCheck;
  103580. private _afterRender;
  103581. }
  103582. }
  103583. declare module BABYLON {
  103584. /**
  103585. * Wraps one or more Sound objects and selects one with random weight for playback.
  103586. */
  103587. export class WeightedSound {
  103588. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103589. loop: boolean;
  103590. private _coneInnerAngle;
  103591. private _coneOuterAngle;
  103592. private _volume;
  103593. /** A Sound is currently playing. */
  103594. isPlaying: boolean;
  103595. /** A Sound is currently paused. */
  103596. isPaused: boolean;
  103597. private _sounds;
  103598. private _weights;
  103599. private _currentIndex?;
  103600. /**
  103601. * Creates a new WeightedSound from the list of sounds given.
  103602. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103603. * @param sounds Array of Sounds that will be selected from.
  103604. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103605. */
  103606. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103607. /**
  103608. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103609. */
  103610. /**
  103611. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103612. */
  103613. directionalConeInnerAngle: number;
  103614. /**
  103615. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103616. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103617. */
  103618. /**
  103619. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103620. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103621. */
  103622. directionalConeOuterAngle: number;
  103623. /**
  103624. * Playback volume.
  103625. */
  103626. /**
  103627. * Playback volume.
  103628. */
  103629. volume: number;
  103630. private _onended;
  103631. /**
  103632. * Suspend playback
  103633. */
  103634. pause(): void;
  103635. /**
  103636. * Stop playback
  103637. */
  103638. stop(): void;
  103639. /**
  103640. * Start playback.
  103641. * @param startOffset Position the clip head at a specific time in seconds.
  103642. */
  103643. play(startOffset?: number): void;
  103644. }
  103645. }
  103646. declare module BABYLON {
  103647. /**
  103648. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103650. */
  103651. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103652. /**
  103653. * Gets the name of the behavior.
  103654. */
  103655. readonly name: string;
  103656. /**
  103657. * The easing function used by animations
  103658. */
  103659. static EasingFunction: BackEase;
  103660. /**
  103661. * The easing mode used by animations
  103662. */
  103663. static EasingMode: number;
  103664. /**
  103665. * The duration of the animation, in milliseconds
  103666. */
  103667. transitionDuration: number;
  103668. /**
  103669. * Length of the distance animated by the transition when lower radius is reached
  103670. */
  103671. lowerRadiusTransitionRange: number;
  103672. /**
  103673. * Length of the distance animated by the transition when upper radius is reached
  103674. */
  103675. upperRadiusTransitionRange: number;
  103676. private _autoTransitionRange;
  103677. /**
  103678. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103679. */
  103680. /**
  103681. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103682. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103683. */
  103684. autoTransitionRange: boolean;
  103685. private _attachedCamera;
  103686. private _onAfterCheckInputsObserver;
  103687. private _onMeshTargetChangedObserver;
  103688. /**
  103689. * Initializes the behavior.
  103690. */
  103691. init(): void;
  103692. /**
  103693. * Attaches the behavior to its arc rotate camera.
  103694. * @param camera Defines the camera to attach the behavior to
  103695. */
  103696. attach(camera: ArcRotateCamera): void;
  103697. /**
  103698. * Detaches the behavior from its current arc rotate camera.
  103699. */
  103700. detach(): void;
  103701. private _radiusIsAnimating;
  103702. private _radiusBounceTransition;
  103703. private _animatables;
  103704. private _cachedWheelPrecision;
  103705. /**
  103706. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103707. * @param radiusLimit The limit to check against.
  103708. * @return Bool to indicate if at limit.
  103709. */
  103710. private _isRadiusAtLimit;
  103711. /**
  103712. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103713. * @param radiusDelta The delta by which to animate to. Can be negative.
  103714. */
  103715. private _applyBoundRadiusAnimation;
  103716. /**
  103717. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103718. */
  103719. protected _clearAnimationLocks(): void;
  103720. /**
  103721. * Stops and removes all animations that have been applied to the camera
  103722. */
  103723. stopAllAnimations(): void;
  103724. }
  103725. }
  103726. declare module BABYLON {
  103727. /**
  103728. * 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.
  103729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103730. */
  103731. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103732. /**
  103733. * Gets the name of the behavior.
  103734. */
  103735. readonly name: string;
  103736. private _mode;
  103737. private _radiusScale;
  103738. private _positionScale;
  103739. private _defaultElevation;
  103740. private _elevationReturnTime;
  103741. private _elevationReturnWaitTime;
  103742. private _zoomStopsAnimation;
  103743. private _framingTime;
  103744. /**
  103745. * The easing function used by animations
  103746. */
  103747. static EasingFunction: ExponentialEase;
  103748. /**
  103749. * The easing mode used by animations
  103750. */
  103751. static EasingMode: number;
  103752. /**
  103753. * Sets the current mode used by the behavior
  103754. */
  103755. /**
  103756. * Gets current mode used by the behavior.
  103757. */
  103758. mode: number;
  103759. /**
  103760. * Sets the scale applied to the radius (1 by default)
  103761. */
  103762. /**
  103763. * Gets the scale applied to the radius
  103764. */
  103765. radiusScale: number;
  103766. /**
  103767. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103768. */
  103769. /**
  103770. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103771. */
  103772. positionScale: number;
  103773. /**
  103774. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103775. * behaviour is triggered, in radians.
  103776. */
  103777. /**
  103778. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103779. * behaviour is triggered, in radians.
  103780. */
  103781. defaultElevation: number;
  103782. /**
  103783. * Sets the time (in milliseconds) taken to return to the default beta position.
  103784. * Negative value indicates camera should not return to default.
  103785. */
  103786. /**
  103787. * Gets the time (in milliseconds) taken to return to the default beta position.
  103788. * Negative value indicates camera should not return to default.
  103789. */
  103790. elevationReturnTime: number;
  103791. /**
  103792. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103793. */
  103794. /**
  103795. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103796. */
  103797. elevationReturnWaitTime: number;
  103798. /**
  103799. * Sets the flag that indicates if user zooming should stop animation.
  103800. */
  103801. /**
  103802. * Gets the flag that indicates if user zooming should stop animation.
  103803. */
  103804. zoomStopsAnimation: boolean;
  103805. /**
  103806. * Sets the transition time when framing the mesh, in milliseconds
  103807. */
  103808. /**
  103809. * Gets the transition time when framing the mesh, in milliseconds
  103810. */
  103811. framingTime: number;
  103812. /**
  103813. * Define if the behavior should automatically change the configured
  103814. * camera limits and sensibilities.
  103815. */
  103816. autoCorrectCameraLimitsAndSensibility: boolean;
  103817. private _onPrePointerObservableObserver;
  103818. private _onAfterCheckInputsObserver;
  103819. private _onMeshTargetChangedObserver;
  103820. private _attachedCamera;
  103821. private _isPointerDown;
  103822. private _lastInteractionTime;
  103823. /**
  103824. * Initializes the behavior.
  103825. */
  103826. init(): void;
  103827. /**
  103828. * Attaches the behavior to its arc rotate camera.
  103829. * @param camera Defines the camera to attach the behavior to
  103830. */
  103831. attach(camera: ArcRotateCamera): void;
  103832. /**
  103833. * Detaches the behavior from its current arc rotate camera.
  103834. */
  103835. detach(): void;
  103836. private _animatables;
  103837. private _betaIsAnimating;
  103838. private _betaTransition;
  103839. private _radiusTransition;
  103840. private _vectorTransition;
  103841. /**
  103842. * Targets the given mesh and updates zoom level accordingly.
  103843. * @param mesh The mesh to target.
  103844. * @param radius Optional. If a cached radius position already exists, overrides default.
  103845. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103846. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103847. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103848. */
  103849. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103850. /**
  103851. * Targets the given mesh with its children and updates zoom level accordingly.
  103852. * @param mesh The mesh to target.
  103853. * @param radius Optional. If a cached radius position already exists, overrides default.
  103854. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103855. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103856. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103857. */
  103858. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103859. /**
  103860. * Targets the given meshes with their children and updates zoom level accordingly.
  103861. * @param meshes The mesh to target.
  103862. * @param radius Optional. If a cached radius position already exists, overrides default.
  103863. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103864. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103865. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103866. */
  103867. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103868. /**
  103869. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103870. * @param minimumWorld Determines the smaller position of the bounding box extend
  103871. * @param maximumWorld Determines the bigger position of the bounding box extend
  103872. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103873. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103874. */
  103875. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103876. /**
  103877. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103878. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103879. * frustum width.
  103880. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103881. * to fully enclose the mesh in the viewing frustum.
  103882. */
  103883. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103884. /**
  103885. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103886. * is automatically returned to its default position (expected to be above ground plane).
  103887. */
  103888. private _maintainCameraAboveGround;
  103889. /**
  103890. * Returns the frustum slope based on the canvas ratio and camera FOV
  103891. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103892. */
  103893. private _getFrustumSlope;
  103894. /**
  103895. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103896. */
  103897. private _clearAnimationLocks;
  103898. /**
  103899. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103900. */
  103901. private _applyUserInteraction;
  103902. /**
  103903. * Stops and removes all animations that have been applied to the camera
  103904. */
  103905. stopAllAnimations(): void;
  103906. /**
  103907. * Gets a value indicating if the user is moving the camera
  103908. */
  103909. readonly isUserIsMoving: boolean;
  103910. /**
  103911. * The camera can move all the way towards the mesh.
  103912. */
  103913. static IgnoreBoundsSizeMode: number;
  103914. /**
  103915. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103916. */
  103917. static FitFrustumSidesMode: number;
  103918. }
  103919. }
  103920. declare module BABYLON {
  103921. /**
  103922. * Base class for Camera Pointer Inputs.
  103923. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103924. * for example usage.
  103925. */
  103926. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103927. /**
  103928. * Defines the camera the input is attached to.
  103929. */
  103930. abstract camera: Camera;
  103931. /**
  103932. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103933. */
  103934. protected _altKey: boolean;
  103935. protected _ctrlKey: boolean;
  103936. protected _metaKey: boolean;
  103937. protected _shiftKey: boolean;
  103938. /**
  103939. * Which mouse buttons were pressed at time of last mouse event.
  103940. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103941. */
  103942. protected _buttonsPressed: number;
  103943. /**
  103944. * Defines the buttons associated with the input to handle camera move.
  103945. */
  103946. buttons: number[];
  103947. /**
  103948. * Attach the input controls to a specific dom element to get the input from.
  103949. * @param element Defines the element the controls should be listened from
  103950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103951. */
  103952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103953. /**
  103954. * Detach the current controls from the specified dom element.
  103955. * @param element Defines the element to stop listening the inputs from
  103956. */
  103957. detachControl(element: Nullable<HTMLElement>): void;
  103958. /**
  103959. * Gets the class name of the current input.
  103960. * @returns the class name
  103961. */
  103962. getClassName(): string;
  103963. /**
  103964. * Get the friendly name associated with the input class.
  103965. * @returns the input friendly name
  103966. */
  103967. getSimpleName(): string;
  103968. /**
  103969. * Called on pointer POINTERDOUBLETAP event.
  103970. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103971. */
  103972. protected onDoubleTap(type: string): void;
  103973. /**
  103974. * Called on pointer POINTERMOVE event if only a single touch is active.
  103975. * Override this method to provide functionality.
  103976. */
  103977. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103978. /**
  103979. * Called on pointer POINTERMOVE event if multiple touches are active.
  103980. * Override this method to provide functionality.
  103981. */
  103982. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103983. /**
  103984. * Called on JS contextmenu event.
  103985. * Override this method to provide functionality.
  103986. */
  103987. protected onContextMenu(evt: PointerEvent): void;
  103988. /**
  103989. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103990. * press.
  103991. * Override this method to provide functionality.
  103992. */
  103993. protected onButtonDown(evt: PointerEvent): void;
  103994. /**
  103995. * Called each time a new POINTERUP event occurs. Ie, for each button
  103996. * release.
  103997. * Override this method to provide functionality.
  103998. */
  103999. protected onButtonUp(evt: PointerEvent): void;
  104000. /**
  104001. * Called when window becomes inactive.
  104002. * Override this method to provide functionality.
  104003. */
  104004. protected onLostFocus(): void;
  104005. private _pointerInput;
  104006. private _observer;
  104007. private _onLostFocus;
  104008. private pointA;
  104009. private pointB;
  104010. }
  104011. }
  104012. declare module BABYLON {
  104013. /**
  104014. * Manage the pointers inputs to control an arc rotate camera.
  104015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104016. */
  104017. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104018. /**
  104019. * Defines the camera the input is attached to.
  104020. */
  104021. camera: ArcRotateCamera;
  104022. /**
  104023. * Gets the class name of the current input.
  104024. * @returns the class name
  104025. */
  104026. getClassName(): string;
  104027. /**
  104028. * Defines the buttons associated with the input to handle camera move.
  104029. */
  104030. buttons: number[];
  104031. /**
  104032. * Defines the pointer angular sensibility along the X axis or how fast is
  104033. * the camera rotating.
  104034. */
  104035. angularSensibilityX: number;
  104036. /**
  104037. * Defines the pointer angular sensibility along the Y axis or how fast is
  104038. * the camera rotating.
  104039. */
  104040. angularSensibilityY: number;
  104041. /**
  104042. * Defines the pointer pinch precision or how fast is the camera zooming.
  104043. */
  104044. pinchPrecision: number;
  104045. /**
  104046. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104047. * from 0.
  104048. * It defines the percentage of current camera.radius to use as delta when
  104049. * pinch zoom is used.
  104050. */
  104051. pinchDeltaPercentage: number;
  104052. /**
  104053. * Defines the pointer panning sensibility or how fast is the camera moving.
  104054. */
  104055. panningSensibility: number;
  104056. /**
  104057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104058. */
  104059. multiTouchPanning: boolean;
  104060. /**
  104061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104062. * zoom (pinch) through multitouch.
  104063. */
  104064. multiTouchPanAndZoom: boolean;
  104065. /**
  104066. * Revers pinch action direction.
  104067. */
  104068. pinchInwards: boolean;
  104069. private _isPanClick;
  104070. private _twoFingerActivityCount;
  104071. private _isPinching;
  104072. /**
  104073. * Called on pointer POINTERMOVE event if only a single touch is active.
  104074. */
  104075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104076. /**
  104077. * Called on pointer POINTERDOUBLETAP event.
  104078. */
  104079. protected onDoubleTap(type: string): void;
  104080. /**
  104081. * Called on pointer POINTERMOVE event if multiple touches are active.
  104082. */
  104083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104084. /**
  104085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104086. * press.
  104087. */
  104088. protected onButtonDown(evt: PointerEvent): void;
  104089. /**
  104090. * Called each time a new POINTERUP event occurs. Ie, for each button
  104091. * release.
  104092. */
  104093. protected onButtonUp(evt: PointerEvent): void;
  104094. /**
  104095. * Called when window becomes inactive.
  104096. */
  104097. protected onLostFocus(): void;
  104098. }
  104099. }
  104100. declare module BABYLON {
  104101. /**
  104102. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104104. */
  104105. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104106. /**
  104107. * Defines the camera the input is attached to.
  104108. */
  104109. camera: ArcRotateCamera;
  104110. /**
  104111. * Defines the list of key codes associated with the up action (increase alpha)
  104112. */
  104113. keysUp: number[];
  104114. /**
  104115. * Defines the list of key codes associated with the down action (decrease alpha)
  104116. */
  104117. keysDown: number[];
  104118. /**
  104119. * Defines the list of key codes associated with the left action (increase beta)
  104120. */
  104121. keysLeft: number[];
  104122. /**
  104123. * Defines the list of key codes associated with the right action (decrease beta)
  104124. */
  104125. keysRight: number[];
  104126. /**
  104127. * Defines the list of key codes associated with the reset action.
  104128. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104129. */
  104130. keysReset: number[];
  104131. /**
  104132. * Defines the panning sensibility of the inputs.
  104133. * (How fast is the camera paning)
  104134. */
  104135. panningSensibility: number;
  104136. /**
  104137. * Defines the zooming sensibility of the inputs.
  104138. * (How fast is the camera zooming)
  104139. */
  104140. zoomingSensibility: number;
  104141. /**
  104142. * Defines wether maintaining the alt key down switch the movement mode from
  104143. * orientation to zoom.
  104144. */
  104145. useAltToZoom: boolean;
  104146. /**
  104147. * Rotation speed of the camera
  104148. */
  104149. angularSpeed: number;
  104150. private _keys;
  104151. private _ctrlPressed;
  104152. private _altPressed;
  104153. private _onCanvasBlurObserver;
  104154. private _onKeyboardObserver;
  104155. private _engine;
  104156. private _scene;
  104157. /**
  104158. * Attach the input controls to a specific dom element to get the input from.
  104159. * @param element Defines the element the controls should be listened from
  104160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104161. */
  104162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104163. /**
  104164. * Detach the current controls from the specified dom element.
  104165. * @param element Defines the element to stop listening the inputs from
  104166. */
  104167. detachControl(element: Nullable<HTMLElement>): void;
  104168. /**
  104169. * Update the current camera state depending on the inputs that have been used this frame.
  104170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104171. */
  104172. checkInputs(): void;
  104173. /**
  104174. * Gets the class name of the current intput.
  104175. * @returns the class name
  104176. */
  104177. getClassName(): string;
  104178. /**
  104179. * Get the friendly name associated with the input class.
  104180. * @returns the input friendly name
  104181. */
  104182. getSimpleName(): string;
  104183. }
  104184. }
  104185. declare module BABYLON {
  104186. /**
  104187. * Manage the mouse wheel inputs to control an arc rotate camera.
  104188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104189. */
  104190. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104191. /**
  104192. * Defines the camera the input is attached to.
  104193. */
  104194. camera: ArcRotateCamera;
  104195. /**
  104196. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104197. */
  104198. wheelPrecision: number;
  104199. /**
  104200. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104201. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104202. */
  104203. wheelDeltaPercentage: number;
  104204. private _wheel;
  104205. private _observer;
  104206. private computeDeltaFromMouseWheelLegacyEvent;
  104207. /**
  104208. * Attach the input controls to a specific dom element to get the input from.
  104209. * @param element Defines the element the controls should be listened from
  104210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104211. */
  104212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104213. /**
  104214. * Detach the current controls from the specified dom element.
  104215. * @param element Defines the element to stop listening the inputs from
  104216. */
  104217. detachControl(element: Nullable<HTMLElement>): void;
  104218. /**
  104219. * Gets the class name of the current intput.
  104220. * @returns the class name
  104221. */
  104222. getClassName(): string;
  104223. /**
  104224. * Get the friendly name associated with the input class.
  104225. * @returns the input friendly name
  104226. */
  104227. getSimpleName(): string;
  104228. }
  104229. }
  104230. declare module BABYLON {
  104231. /**
  104232. * Default Inputs manager for the ArcRotateCamera.
  104233. * It groups all the default supported inputs for ease of use.
  104234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104235. */
  104236. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104237. /**
  104238. * Instantiates a new ArcRotateCameraInputsManager.
  104239. * @param camera Defines the camera the inputs belong to
  104240. */
  104241. constructor(camera: ArcRotateCamera);
  104242. /**
  104243. * Add mouse wheel input support to the input manager.
  104244. * @returns the current input manager
  104245. */
  104246. addMouseWheel(): ArcRotateCameraInputsManager;
  104247. /**
  104248. * Add pointers input support to the input manager.
  104249. * @returns the current input manager
  104250. */
  104251. addPointers(): ArcRotateCameraInputsManager;
  104252. /**
  104253. * Add keyboard input support to the input manager.
  104254. * @returns the current input manager
  104255. */
  104256. addKeyboard(): ArcRotateCameraInputsManager;
  104257. }
  104258. }
  104259. declare module BABYLON {
  104260. /**
  104261. * This represents an orbital type of camera.
  104262. *
  104263. * 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.
  104264. * 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.
  104265. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104266. */
  104267. export class ArcRotateCamera extends TargetCamera {
  104268. /**
  104269. * Defines the rotation angle of the camera along the longitudinal axis.
  104270. */
  104271. alpha: number;
  104272. /**
  104273. * Defines the rotation angle of the camera along the latitudinal axis.
  104274. */
  104275. beta: number;
  104276. /**
  104277. * Defines the radius of the camera from it s target point.
  104278. */
  104279. radius: number;
  104280. protected _target: Vector3;
  104281. protected _targetHost: Nullable<AbstractMesh>;
  104282. /**
  104283. * Defines the target point of the camera.
  104284. * The camera looks towards it form the radius distance.
  104285. */
  104286. target: Vector3;
  104287. /**
  104288. * Define the current local position of the camera in the scene
  104289. */
  104290. position: Vector3;
  104291. protected _upVector: Vector3;
  104292. protected _upToYMatrix: Matrix;
  104293. protected _YToUpMatrix: Matrix;
  104294. /**
  104295. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104296. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104297. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104298. */
  104299. upVector: Vector3;
  104300. /**
  104301. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104302. */
  104303. setMatUp(): void;
  104304. /**
  104305. * Current inertia value on the longitudinal axis.
  104306. * The bigger this number the longer it will take for the camera to stop.
  104307. */
  104308. inertialAlphaOffset: number;
  104309. /**
  104310. * Current inertia value on the latitudinal axis.
  104311. * The bigger this number the longer it will take for the camera to stop.
  104312. */
  104313. inertialBetaOffset: number;
  104314. /**
  104315. * Current inertia value on the radius axis.
  104316. * The bigger this number the longer it will take for the camera to stop.
  104317. */
  104318. inertialRadiusOffset: number;
  104319. /**
  104320. * Minimum allowed angle on the longitudinal axis.
  104321. * This can help limiting how the Camera is able to move in the scene.
  104322. */
  104323. lowerAlphaLimit: Nullable<number>;
  104324. /**
  104325. * Maximum allowed angle on the longitudinal axis.
  104326. * This can help limiting how the Camera is able to move in the scene.
  104327. */
  104328. upperAlphaLimit: Nullable<number>;
  104329. /**
  104330. * Minimum allowed angle on the latitudinal axis.
  104331. * This can help limiting how the Camera is able to move in the scene.
  104332. */
  104333. lowerBetaLimit: number;
  104334. /**
  104335. * Maximum allowed angle on the latitudinal axis.
  104336. * This can help limiting how the Camera is able to move in the scene.
  104337. */
  104338. upperBetaLimit: number;
  104339. /**
  104340. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104341. * This can help limiting how the Camera is able to move in the scene.
  104342. */
  104343. lowerRadiusLimit: Nullable<number>;
  104344. /**
  104345. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104346. * This can help limiting how the Camera is able to move in the scene.
  104347. */
  104348. upperRadiusLimit: Nullable<number>;
  104349. /**
  104350. * Defines the current inertia value used during panning of the camera along the X axis.
  104351. */
  104352. inertialPanningX: number;
  104353. /**
  104354. * Defines the current inertia value used during panning of the camera along the Y axis.
  104355. */
  104356. inertialPanningY: number;
  104357. /**
  104358. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104359. * Basically if your fingers moves away from more than this distance you will be considered
  104360. * in pinch mode.
  104361. */
  104362. pinchToPanMaxDistance: number;
  104363. /**
  104364. * Defines the maximum distance the camera can pan.
  104365. * This could help keeping the cammera always in your scene.
  104366. */
  104367. panningDistanceLimit: Nullable<number>;
  104368. /**
  104369. * Defines the target of the camera before paning.
  104370. */
  104371. panningOriginTarget: Vector3;
  104372. /**
  104373. * Defines the value of the inertia used during panning.
  104374. * 0 would mean stop inertia and one would mean no decelleration at all.
  104375. */
  104376. panningInertia: number;
  104377. /**
  104378. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104379. */
  104380. angularSensibilityX: number;
  104381. /**
  104382. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104383. */
  104384. angularSensibilityY: number;
  104385. /**
  104386. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104387. */
  104388. pinchPrecision: number;
  104389. /**
  104390. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104391. * It will be used instead of pinchDeltaPrecision if different from 0.
  104392. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104393. */
  104394. pinchDeltaPercentage: number;
  104395. /**
  104396. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104397. */
  104398. panningSensibility: number;
  104399. /**
  104400. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104401. */
  104402. keysUp: number[];
  104403. /**
  104404. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104405. */
  104406. keysDown: number[];
  104407. /**
  104408. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104409. */
  104410. keysLeft: number[];
  104411. /**
  104412. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104413. */
  104414. keysRight: number[];
  104415. /**
  104416. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104417. */
  104418. wheelPrecision: number;
  104419. /**
  104420. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104421. * It will be used instead of pinchDeltaPrecision if different from 0.
  104422. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104423. */
  104424. wheelDeltaPercentage: number;
  104425. /**
  104426. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104427. */
  104428. zoomOnFactor: number;
  104429. /**
  104430. * Defines a screen offset for the camera position.
  104431. */
  104432. targetScreenOffset: Vector2;
  104433. /**
  104434. * Allows the camera to be completely reversed.
  104435. * If false the camera can not arrive upside down.
  104436. */
  104437. allowUpsideDown: boolean;
  104438. /**
  104439. * Define if double tap/click is used to restore the previously saved state of the camera.
  104440. */
  104441. useInputToRestoreState: boolean;
  104442. /** @hidden */
  104443. _viewMatrix: Matrix;
  104444. /** @hidden */
  104445. _useCtrlForPanning: boolean;
  104446. /** @hidden */
  104447. _panningMouseButton: number;
  104448. /**
  104449. * Defines the input associated to the camera.
  104450. */
  104451. inputs: ArcRotateCameraInputsManager;
  104452. /** @hidden */
  104453. _reset: () => void;
  104454. /**
  104455. * Defines the allowed panning axis.
  104456. */
  104457. panningAxis: Vector3;
  104458. protected _localDirection: Vector3;
  104459. protected _transformedDirection: Vector3;
  104460. private _bouncingBehavior;
  104461. /**
  104462. * Gets the bouncing behavior of the camera if it has been enabled.
  104463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104464. */
  104465. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104466. /**
  104467. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104469. */
  104470. useBouncingBehavior: boolean;
  104471. private _framingBehavior;
  104472. /**
  104473. * Gets the framing behavior of the camera if it has been enabled.
  104474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104475. */
  104476. readonly framingBehavior: Nullable<FramingBehavior>;
  104477. /**
  104478. * Defines if the framing behavior of the camera is enabled on the camera.
  104479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104480. */
  104481. useFramingBehavior: boolean;
  104482. private _autoRotationBehavior;
  104483. /**
  104484. * Gets the auto rotation behavior of the camera if it has been enabled.
  104485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104486. */
  104487. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104488. /**
  104489. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104490. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104491. */
  104492. useAutoRotationBehavior: boolean;
  104493. /**
  104494. * Observable triggered when the mesh target has been changed on the camera.
  104495. */
  104496. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104497. /**
  104498. * Event raised when the camera is colliding with a mesh.
  104499. */
  104500. onCollide: (collidedMesh: AbstractMesh) => void;
  104501. /**
  104502. * Defines whether the camera should check collision with the objects oh the scene.
  104503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104504. */
  104505. checkCollisions: boolean;
  104506. /**
  104507. * Defines the collision radius of the camera.
  104508. * This simulates a sphere around the camera.
  104509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104510. */
  104511. collisionRadius: Vector3;
  104512. protected _collider: Collider;
  104513. protected _previousPosition: Vector3;
  104514. protected _collisionVelocity: Vector3;
  104515. protected _newPosition: Vector3;
  104516. protected _previousAlpha: number;
  104517. protected _previousBeta: number;
  104518. protected _previousRadius: number;
  104519. protected _collisionTriggered: boolean;
  104520. protected _targetBoundingCenter: Nullable<Vector3>;
  104521. private _computationVector;
  104522. /**
  104523. * Instantiates a new ArcRotateCamera in a given scene
  104524. * @param name Defines the name of the camera
  104525. * @param alpha Defines the camera rotation along the logitudinal axis
  104526. * @param beta Defines the camera rotation along the latitudinal axis
  104527. * @param radius Defines the camera distance from its target
  104528. * @param target Defines the camera target
  104529. * @param scene Defines the scene the camera belongs to
  104530. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104531. */
  104532. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104533. /** @hidden */
  104534. _initCache(): void;
  104535. /** @hidden */
  104536. _updateCache(ignoreParentClass?: boolean): void;
  104537. protected _getTargetPosition(): Vector3;
  104538. private _storedAlpha;
  104539. private _storedBeta;
  104540. private _storedRadius;
  104541. private _storedTarget;
  104542. private _storedTargetScreenOffset;
  104543. /**
  104544. * Stores the current state of the camera (alpha, beta, radius and target)
  104545. * @returns the camera itself
  104546. */
  104547. storeState(): Camera;
  104548. /**
  104549. * @hidden
  104550. * Restored camera state. You must call storeState() first
  104551. */
  104552. _restoreStateValues(): boolean;
  104553. /** @hidden */
  104554. _isSynchronizedViewMatrix(): boolean;
  104555. /**
  104556. * Attached controls to the current camera.
  104557. * @param element Defines the element the controls should be listened from
  104558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104559. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104560. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104561. */
  104562. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104563. /**
  104564. * Detach the current controls from the camera.
  104565. * The camera will stop reacting to inputs.
  104566. * @param element Defines the element to stop listening the inputs from
  104567. */
  104568. detachControl(element: HTMLElement): void;
  104569. /** @hidden */
  104570. _checkInputs(): void;
  104571. protected _checkLimits(): void;
  104572. /**
  104573. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104574. */
  104575. rebuildAnglesAndRadius(): void;
  104576. /**
  104577. * Use a position to define the current camera related information like alpha, beta and radius
  104578. * @param position Defines the position to set the camera at
  104579. */
  104580. setPosition(position: Vector3): void;
  104581. /**
  104582. * Defines the target the camera should look at.
  104583. * This will automatically adapt alpha beta and radius to fit within the new target.
  104584. * @param target Defines the new target as a Vector or a mesh
  104585. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104586. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104587. */
  104588. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104589. /** @hidden */
  104590. _getViewMatrix(): Matrix;
  104591. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104592. /**
  104593. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104594. * @param meshes Defines the mesh to zoom on
  104595. * @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)
  104596. */
  104597. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104598. /**
  104599. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104600. * The target will be changed but the radius
  104601. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104602. * @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)
  104603. */
  104604. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104605. min: Vector3;
  104606. max: Vector3;
  104607. distance: number;
  104608. }, doNotUpdateMaxZ?: boolean): void;
  104609. /**
  104610. * @override
  104611. * Override Camera.createRigCamera
  104612. */
  104613. createRigCamera(name: string, cameraIndex: number): Camera;
  104614. /**
  104615. * @hidden
  104616. * @override
  104617. * Override Camera._updateRigCameras
  104618. */
  104619. _updateRigCameras(): void;
  104620. /**
  104621. * Destroy the camera and release the current resources hold by it.
  104622. */
  104623. dispose(): void;
  104624. /**
  104625. * Gets the current object class name.
  104626. * @return the class name
  104627. */
  104628. getClassName(): string;
  104629. }
  104630. }
  104631. declare module BABYLON {
  104632. /**
  104633. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104635. */
  104636. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104637. /**
  104638. * Gets the name of the behavior.
  104639. */
  104640. readonly name: string;
  104641. private _zoomStopsAnimation;
  104642. private _idleRotationSpeed;
  104643. private _idleRotationWaitTime;
  104644. private _idleRotationSpinupTime;
  104645. /**
  104646. * Sets the flag that indicates if user zooming should stop animation.
  104647. */
  104648. /**
  104649. * Gets the flag that indicates if user zooming should stop animation.
  104650. */
  104651. zoomStopsAnimation: boolean;
  104652. /**
  104653. * Sets the default speed at which the camera rotates around the model.
  104654. */
  104655. /**
  104656. * Gets the default speed at which the camera rotates around the model.
  104657. */
  104658. idleRotationSpeed: number;
  104659. /**
  104660. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104661. */
  104662. /**
  104663. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104664. */
  104665. idleRotationWaitTime: number;
  104666. /**
  104667. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104668. */
  104669. /**
  104670. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104671. */
  104672. idleRotationSpinupTime: number;
  104673. /**
  104674. * Gets a value indicating if the camera is currently rotating because of this behavior
  104675. */
  104676. readonly rotationInProgress: boolean;
  104677. private _onPrePointerObservableObserver;
  104678. private _onAfterCheckInputsObserver;
  104679. private _attachedCamera;
  104680. private _isPointerDown;
  104681. private _lastFrameTime;
  104682. private _lastInteractionTime;
  104683. private _cameraRotationSpeed;
  104684. /**
  104685. * Initializes the behavior.
  104686. */
  104687. init(): void;
  104688. /**
  104689. * Attaches the behavior to its arc rotate camera.
  104690. * @param camera Defines the camera to attach the behavior to
  104691. */
  104692. attach(camera: ArcRotateCamera): void;
  104693. /**
  104694. * Detaches the behavior from its current arc rotate camera.
  104695. */
  104696. detach(): void;
  104697. /**
  104698. * Returns true if user is scrolling.
  104699. * @return true if user is scrolling.
  104700. */
  104701. private _userIsZooming;
  104702. private _lastFrameRadius;
  104703. private _shouldAnimationStopForInteraction;
  104704. /**
  104705. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104706. */
  104707. private _applyUserInteraction;
  104708. private _userIsMoving;
  104709. }
  104710. }
  104711. declare module BABYLON {
  104712. /**
  104713. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104714. */
  104715. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104716. private ui;
  104717. /**
  104718. * The name of the behavior
  104719. */
  104720. name: string;
  104721. /**
  104722. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104723. */
  104724. distanceAwayFromFace: number;
  104725. /**
  104726. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104727. */
  104728. distanceAwayFromBottomOfFace: number;
  104729. private _faceVectors;
  104730. private _target;
  104731. private _scene;
  104732. private _onRenderObserver;
  104733. private _tmpMatrix;
  104734. private _tmpVector;
  104735. /**
  104736. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104737. * @param ui The transform node that should be attched to the mesh
  104738. */
  104739. constructor(ui: TransformNode);
  104740. /**
  104741. * Initializes the behavior
  104742. */
  104743. init(): void;
  104744. private _closestFace;
  104745. private _zeroVector;
  104746. private _lookAtTmpMatrix;
  104747. private _lookAtToRef;
  104748. /**
  104749. * Attaches the AttachToBoxBehavior to the passed in mesh
  104750. * @param target The mesh that the specified node will be attached to
  104751. */
  104752. attach(target: Mesh): void;
  104753. /**
  104754. * Detaches the behavior from the mesh
  104755. */
  104756. detach(): void;
  104757. }
  104758. }
  104759. declare module BABYLON {
  104760. /**
  104761. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104762. */
  104763. export class FadeInOutBehavior implements Behavior<Mesh> {
  104764. /**
  104765. * Time in milliseconds to delay before fading in (Default: 0)
  104766. */
  104767. delay: number;
  104768. /**
  104769. * Time in milliseconds for the mesh to fade in (Default: 300)
  104770. */
  104771. fadeInTime: number;
  104772. private _millisecondsPerFrame;
  104773. private _hovered;
  104774. private _hoverValue;
  104775. private _ownerNode;
  104776. /**
  104777. * Instatiates the FadeInOutBehavior
  104778. */
  104779. constructor();
  104780. /**
  104781. * The name of the behavior
  104782. */
  104783. readonly name: string;
  104784. /**
  104785. * Initializes the behavior
  104786. */
  104787. init(): void;
  104788. /**
  104789. * Attaches the fade behavior on the passed in mesh
  104790. * @param ownerNode The mesh that will be faded in/out once attached
  104791. */
  104792. attach(ownerNode: Mesh): void;
  104793. /**
  104794. * Detaches the behavior from the mesh
  104795. */
  104796. detach(): void;
  104797. /**
  104798. * Triggers the mesh to begin fading in or out
  104799. * @param value if the object should fade in or out (true to fade in)
  104800. */
  104801. fadeIn(value: boolean): void;
  104802. private _update;
  104803. private _setAllVisibility;
  104804. }
  104805. }
  104806. declare module BABYLON {
  104807. /**
  104808. * Class containing a set of static utilities functions for managing Pivots
  104809. * @hidden
  104810. */
  104811. export class PivotTools {
  104812. private static _PivotCached;
  104813. private static _OldPivotPoint;
  104814. private static _PivotTranslation;
  104815. private static _PivotTmpVector;
  104816. /** @hidden */
  104817. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104818. /** @hidden */
  104819. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104820. }
  104821. }
  104822. declare module BABYLON {
  104823. /**
  104824. * Class containing static functions to help procedurally build meshes
  104825. */
  104826. export class PlaneBuilder {
  104827. /**
  104828. * Creates a plane mesh
  104829. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104830. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104831. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104835. * @param name defines the name of the mesh
  104836. * @param options defines the options used to create the mesh
  104837. * @param scene defines the hosting scene
  104838. * @returns the plane mesh
  104839. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104840. */
  104841. static CreatePlane(name: string, options: {
  104842. size?: number;
  104843. width?: number;
  104844. height?: number;
  104845. sideOrientation?: number;
  104846. frontUVs?: Vector4;
  104847. backUVs?: Vector4;
  104848. updatable?: boolean;
  104849. sourcePlane?: Plane;
  104850. }, scene?: Nullable<Scene>): Mesh;
  104851. }
  104852. }
  104853. declare module BABYLON {
  104854. /**
  104855. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104856. */
  104857. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104858. private static _AnyMouseID;
  104859. /**
  104860. * Abstract mesh the behavior is set on
  104861. */
  104862. attachedNode: AbstractMesh;
  104863. private _dragPlane;
  104864. private _scene;
  104865. private _pointerObserver;
  104866. private _beforeRenderObserver;
  104867. private static _planeScene;
  104868. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104869. /**
  104870. * 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)
  104871. */
  104872. maxDragAngle: number;
  104873. /**
  104874. * @hidden
  104875. */
  104876. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104877. /**
  104878. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104879. */
  104880. currentDraggingPointerID: number;
  104881. /**
  104882. * The last position where the pointer hit the drag plane in world space
  104883. */
  104884. lastDragPosition: Vector3;
  104885. /**
  104886. * If the behavior is currently in a dragging state
  104887. */
  104888. dragging: boolean;
  104889. /**
  104890. * 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)
  104891. */
  104892. dragDeltaRatio: number;
  104893. /**
  104894. * If the drag plane orientation should be updated during the dragging (Default: true)
  104895. */
  104896. updateDragPlane: boolean;
  104897. private _debugMode;
  104898. private _moving;
  104899. /**
  104900. * Fires each time the attached mesh is dragged with the pointer
  104901. * * delta between last drag position and current drag position in world space
  104902. * * dragDistance along the drag axis
  104903. * * dragPlaneNormal normal of the current drag plane used during the drag
  104904. * * dragPlanePoint in world space where the drag intersects the drag plane
  104905. */
  104906. onDragObservable: Observable<{
  104907. delta: Vector3;
  104908. dragPlanePoint: Vector3;
  104909. dragPlaneNormal: Vector3;
  104910. dragDistance: number;
  104911. pointerId: number;
  104912. }>;
  104913. /**
  104914. * Fires each time a drag begins (eg. mouse down on mesh)
  104915. */
  104916. onDragStartObservable: Observable<{
  104917. dragPlanePoint: Vector3;
  104918. pointerId: number;
  104919. }>;
  104920. /**
  104921. * Fires each time a drag ends (eg. mouse release after drag)
  104922. */
  104923. onDragEndObservable: Observable<{
  104924. dragPlanePoint: Vector3;
  104925. pointerId: number;
  104926. }>;
  104927. /**
  104928. * If the attached mesh should be moved when dragged
  104929. */
  104930. moveAttached: boolean;
  104931. /**
  104932. * If the drag behavior will react to drag events (Default: true)
  104933. */
  104934. enabled: boolean;
  104935. /**
  104936. * If pointer events should start and release the drag (Default: true)
  104937. */
  104938. startAndReleaseDragOnPointerEvents: boolean;
  104939. /**
  104940. * If camera controls should be detached during the drag
  104941. */
  104942. detachCameraControls: boolean;
  104943. /**
  104944. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104945. */
  104946. useObjectOrienationForDragging: boolean;
  104947. private _options;
  104948. /**
  104949. * Creates a pointer drag behavior that can be attached to a mesh
  104950. * @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)
  104951. */
  104952. constructor(options?: {
  104953. dragAxis?: Vector3;
  104954. dragPlaneNormal?: Vector3;
  104955. });
  104956. /**
  104957. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104958. */
  104959. validateDrag: (targetPosition: Vector3) => boolean;
  104960. /**
  104961. * The name of the behavior
  104962. */
  104963. readonly name: string;
  104964. /**
  104965. * Initializes the behavior
  104966. */
  104967. init(): void;
  104968. private _tmpVector;
  104969. private _alternatePickedPoint;
  104970. private _worldDragAxis;
  104971. private _targetPosition;
  104972. private _attachedElement;
  104973. /**
  104974. * Attaches the drag behavior the passed in mesh
  104975. * @param ownerNode The mesh that will be dragged around once attached
  104976. * @param predicate Predicate to use for pick filtering
  104977. */
  104978. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104979. /**
  104980. * Force relase the drag action by code.
  104981. */
  104982. releaseDrag(): void;
  104983. private _startDragRay;
  104984. private _lastPointerRay;
  104985. /**
  104986. * Simulates the start of a pointer drag event on the behavior
  104987. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104988. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104989. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104990. */
  104991. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104992. private _startDrag;
  104993. private _dragDelta;
  104994. private _moveDrag;
  104995. private _pickWithRayOnDragPlane;
  104996. private _pointA;
  104997. private _pointB;
  104998. private _pointC;
  104999. private _lineA;
  105000. private _lineB;
  105001. private _localAxis;
  105002. private _lookAt;
  105003. private _updateDragPlanePosition;
  105004. /**
  105005. * Detaches the behavior from the mesh
  105006. */
  105007. detach(): void;
  105008. }
  105009. }
  105010. declare module BABYLON {
  105011. /**
  105012. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105013. */
  105014. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105015. private _dragBehaviorA;
  105016. private _dragBehaviorB;
  105017. private _startDistance;
  105018. private _initialScale;
  105019. private _targetScale;
  105020. private _ownerNode;
  105021. private _sceneRenderObserver;
  105022. /**
  105023. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105024. */
  105025. constructor();
  105026. /**
  105027. * The name of the behavior
  105028. */
  105029. readonly name: string;
  105030. /**
  105031. * Initializes the behavior
  105032. */
  105033. init(): void;
  105034. private _getCurrentDistance;
  105035. /**
  105036. * Attaches the scale behavior the passed in mesh
  105037. * @param ownerNode The mesh that will be scaled around once attached
  105038. */
  105039. attach(ownerNode: Mesh): void;
  105040. /**
  105041. * Detaches the behavior from the mesh
  105042. */
  105043. detach(): void;
  105044. }
  105045. }
  105046. declare module BABYLON {
  105047. /**
  105048. * 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
  105049. */
  105050. export class SixDofDragBehavior implements Behavior<Mesh> {
  105051. private static _virtualScene;
  105052. private _ownerNode;
  105053. private _sceneRenderObserver;
  105054. private _scene;
  105055. private _targetPosition;
  105056. private _virtualOriginMesh;
  105057. private _virtualDragMesh;
  105058. private _pointerObserver;
  105059. private _moving;
  105060. private _startingOrientation;
  105061. /**
  105062. * 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)
  105063. */
  105064. private zDragFactor;
  105065. /**
  105066. * If the object should rotate to face the drag origin
  105067. */
  105068. rotateDraggedObject: boolean;
  105069. /**
  105070. * If the behavior is currently in a dragging state
  105071. */
  105072. dragging: boolean;
  105073. /**
  105074. * 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)
  105075. */
  105076. dragDeltaRatio: number;
  105077. /**
  105078. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105079. */
  105080. currentDraggingPointerID: number;
  105081. /**
  105082. * If camera controls should be detached during the drag
  105083. */
  105084. detachCameraControls: boolean;
  105085. /**
  105086. * Fires each time a drag starts
  105087. */
  105088. onDragStartObservable: Observable<{}>;
  105089. /**
  105090. * Fires each time a drag ends (eg. mouse release after drag)
  105091. */
  105092. onDragEndObservable: Observable<{}>;
  105093. /**
  105094. * 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
  105095. */
  105096. constructor();
  105097. /**
  105098. * The name of the behavior
  105099. */
  105100. readonly name: string;
  105101. /**
  105102. * Initializes the behavior
  105103. */
  105104. init(): void;
  105105. /**
  105106. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105107. */
  105108. private readonly _pointerCamera;
  105109. /**
  105110. * Attaches the scale behavior the passed in mesh
  105111. * @param ownerNode The mesh that will be scaled around once attached
  105112. */
  105113. attach(ownerNode: Mesh): void;
  105114. /**
  105115. * Detaches the behavior from the mesh
  105116. */
  105117. detach(): void;
  105118. }
  105119. }
  105120. declare module BABYLON {
  105121. /**
  105122. * Class used to apply inverse kinematics to bones
  105123. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105124. */
  105125. export class BoneIKController {
  105126. private static _tmpVecs;
  105127. private static _tmpQuat;
  105128. private static _tmpMats;
  105129. /**
  105130. * Gets or sets the target mesh
  105131. */
  105132. targetMesh: AbstractMesh;
  105133. /** Gets or sets the mesh used as pole */
  105134. poleTargetMesh: AbstractMesh;
  105135. /**
  105136. * Gets or sets the bone used as pole
  105137. */
  105138. poleTargetBone: Nullable<Bone>;
  105139. /**
  105140. * Gets or sets the target position
  105141. */
  105142. targetPosition: Vector3;
  105143. /**
  105144. * Gets or sets the pole target position
  105145. */
  105146. poleTargetPosition: Vector3;
  105147. /**
  105148. * Gets or sets the pole target local offset
  105149. */
  105150. poleTargetLocalOffset: Vector3;
  105151. /**
  105152. * Gets or sets the pole angle
  105153. */
  105154. poleAngle: number;
  105155. /**
  105156. * Gets or sets the mesh associated with the controller
  105157. */
  105158. mesh: AbstractMesh;
  105159. /**
  105160. * 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)
  105161. */
  105162. slerpAmount: number;
  105163. private _bone1Quat;
  105164. private _bone1Mat;
  105165. private _bone2Ang;
  105166. private _bone1;
  105167. private _bone2;
  105168. private _bone1Length;
  105169. private _bone2Length;
  105170. private _maxAngle;
  105171. private _maxReach;
  105172. private _rightHandedSystem;
  105173. private _bendAxis;
  105174. private _slerping;
  105175. private _adjustRoll;
  105176. /**
  105177. * Gets or sets maximum allowed angle
  105178. */
  105179. maxAngle: number;
  105180. /**
  105181. * Creates a new BoneIKController
  105182. * @param mesh defines the mesh to control
  105183. * @param bone defines the bone to control
  105184. * @param options defines options to set up the controller
  105185. */
  105186. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105187. targetMesh?: AbstractMesh;
  105188. poleTargetMesh?: AbstractMesh;
  105189. poleTargetBone?: Bone;
  105190. poleTargetLocalOffset?: Vector3;
  105191. poleAngle?: number;
  105192. bendAxis?: Vector3;
  105193. maxAngle?: number;
  105194. slerpAmount?: number;
  105195. });
  105196. private _setMaxAngle;
  105197. /**
  105198. * Force the controller to update the bones
  105199. */
  105200. update(): void;
  105201. }
  105202. }
  105203. declare module BABYLON {
  105204. /**
  105205. * Class used to make a bone look toward a point in space
  105206. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105207. */
  105208. export class BoneLookController {
  105209. private static _tmpVecs;
  105210. private static _tmpQuat;
  105211. private static _tmpMats;
  105212. /**
  105213. * The target Vector3 that the bone will look at
  105214. */
  105215. target: Vector3;
  105216. /**
  105217. * The mesh that the bone is attached to
  105218. */
  105219. mesh: AbstractMesh;
  105220. /**
  105221. * The bone that will be looking to the target
  105222. */
  105223. bone: Bone;
  105224. /**
  105225. * The up axis of the coordinate system that is used when the bone is rotated
  105226. */
  105227. upAxis: Vector3;
  105228. /**
  105229. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105230. */
  105231. upAxisSpace: Space;
  105232. /**
  105233. * Used to make an adjustment to the yaw of the bone
  105234. */
  105235. adjustYaw: number;
  105236. /**
  105237. * Used to make an adjustment to the pitch of the bone
  105238. */
  105239. adjustPitch: number;
  105240. /**
  105241. * Used to make an adjustment to the roll of the bone
  105242. */
  105243. adjustRoll: number;
  105244. /**
  105245. * 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)
  105246. */
  105247. slerpAmount: number;
  105248. private _minYaw;
  105249. private _maxYaw;
  105250. private _minPitch;
  105251. private _maxPitch;
  105252. private _minYawSin;
  105253. private _minYawCos;
  105254. private _maxYawSin;
  105255. private _maxYawCos;
  105256. private _midYawConstraint;
  105257. private _minPitchTan;
  105258. private _maxPitchTan;
  105259. private _boneQuat;
  105260. private _slerping;
  105261. private _transformYawPitch;
  105262. private _transformYawPitchInv;
  105263. private _firstFrameSkipped;
  105264. private _yawRange;
  105265. private _fowardAxis;
  105266. /**
  105267. * Gets or sets the minimum yaw angle that the bone can look to
  105268. */
  105269. minYaw: number;
  105270. /**
  105271. * Gets or sets the maximum yaw angle that the bone can look to
  105272. */
  105273. maxYaw: number;
  105274. /**
  105275. * Gets or sets the minimum pitch angle that the bone can look to
  105276. */
  105277. minPitch: number;
  105278. /**
  105279. * Gets or sets the maximum pitch angle that the bone can look to
  105280. */
  105281. maxPitch: number;
  105282. /**
  105283. * Create a BoneLookController
  105284. * @param mesh the mesh that the bone belongs to
  105285. * @param bone the bone that will be looking to the target
  105286. * @param target the target Vector3 to look at
  105287. * @param options optional settings:
  105288. * * maxYaw: the maximum angle the bone will yaw to
  105289. * * minYaw: the minimum angle the bone will yaw to
  105290. * * maxPitch: the maximum angle the bone will pitch to
  105291. * * minPitch: the minimum angle the bone will yaw to
  105292. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105293. * * upAxis: the up axis of the coordinate system
  105294. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105295. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105296. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105297. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105298. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105299. * * adjustRoll: used to make an adjustment to the roll of the bone
  105300. **/
  105301. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105302. maxYaw?: number;
  105303. minYaw?: number;
  105304. maxPitch?: number;
  105305. minPitch?: number;
  105306. slerpAmount?: number;
  105307. upAxis?: Vector3;
  105308. upAxisSpace?: Space;
  105309. yawAxis?: Vector3;
  105310. pitchAxis?: Vector3;
  105311. adjustYaw?: number;
  105312. adjustPitch?: number;
  105313. adjustRoll?: number;
  105314. });
  105315. /**
  105316. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105317. */
  105318. update(): void;
  105319. private _getAngleDiff;
  105320. private _getAngleBetween;
  105321. private _isAngleBetween;
  105322. }
  105323. }
  105324. declare module BABYLON {
  105325. /**
  105326. * Manage the gamepad inputs to control an arc rotate camera.
  105327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105328. */
  105329. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105330. /**
  105331. * Defines the camera the input is attached to.
  105332. */
  105333. camera: ArcRotateCamera;
  105334. /**
  105335. * Defines the gamepad the input is gathering event from.
  105336. */
  105337. gamepad: Nullable<Gamepad>;
  105338. /**
  105339. * Defines the gamepad rotation sensiblity.
  105340. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105341. */
  105342. gamepadRotationSensibility: number;
  105343. /**
  105344. * Defines the gamepad move sensiblity.
  105345. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105346. */
  105347. gamepadMoveSensibility: number;
  105348. private _yAxisScale;
  105349. /**
  105350. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105351. */
  105352. invertYAxis: boolean;
  105353. private _onGamepadConnectedObserver;
  105354. private _onGamepadDisconnectedObserver;
  105355. /**
  105356. * Attach the input controls to a specific dom element to get the input from.
  105357. * @param element Defines the element the controls should be listened from
  105358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105359. */
  105360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105361. /**
  105362. * Detach the current controls from the specified dom element.
  105363. * @param element Defines the element to stop listening the inputs from
  105364. */
  105365. detachControl(element: Nullable<HTMLElement>): void;
  105366. /**
  105367. * Update the current camera state depending on the inputs that have been used this frame.
  105368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105369. */
  105370. checkInputs(): void;
  105371. /**
  105372. * Gets the class name of the current intput.
  105373. * @returns the class name
  105374. */
  105375. getClassName(): string;
  105376. /**
  105377. * Get the friendly name associated with the input class.
  105378. * @returns the input friendly name
  105379. */
  105380. getSimpleName(): string;
  105381. }
  105382. }
  105383. declare module BABYLON {
  105384. interface ArcRotateCameraInputsManager {
  105385. /**
  105386. * Add orientation input support to the input manager.
  105387. * @returns the current input manager
  105388. */
  105389. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105390. }
  105391. /**
  105392. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105394. */
  105395. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105396. /**
  105397. * Defines the camera the input is attached to.
  105398. */
  105399. camera: ArcRotateCamera;
  105400. /**
  105401. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105402. */
  105403. alphaCorrection: number;
  105404. /**
  105405. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105406. */
  105407. gammaCorrection: number;
  105408. private _alpha;
  105409. private _gamma;
  105410. private _dirty;
  105411. private _deviceOrientationHandler;
  105412. /**
  105413. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105414. */
  105415. constructor();
  105416. /**
  105417. * Attach the input controls to a specific dom element to get the input from.
  105418. * @param element Defines the element the controls should be listened from
  105419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105420. */
  105421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105422. /** @hidden */
  105423. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105424. /**
  105425. * Update the current camera state depending on the inputs that have been used this frame.
  105426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105427. */
  105428. checkInputs(): void;
  105429. /**
  105430. * Detach the current controls from the specified dom element.
  105431. * @param element Defines the element to stop listening the inputs from
  105432. */
  105433. detachControl(element: Nullable<HTMLElement>): void;
  105434. /**
  105435. * Gets the class name of the current intput.
  105436. * @returns the class name
  105437. */
  105438. getClassName(): string;
  105439. /**
  105440. * Get the friendly name associated with the input class.
  105441. * @returns the input friendly name
  105442. */
  105443. getSimpleName(): string;
  105444. }
  105445. }
  105446. declare module BABYLON {
  105447. /**
  105448. * Listen to mouse events to control the camera.
  105449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105450. */
  105451. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105452. /**
  105453. * Defines the camera the input is attached to.
  105454. */
  105455. camera: FlyCamera;
  105456. /**
  105457. * Defines if touch is enabled. (Default is true.)
  105458. */
  105459. touchEnabled: boolean;
  105460. /**
  105461. * Defines the buttons associated with the input to handle camera rotation.
  105462. */
  105463. buttons: number[];
  105464. /**
  105465. * Assign buttons for Yaw control.
  105466. */
  105467. buttonsYaw: number[];
  105468. /**
  105469. * Assign buttons for Pitch control.
  105470. */
  105471. buttonsPitch: number[];
  105472. /**
  105473. * Assign buttons for Roll control.
  105474. */
  105475. buttonsRoll: number[];
  105476. /**
  105477. * Detect if any button is being pressed while mouse is moved.
  105478. * -1 = Mouse locked.
  105479. * 0 = Left button.
  105480. * 1 = Middle Button.
  105481. * 2 = Right Button.
  105482. */
  105483. activeButton: number;
  105484. /**
  105485. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105486. * Higher values reduce its sensitivity.
  105487. */
  105488. angularSensibility: number;
  105489. private _mousemoveCallback;
  105490. private _observer;
  105491. private _rollObserver;
  105492. private previousPosition;
  105493. private noPreventDefault;
  105494. private element;
  105495. /**
  105496. * Listen to mouse events to control the camera.
  105497. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105499. */
  105500. constructor(touchEnabled?: boolean);
  105501. /**
  105502. * Attach the mouse control to the HTML DOM element.
  105503. * @param element Defines the element that listens to the input events.
  105504. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105505. */
  105506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105507. /**
  105508. * Detach the current controls from the specified dom element.
  105509. * @param element Defines the element to stop listening the inputs from
  105510. */
  105511. detachControl(element: Nullable<HTMLElement>): void;
  105512. /**
  105513. * Gets the class name of the current input.
  105514. * @returns the class name.
  105515. */
  105516. getClassName(): string;
  105517. /**
  105518. * Get the friendly name associated with the input class.
  105519. * @returns the input's friendly name.
  105520. */
  105521. getSimpleName(): string;
  105522. private _pointerInput;
  105523. private _onMouseMove;
  105524. /**
  105525. * Rotate camera by mouse offset.
  105526. */
  105527. private rotateCamera;
  105528. }
  105529. }
  105530. declare module BABYLON {
  105531. /**
  105532. * Default Inputs manager for the FlyCamera.
  105533. * It groups all the default supported inputs for ease of use.
  105534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105535. */
  105536. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105537. /**
  105538. * Instantiates a new FlyCameraInputsManager.
  105539. * @param camera Defines the camera the inputs belong to.
  105540. */
  105541. constructor(camera: FlyCamera);
  105542. /**
  105543. * Add keyboard input support to the input manager.
  105544. * @returns the new FlyCameraKeyboardMoveInput().
  105545. */
  105546. addKeyboard(): FlyCameraInputsManager;
  105547. /**
  105548. * Add mouse input support to the input manager.
  105549. * @param touchEnabled Enable touch screen support.
  105550. * @returns the new FlyCameraMouseInput().
  105551. */
  105552. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105553. }
  105554. }
  105555. declare module BABYLON {
  105556. /**
  105557. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105558. * such as in a 3D Space Shooter or a Flight Simulator.
  105559. */
  105560. export class FlyCamera extends TargetCamera {
  105561. /**
  105562. * Define the collision ellipsoid of the camera.
  105563. * This is helpful for simulating a camera body, like a player's body.
  105564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105565. */
  105566. ellipsoid: Vector3;
  105567. /**
  105568. * Define an offset for the position of the ellipsoid around the camera.
  105569. * This can be helpful if the camera is attached away from the player's body center,
  105570. * such as at its head.
  105571. */
  105572. ellipsoidOffset: Vector3;
  105573. /**
  105574. * Enable or disable collisions of the camera with the rest of the scene objects.
  105575. */
  105576. checkCollisions: boolean;
  105577. /**
  105578. * Enable or disable gravity on the camera.
  105579. */
  105580. applyGravity: boolean;
  105581. /**
  105582. * Define the current direction the camera is moving to.
  105583. */
  105584. cameraDirection: Vector3;
  105585. /**
  105586. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105587. * This overrides and empties cameraRotation.
  105588. */
  105589. rotationQuaternion: Quaternion;
  105590. /**
  105591. * Track Roll to maintain the wanted Rolling when looking around.
  105592. */
  105593. _trackRoll: number;
  105594. /**
  105595. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105596. */
  105597. rollCorrect: number;
  105598. /**
  105599. * Mimic a banked turn, Rolling the camera when Yawing.
  105600. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105601. */
  105602. bankedTurn: boolean;
  105603. /**
  105604. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105605. */
  105606. bankedTurnLimit: number;
  105607. /**
  105608. * Value of 0 disables the banked Roll.
  105609. * Value of 1 is equal to the Yaw angle in radians.
  105610. */
  105611. bankedTurnMultiplier: number;
  105612. /**
  105613. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105614. */
  105615. inputs: FlyCameraInputsManager;
  105616. /**
  105617. * Gets the input sensibility for mouse input.
  105618. * Higher values reduce sensitivity.
  105619. */
  105620. /**
  105621. * Sets the input sensibility for a mouse input.
  105622. * Higher values reduce sensitivity.
  105623. */
  105624. angularSensibility: number;
  105625. /**
  105626. * Get the keys for camera movement forward.
  105627. */
  105628. /**
  105629. * Set the keys for camera movement forward.
  105630. */
  105631. keysForward: number[];
  105632. /**
  105633. * Get the keys for camera movement backward.
  105634. */
  105635. keysBackward: number[];
  105636. /**
  105637. * Get the keys for camera movement up.
  105638. */
  105639. /**
  105640. * Set the keys for camera movement up.
  105641. */
  105642. keysUp: number[];
  105643. /**
  105644. * Get the keys for camera movement down.
  105645. */
  105646. /**
  105647. * Set the keys for camera movement down.
  105648. */
  105649. keysDown: number[];
  105650. /**
  105651. * Get the keys for camera movement left.
  105652. */
  105653. /**
  105654. * Set the keys for camera movement left.
  105655. */
  105656. keysLeft: number[];
  105657. /**
  105658. * Set the keys for camera movement right.
  105659. */
  105660. /**
  105661. * Set the keys for camera movement right.
  105662. */
  105663. keysRight: number[];
  105664. /**
  105665. * Event raised when the camera collides with a mesh in the scene.
  105666. */
  105667. onCollide: (collidedMesh: AbstractMesh) => void;
  105668. private _collider;
  105669. private _needMoveForGravity;
  105670. private _oldPosition;
  105671. private _diffPosition;
  105672. private _newPosition;
  105673. /** @hidden */
  105674. _localDirection: Vector3;
  105675. /** @hidden */
  105676. _transformedDirection: Vector3;
  105677. /**
  105678. * Instantiates a FlyCamera.
  105679. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105680. * such as in a 3D Space Shooter or a Flight Simulator.
  105681. * @param name Define the name of the camera in the scene.
  105682. * @param position Define the starting position of the camera in the scene.
  105683. * @param scene Define the scene the camera belongs to.
  105684. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105685. */
  105686. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105687. /**
  105688. * Attach a control to the HTML DOM element.
  105689. * @param element Defines the element that listens to the input events.
  105690. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105691. */
  105692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105693. /**
  105694. * Detach a control from the HTML DOM element.
  105695. * The camera will stop reacting to that input.
  105696. * @param element Defines the element that listens to the input events.
  105697. */
  105698. detachControl(element: HTMLElement): void;
  105699. private _collisionMask;
  105700. /**
  105701. * Get the mask that the camera ignores in collision events.
  105702. */
  105703. /**
  105704. * Set the mask that the camera ignores in collision events.
  105705. */
  105706. collisionMask: number;
  105707. /** @hidden */
  105708. _collideWithWorld(displacement: Vector3): void;
  105709. /** @hidden */
  105710. private _onCollisionPositionChange;
  105711. /** @hidden */
  105712. _checkInputs(): void;
  105713. /** @hidden */
  105714. _decideIfNeedsToMove(): boolean;
  105715. /** @hidden */
  105716. _updatePosition(): void;
  105717. /**
  105718. * Restore the Roll to its target value at the rate specified.
  105719. * @param rate - Higher means slower restoring.
  105720. * @hidden
  105721. */
  105722. restoreRoll(rate: number): void;
  105723. /**
  105724. * Destroy the camera and release the current resources held by it.
  105725. */
  105726. dispose(): void;
  105727. /**
  105728. * Get the current object class name.
  105729. * @returns the class name.
  105730. */
  105731. getClassName(): string;
  105732. }
  105733. }
  105734. declare module BABYLON {
  105735. /**
  105736. * Listen to keyboard events to control the camera.
  105737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105738. */
  105739. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105740. /**
  105741. * Defines the camera the input is attached to.
  105742. */
  105743. camera: FlyCamera;
  105744. /**
  105745. * The list of keyboard keys used to control the forward move of the camera.
  105746. */
  105747. keysForward: number[];
  105748. /**
  105749. * The list of keyboard keys used to control the backward move of the camera.
  105750. */
  105751. keysBackward: number[];
  105752. /**
  105753. * The list of keyboard keys used to control the forward move of the camera.
  105754. */
  105755. keysUp: number[];
  105756. /**
  105757. * The list of keyboard keys used to control the backward move of the camera.
  105758. */
  105759. keysDown: number[];
  105760. /**
  105761. * The list of keyboard keys used to control the right strafe move of the camera.
  105762. */
  105763. keysRight: number[];
  105764. /**
  105765. * The list of keyboard keys used to control the left strafe move of the camera.
  105766. */
  105767. keysLeft: number[];
  105768. private _keys;
  105769. private _onCanvasBlurObserver;
  105770. private _onKeyboardObserver;
  105771. private _engine;
  105772. private _scene;
  105773. /**
  105774. * Attach the input controls to a specific dom element to get the input from.
  105775. * @param element Defines the element the controls should be listened from
  105776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105777. */
  105778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105779. /**
  105780. * Detach the current controls from the specified dom element.
  105781. * @param element Defines the element to stop listening the inputs from
  105782. */
  105783. detachControl(element: Nullable<HTMLElement>): void;
  105784. /**
  105785. * Gets the class name of the current intput.
  105786. * @returns the class name
  105787. */
  105788. getClassName(): string;
  105789. /** @hidden */
  105790. _onLostFocus(e: FocusEvent): void;
  105791. /**
  105792. * Get the friendly name associated with the input class.
  105793. * @returns the input friendly name
  105794. */
  105795. getSimpleName(): string;
  105796. /**
  105797. * Update the current camera state depending on the inputs that have been used this frame.
  105798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105799. */
  105800. checkInputs(): void;
  105801. }
  105802. }
  105803. declare module BABYLON {
  105804. /**
  105805. * Manage the mouse wheel inputs to control a follow camera.
  105806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105807. */
  105808. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105809. /**
  105810. * Defines the camera the input is attached to.
  105811. */
  105812. camera: FollowCamera;
  105813. /**
  105814. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105815. */
  105816. axisControlRadius: boolean;
  105817. /**
  105818. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105819. */
  105820. axisControlHeight: boolean;
  105821. /**
  105822. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105823. */
  105824. axisControlRotation: boolean;
  105825. /**
  105826. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105827. * relation to mouseWheel events.
  105828. */
  105829. wheelPrecision: number;
  105830. /**
  105831. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105832. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105833. */
  105834. wheelDeltaPercentage: number;
  105835. private _wheel;
  105836. private _observer;
  105837. /**
  105838. * Attach the input controls to a specific dom element to get the input from.
  105839. * @param element Defines the element the controls should be listened from
  105840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105841. */
  105842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105843. /**
  105844. * Detach the current controls from the specified dom element.
  105845. * @param element Defines the element to stop listening the inputs from
  105846. */
  105847. detachControl(element: Nullable<HTMLElement>): void;
  105848. /**
  105849. * Gets the class name of the current intput.
  105850. * @returns the class name
  105851. */
  105852. getClassName(): string;
  105853. /**
  105854. * Get the friendly name associated with the input class.
  105855. * @returns the input friendly name
  105856. */
  105857. getSimpleName(): string;
  105858. }
  105859. }
  105860. declare module BABYLON {
  105861. /**
  105862. * Manage the pointers inputs to control an follow camera.
  105863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105864. */
  105865. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105866. /**
  105867. * Defines the camera the input is attached to.
  105868. */
  105869. camera: FollowCamera;
  105870. /**
  105871. * Gets the class name of the current input.
  105872. * @returns the class name
  105873. */
  105874. getClassName(): string;
  105875. /**
  105876. * Defines the pointer angular sensibility along the X axis or how fast is
  105877. * the camera rotating.
  105878. * A negative number will reverse the axis direction.
  105879. */
  105880. angularSensibilityX: number;
  105881. /**
  105882. * Defines the pointer angular sensibility along the Y axis or how fast is
  105883. * the camera rotating.
  105884. * A negative number will reverse the axis direction.
  105885. */
  105886. angularSensibilityY: number;
  105887. /**
  105888. * Defines the pointer pinch precision or how fast is the camera zooming.
  105889. * A negative number will reverse the axis direction.
  105890. */
  105891. pinchPrecision: number;
  105892. /**
  105893. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105894. * from 0.
  105895. * It defines the percentage of current camera.radius to use as delta when
  105896. * pinch zoom is used.
  105897. */
  105898. pinchDeltaPercentage: number;
  105899. /**
  105900. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105901. */
  105902. axisXControlRadius: boolean;
  105903. /**
  105904. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105905. */
  105906. axisXControlHeight: boolean;
  105907. /**
  105908. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105909. */
  105910. axisXControlRotation: boolean;
  105911. /**
  105912. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105913. */
  105914. axisYControlRadius: boolean;
  105915. /**
  105916. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105917. */
  105918. axisYControlHeight: boolean;
  105919. /**
  105920. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105921. */
  105922. axisYControlRotation: boolean;
  105923. /**
  105924. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105925. */
  105926. axisPinchControlRadius: boolean;
  105927. /**
  105928. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105929. */
  105930. axisPinchControlHeight: boolean;
  105931. /**
  105932. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105933. */
  105934. axisPinchControlRotation: boolean;
  105935. /**
  105936. * Log error messages if basic misconfiguration has occurred.
  105937. */
  105938. warningEnable: boolean;
  105939. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105940. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105941. private _warningCounter;
  105942. private _warning;
  105943. }
  105944. }
  105945. declare module BABYLON {
  105946. /**
  105947. * Default Inputs manager for the FollowCamera.
  105948. * It groups all the default supported inputs for ease of use.
  105949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105950. */
  105951. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105952. /**
  105953. * Instantiates a new FollowCameraInputsManager.
  105954. * @param camera Defines the camera the inputs belong to
  105955. */
  105956. constructor(camera: FollowCamera);
  105957. /**
  105958. * Add keyboard input support to the input manager.
  105959. * @returns the current input manager
  105960. */
  105961. addKeyboard(): FollowCameraInputsManager;
  105962. /**
  105963. * Add mouse wheel input support to the input manager.
  105964. * @returns the current input manager
  105965. */
  105966. addMouseWheel(): FollowCameraInputsManager;
  105967. /**
  105968. * Add pointers input support to the input manager.
  105969. * @returns the current input manager
  105970. */
  105971. addPointers(): FollowCameraInputsManager;
  105972. /**
  105973. * Add orientation input support to the input manager.
  105974. * @returns the current input manager
  105975. */
  105976. addVRDeviceOrientation(): FollowCameraInputsManager;
  105977. }
  105978. }
  105979. declare module BABYLON {
  105980. /**
  105981. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105982. * an arc rotate version arcFollowCamera are available.
  105983. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105984. */
  105985. export class FollowCamera extends TargetCamera {
  105986. /**
  105987. * Distance the follow camera should follow an object at
  105988. */
  105989. radius: number;
  105990. /**
  105991. * Minimum allowed distance of the camera to the axis of rotation
  105992. * (The camera can not get closer).
  105993. * This can help limiting how the Camera is able to move in the scene.
  105994. */
  105995. lowerRadiusLimit: Nullable<number>;
  105996. /**
  105997. * Maximum allowed distance of the camera to the axis of rotation
  105998. * (The camera can not get further).
  105999. * This can help limiting how the Camera is able to move in the scene.
  106000. */
  106001. upperRadiusLimit: Nullable<number>;
  106002. /**
  106003. * Define a rotation offset between the camera and the object it follows
  106004. */
  106005. rotationOffset: number;
  106006. /**
  106007. * Minimum allowed angle to camera position relative to target object.
  106008. * This can help limiting how the Camera is able to move in the scene.
  106009. */
  106010. lowerRotationOffsetLimit: Nullable<number>;
  106011. /**
  106012. * Maximum allowed angle to camera position relative to target object.
  106013. * This can help limiting how the Camera is able to move in the scene.
  106014. */
  106015. upperRotationOffsetLimit: Nullable<number>;
  106016. /**
  106017. * Define a height offset between the camera and the object it follows.
  106018. * It can help following an object from the top (like a car chaing a plane)
  106019. */
  106020. heightOffset: number;
  106021. /**
  106022. * Minimum allowed height of camera position relative to target object.
  106023. * This can help limiting how the Camera is able to move in the scene.
  106024. */
  106025. lowerHeightOffsetLimit: Nullable<number>;
  106026. /**
  106027. * Maximum allowed height of camera position relative to target object.
  106028. * This can help limiting how the Camera is able to move in the scene.
  106029. */
  106030. upperHeightOffsetLimit: Nullable<number>;
  106031. /**
  106032. * Define how fast the camera can accelerate to follow it s target.
  106033. */
  106034. cameraAcceleration: number;
  106035. /**
  106036. * Define the speed limit of the camera following an object.
  106037. */
  106038. maxCameraSpeed: number;
  106039. /**
  106040. * Define the target of the camera.
  106041. */
  106042. lockedTarget: Nullable<AbstractMesh>;
  106043. /**
  106044. * Defines the input associated with the camera.
  106045. */
  106046. inputs: FollowCameraInputsManager;
  106047. /**
  106048. * Instantiates the follow camera.
  106049. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106050. * @param name Define the name of the camera in the scene
  106051. * @param position Define the position of the camera
  106052. * @param scene Define the scene the camera belong to
  106053. * @param lockedTarget Define the target of the camera
  106054. */
  106055. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106056. private _follow;
  106057. /**
  106058. * Attached controls to the current camera.
  106059. * @param element Defines the element the controls should be listened from
  106060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106061. */
  106062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106063. /**
  106064. * Detach the current controls from the camera.
  106065. * The camera will stop reacting to inputs.
  106066. * @param element Defines the element to stop listening the inputs from
  106067. */
  106068. detachControl(element: HTMLElement): void;
  106069. /** @hidden */
  106070. _checkInputs(): void;
  106071. private _checkLimits;
  106072. /**
  106073. * Gets the camera class name.
  106074. * @returns the class name
  106075. */
  106076. getClassName(): string;
  106077. }
  106078. /**
  106079. * Arc Rotate version of the follow camera.
  106080. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106081. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106082. */
  106083. export class ArcFollowCamera extends TargetCamera {
  106084. /** The longitudinal angle of the camera */
  106085. alpha: number;
  106086. /** The latitudinal angle of the camera */
  106087. beta: number;
  106088. /** The radius of the camera from its target */
  106089. radius: number;
  106090. /** Define the camera target (the messh it should follow) */
  106091. target: Nullable<AbstractMesh>;
  106092. private _cartesianCoordinates;
  106093. /**
  106094. * Instantiates a new ArcFollowCamera
  106095. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106096. * @param name Define the name of the camera
  106097. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106098. * @param beta Define the rotation angle of the camera around the elevation axis
  106099. * @param radius Define the radius of the camera from its target point
  106100. * @param target Define the target of the camera
  106101. * @param scene Define the scene the camera belongs to
  106102. */
  106103. constructor(name: string,
  106104. /** The longitudinal angle of the camera */
  106105. alpha: number,
  106106. /** The latitudinal angle of the camera */
  106107. beta: number,
  106108. /** The radius of the camera from its target */
  106109. radius: number,
  106110. /** Define the camera target (the messh it should follow) */
  106111. target: Nullable<AbstractMesh>, scene: Scene);
  106112. private _follow;
  106113. /** @hidden */
  106114. _checkInputs(): void;
  106115. /**
  106116. * Returns the class name of the object.
  106117. * It is mostly used internally for serialization purposes.
  106118. */
  106119. getClassName(): string;
  106120. }
  106121. }
  106122. declare module BABYLON {
  106123. /**
  106124. * Manage the keyboard inputs to control the movement of a follow camera.
  106125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106126. */
  106127. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106128. /**
  106129. * Defines the camera the input is attached to.
  106130. */
  106131. camera: FollowCamera;
  106132. /**
  106133. * Defines the list of key codes associated with the up action (increase heightOffset)
  106134. */
  106135. keysHeightOffsetIncr: number[];
  106136. /**
  106137. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106138. */
  106139. keysHeightOffsetDecr: number[];
  106140. /**
  106141. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106142. */
  106143. keysHeightOffsetModifierAlt: boolean;
  106144. /**
  106145. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106146. */
  106147. keysHeightOffsetModifierCtrl: boolean;
  106148. /**
  106149. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106150. */
  106151. keysHeightOffsetModifierShift: boolean;
  106152. /**
  106153. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106154. */
  106155. keysRotationOffsetIncr: number[];
  106156. /**
  106157. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106158. */
  106159. keysRotationOffsetDecr: number[];
  106160. /**
  106161. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106162. */
  106163. keysRotationOffsetModifierAlt: boolean;
  106164. /**
  106165. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106166. */
  106167. keysRotationOffsetModifierCtrl: boolean;
  106168. /**
  106169. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106170. */
  106171. keysRotationOffsetModifierShift: boolean;
  106172. /**
  106173. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106174. */
  106175. keysRadiusIncr: number[];
  106176. /**
  106177. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106178. */
  106179. keysRadiusDecr: number[];
  106180. /**
  106181. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106182. */
  106183. keysRadiusModifierAlt: boolean;
  106184. /**
  106185. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106186. */
  106187. keysRadiusModifierCtrl: boolean;
  106188. /**
  106189. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106190. */
  106191. keysRadiusModifierShift: boolean;
  106192. /**
  106193. * Defines the rate of change of heightOffset.
  106194. */
  106195. heightSensibility: number;
  106196. /**
  106197. * Defines the rate of change of rotationOffset.
  106198. */
  106199. rotationSensibility: number;
  106200. /**
  106201. * Defines the rate of change of radius.
  106202. */
  106203. radiusSensibility: number;
  106204. private _keys;
  106205. private _ctrlPressed;
  106206. private _altPressed;
  106207. private _shiftPressed;
  106208. private _onCanvasBlurObserver;
  106209. private _onKeyboardObserver;
  106210. private _engine;
  106211. private _scene;
  106212. /**
  106213. * Attach the input controls to a specific dom element to get the input from.
  106214. * @param element Defines the element the controls should be listened from
  106215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106216. */
  106217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106218. /**
  106219. * Detach the current controls from the specified dom element.
  106220. * @param element Defines the element to stop listening the inputs from
  106221. */
  106222. detachControl(element: Nullable<HTMLElement>): void;
  106223. /**
  106224. * Update the current camera state depending on the inputs that have been used this frame.
  106225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106226. */
  106227. checkInputs(): void;
  106228. /**
  106229. * Gets the class name of the current input.
  106230. * @returns the class name
  106231. */
  106232. getClassName(): string;
  106233. /**
  106234. * Get the friendly name associated with the input class.
  106235. * @returns the input friendly name
  106236. */
  106237. getSimpleName(): string;
  106238. /**
  106239. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106240. * allow modification of the heightOffset value.
  106241. */
  106242. private _modifierHeightOffset;
  106243. /**
  106244. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106245. * allow modification of the rotationOffset value.
  106246. */
  106247. private _modifierRotationOffset;
  106248. /**
  106249. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106250. * allow modification of the radius value.
  106251. */
  106252. private _modifierRadius;
  106253. }
  106254. }
  106255. declare module BABYLON {
  106256. interface FreeCameraInputsManager {
  106257. /**
  106258. * @hidden
  106259. */
  106260. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106261. /**
  106262. * Add orientation input support to the input manager.
  106263. * @returns the current input manager
  106264. */
  106265. addDeviceOrientation(): FreeCameraInputsManager;
  106266. }
  106267. /**
  106268. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106269. * Screen rotation is taken into account.
  106270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106271. */
  106272. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106273. private _camera;
  106274. private _screenOrientationAngle;
  106275. private _constantTranform;
  106276. private _screenQuaternion;
  106277. private _alpha;
  106278. private _beta;
  106279. private _gamma;
  106280. /**
  106281. * Can be used to detect if a device orientation sensor is availible on a device
  106282. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106283. * @returns a promise that will resolve on orientation change
  106284. */
  106285. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106286. /**
  106287. * @hidden
  106288. */
  106289. _onDeviceOrientationChangedObservable: Observable<void>;
  106290. /**
  106291. * Instantiates a new input
  106292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106293. */
  106294. constructor();
  106295. /**
  106296. * Define the camera controlled by the input.
  106297. */
  106298. camera: FreeCamera;
  106299. /**
  106300. * Attach the input controls to a specific dom element to get the input from.
  106301. * @param element Defines the element the controls should be listened from
  106302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106303. */
  106304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106305. private _orientationChanged;
  106306. private _deviceOrientation;
  106307. /**
  106308. * Detach the current controls from the specified dom element.
  106309. * @param element Defines the element to stop listening the inputs from
  106310. */
  106311. detachControl(element: Nullable<HTMLElement>): void;
  106312. /**
  106313. * Update the current camera state depending on the inputs that have been used this frame.
  106314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106315. */
  106316. checkInputs(): void;
  106317. /**
  106318. * Gets the class name of the current intput.
  106319. * @returns the class name
  106320. */
  106321. getClassName(): string;
  106322. /**
  106323. * Get the friendly name associated with the input class.
  106324. * @returns the input friendly name
  106325. */
  106326. getSimpleName(): string;
  106327. }
  106328. }
  106329. declare module BABYLON {
  106330. /**
  106331. * Manage the gamepad inputs to control a free camera.
  106332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106333. */
  106334. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106335. /**
  106336. * Define the camera the input is attached to.
  106337. */
  106338. camera: FreeCamera;
  106339. /**
  106340. * Define the Gamepad controlling the input
  106341. */
  106342. gamepad: Nullable<Gamepad>;
  106343. /**
  106344. * Defines the gamepad rotation sensiblity.
  106345. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106346. */
  106347. gamepadAngularSensibility: number;
  106348. /**
  106349. * Defines the gamepad move sensiblity.
  106350. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106351. */
  106352. gamepadMoveSensibility: number;
  106353. private _yAxisScale;
  106354. /**
  106355. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106356. */
  106357. invertYAxis: boolean;
  106358. private _onGamepadConnectedObserver;
  106359. private _onGamepadDisconnectedObserver;
  106360. private _cameraTransform;
  106361. private _deltaTransform;
  106362. private _vector3;
  106363. private _vector2;
  106364. /**
  106365. * Attach the input controls to a specific dom element to get the input from.
  106366. * @param element Defines the element the controls should be listened from
  106367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106368. */
  106369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106370. /**
  106371. * Detach the current controls from the specified dom element.
  106372. * @param element Defines the element to stop listening the inputs from
  106373. */
  106374. detachControl(element: Nullable<HTMLElement>): void;
  106375. /**
  106376. * Update the current camera state depending on the inputs that have been used this frame.
  106377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106378. */
  106379. checkInputs(): void;
  106380. /**
  106381. * Gets the class name of the current intput.
  106382. * @returns the class name
  106383. */
  106384. getClassName(): string;
  106385. /**
  106386. * Get the friendly name associated with the input class.
  106387. * @returns the input friendly name
  106388. */
  106389. getSimpleName(): string;
  106390. }
  106391. }
  106392. declare module BABYLON {
  106393. /**
  106394. * Defines the potential axis of a Joystick
  106395. */
  106396. export enum JoystickAxis {
  106397. /** X axis */
  106398. X = 0,
  106399. /** Y axis */
  106400. Y = 1,
  106401. /** Z axis */
  106402. Z = 2
  106403. }
  106404. /**
  106405. * Class used to define virtual joystick (used in touch mode)
  106406. */
  106407. export class VirtualJoystick {
  106408. /**
  106409. * Gets or sets a boolean indicating that left and right values must be inverted
  106410. */
  106411. reverseLeftRight: boolean;
  106412. /**
  106413. * Gets or sets a boolean indicating that up and down values must be inverted
  106414. */
  106415. reverseUpDown: boolean;
  106416. /**
  106417. * Gets the offset value for the position (ie. the change of the position value)
  106418. */
  106419. deltaPosition: Vector3;
  106420. /**
  106421. * Gets a boolean indicating if the virtual joystick was pressed
  106422. */
  106423. pressed: boolean;
  106424. /**
  106425. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106426. */
  106427. static Canvas: Nullable<HTMLCanvasElement>;
  106428. private static _globalJoystickIndex;
  106429. private static vjCanvasContext;
  106430. private static vjCanvasWidth;
  106431. private static vjCanvasHeight;
  106432. private static halfWidth;
  106433. private _action;
  106434. private _axisTargetedByLeftAndRight;
  106435. private _axisTargetedByUpAndDown;
  106436. private _joystickSensibility;
  106437. private _inversedSensibility;
  106438. private _joystickPointerID;
  106439. private _joystickColor;
  106440. private _joystickPointerPos;
  106441. private _joystickPreviousPointerPos;
  106442. private _joystickPointerStartPos;
  106443. private _deltaJoystickVector;
  106444. private _leftJoystick;
  106445. private _touches;
  106446. private _onPointerDownHandlerRef;
  106447. private _onPointerMoveHandlerRef;
  106448. private _onPointerUpHandlerRef;
  106449. private _onResize;
  106450. /**
  106451. * Creates a new virtual joystick
  106452. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106453. */
  106454. constructor(leftJoystick?: boolean);
  106455. /**
  106456. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106457. * @param newJoystickSensibility defines the new sensibility
  106458. */
  106459. setJoystickSensibility(newJoystickSensibility: number): void;
  106460. private _onPointerDown;
  106461. private _onPointerMove;
  106462. private _onPointerUp;
  106463. /**
  106464. * Change the color of the virtual joystick
  106465. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106466. */
  106467. setJoystickColor(newColor: string): void;
  106468. /**
  106469. * Defines a callback to call when the joystick is touched
  106470. * @param action defines the callback
  106471. */
  106472. setActionOnTouch(action: () => any): void;
  106473. /**
  106474. * Defines which axis you'd like to control for left & right
  106475. * @param axis defines the axis to use
  106476. */
  106477. setAxisForLeftRight(axis: JoystickAxis): void;
  106478. /**
  106479. * Defines which axis you'd like to control for up & down
  106480. * @param axis defines the axis to use
  106481. */
  106482. setAxisForUpDown(axis: JoystickAxis): void;
  106483. private _drawVirtualJoystick;
  106484. /**
  106485. * Release internal HTML canvas
  106486. */
  106487. releaseCanvas(): void;
  106488. }
  106489. }
  106490. declare module BABYLON {
  106491. interface FreeCameraInputsManager {
  106492. /**
  106493. * Add virtual joystick input support to the input manager.
  106494. * @returns the current input manager
  106495. */
  106496. addVirtualJoystick(): FreeCameraInputsManager;
  106497. }
  106498. /**
  106499. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106501. */
  106502. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106503. /**
  106504. * Defines the camera the input is attached to.
  106505. */
  106506. camera: FreeCamera;
  106507. private _leftjoystick;
  106508. private _rightjoystick;
  106509. /**
  106510. * Gets the left stick of the virtual joystick.
  106511. * @returns The virtual Joystick
  106512. */
  106513. getLeftJoystick(): VirtualJoystick;
  106514. /**
  106515. * Gets the right stick of the virtual joystick.
  106516. * @returns The virtual Joystick
  106517. */
  106518. getRightJoystick(): VirtualJoystick;
  106519. /**
  106520. * Update the current camera state depending on the inputs that have been used this frame.
  106521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106522. */
  106523. checkInputs(): void;
  106524. /**
  106525. * Attach the input controls to a specific dom element to get the input from.
  106526. * @param element Defines the element the controls should be listened from
  106527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106528. */
  106529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106530. /**
  106531. * Detach the current controls from the specified dom element.
  106532. * @param element Defines the element to stop listening the inputs from
  106533. */
  106534. detachControl(element: Nullable<HTMLElement>): void;
  106535. /**
  106536. * Gets the class name of the current intput.
  106537. * @returns the class name
  106538. */
  106539. getClassName(): string;
  106540. /**
  106541. * Get the friendly name associated with the input class.
  106542. * @returns the input friendly name
  106543. */
  106544. getSimpleName(): string;
  106545. }
  106546. }
  106547. declare module BABYLON {
  106548. /**
  106549. * This represents a FPS type of camera controlled by touch.
  106550. * This is like a universal camera minus the Gamepad controls.
  106551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106552. */
  106553. export class TouchCamera extends FreeCamera {
  106554. /**
  106555. * Defines the touch sensibility for rotation.
  106556. * The higher the faster.
  106557. */
  106558. touchAngularSensibility: number;
  106559. /**
  106560. * Defines the touch sensibility for move.
  106561. * The higher the faster.
  106562. */
  106563. touchMoveSensibility: number;
  106564. /**
  106565. * Instantiates a new touch camera.
  106566. * This represents a FPS type of camera controlled by touch.
  106567. * This is like a universal camera minus the Gamepad controls.
  106568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106569. * @param name Define the name of the camera in the scene
  106570. * @param position Define the start position of the camera in the scene
  106571. * @param scene Define the scene the camera belongs to
  106572. */
  106573. constructor(name: string, position: Vector3, scene: Scene);
  106574. /**
  106575. * Gets the current object class name.
  106576. * @return the class name
  106577. */
  106578. getClassName(): string;
  106579. /** @hidden */
  106580. _setupInputs(): void;
  106581. }
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106586. * being tilted forward or back and left or right.
  106587. */
  106588. export class DeviceOrientationCamera extends FreeCamera {
  106589. private _initialQuaternion;
  106590. private _quaternionCache;
  106591. private _tmpDragQuaternion;
  106592. private _disablePointerInputWhenUsingDeviceOrientation;
  106593. /**
  106594. * Creates a new device orientation camera
  106595. * @param name The name of the camera
  106596. * @param position The start position camera
  106597. * @param scene The scene the camera belongs to
  106598. */
  106599. constructor(name: string, position: Vector3, scene: Scene);
  106600. /**
  106601. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106602. */
  106603. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106604. private _dragFactor;
  106605. /**
  106606. * Enabled turning on the y axis when the orientation sensor is active
  106607. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106608. */
  106609. enableHorizontalDragging(dragFactor?: number): void;
  106610. /**
  106611. * Gets the current instance class name ("DeviceOrientationCamera").
  106612. * This helps avoiding instanceof at run time.
  106613. * @returns the class name
  106614. */
  106615. getClassName(): string;
  106616. /**
  106617. * @hidden
  106618. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106619. */
  106620. _checkInputs(): void;
  106621. /**
  106622. * Reset the camera to its default orientation on the specified axis only.
  106623. * @param axis The axis to reset
  106624. */
  106625. resetToCurrentRotation(axis?: Axis): void;
  106626. }
  106627. }
  106628. declare module BABYLON {
  106629. /**
  106630. * Defines supported buttons for XBox360 compatible gamepads
  106631. */
  106632. export enum Xbox360Button {
  106633. /** A */
  106634. A = 0,
  106635. /** B */
  106636. B = 1,
  106637. /** X */
  106638. X = 2,
  106639. /** Y */
  106640. Y = 3,
  106641. /** Start */
  106642. Start = 4,
  106643. /** Back */
  106644. Back = 5,
  106645. /** Left button */
  106646. LB = 6,
  106647. /** Right button */
  106648. RB = 7,
  106649. /** Left stick */
  106650. LeftStick = 8,
  106651. /** Right stick */
  106652. RightStick = 9
  106653. }
  106654. /** Defines values for XBox360 DPad */
  106655. export enum Xbox360Dpad {
  106656. /** Up */
  106657. Up = 0,
  106658. /** Down */
  106659. Down = 1,
  106660. /** Left */
  106661. Left = 2,
  106662. /** Right */
  106663. Right = 3
  106664. }
  106665. /**
  106666. * Defines a XBox360 gamepad
  106667. */
  106668. export class Xbox360Pad extends Gamepad {
  106669. private _leftTrigger;
  106670. private _rightTrigger;
  106671. private _onlefttriggerchanged;
  106672. private _onrighttriggerchanged;
  106673. private _onbuttondown;
  106674. private _onbuttonup;
  106675. private _ondpaddown;
  106676. private _ondpadup;
  106677. /** Observable raised when a button is pressed */
  106678. onButtonDownObservable: Observable<Xbox360Button>;
  106679. /** Observable raised when a button is released */
  106680. onButtonUpObservable: Observable<Xbox360Button>;
  106681. /** Observable raised when a pad is pressed */
  106682. onPadDownObservable: Observable<Xbox360Dpad>;
  106683. /** Observable raised when a pad is released */
  106684. onPadUpObservable: Observable<Xbox360Dpad>;
  106685. private _buttonA;
  106686. private _buttonB;
  106687. private _buttonX;
  106688. private _buttonY;
  106689. private _buttonBack;
  106690. private _buttonStart;
  106691. private _buttonLB;
  106692. private _buttonRB;
  106693. private _buttonLeftStick;
  106694. private _buttonRightStick;
  106695. private _dPadUp;
  106696. private _dPadDown;
  106697. private _dPadLeft;
  106698. private _dPadRight;
  106699. private _isXboxOnePad;
  106700. /**
  106701. * Creates a new XBox360 gamepad object
  106702. * @param id defines the id of this gamepad
  106703. * @param index defines its index
  106704. * @param gamepad defines the internal HTML gamepad object
  106705. * @param xboxOne defines if it is a XBox One gamepad
  106706. */
  106707. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106708. /**
  106709. * Defines the callback to call when left trigger is pressed
  106710. * @param callback defines the callback to use
  106711. */
  106712. onlefttriggerchanged(callback: (value: number) => void): void;
  106713. /**
  106714. * Defines the callback to call when right trigger is pressed
  106715. * @param callback defines the callback to use
  106716. */
  106717. onrighttriggerchanged(callback: (value: number) => void): void;
  106718. /**
  106719. * Gets the left trigger value
  106720. */
  106721. /**
  106722. * Sets the left trigger value
  106723. */
  106724. leftTrigger: number;
  106725. /**
  106726. * Gets the right trigger value
  106727. */
  106728. /**
  106729. * Sets the right trigger value
  106730. */
  106731. rightTrigger: number;
  106732. /**
  106733. * Defines the callback to call when a button is pressed
  106734. * @param callback defines the callback to use
  106735. */
  106736. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106737. /**
  106738. * Defines the callback to call when a button is released
  106739. * @param callback defines the callback to use
  106740. */
  106741. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106742. /**
  106743. * Defines the callback to call when a pad is pressed
  106744. * @param callback defines the callback to use
  106745. */
  106746. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106747. /**
  106748. * Defines the callback to call when a pad is released
  106749. * @param callback defines the callback to use
  106750. */
  106751. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106752. private _setButtonValue;
  106753. private _setDPadValue;
  106754. /**
  106755. * Gets the value of the `A` button
  106756. */
  106757. /**
  106758. * Sets the value of the `A` button
  106759. */
  106760. buttonA: number;
  106761. /**
  106762. * Gets the value of the `B` button
  106763. */
  106764. /**
  106765. * Sets the value of the `B` button
  106766. */
  106767. buttonB: number;
  106768. /**
  106769. * Gets the value of the `X` button
  106770. */
  106771. /**
  106772. * Sets the value of the `X` button
  106773. */
  106774. buttonX: number;
  106775. /**
  106776. * Gets the value of the `Y` button
  106777. */
  106778. /**
  106779. * Sets the value of the `Y` button
  106780. */
  106781. buttonY: number;
  106782. /**
  106783. * Gets the value of the `Start` button
  106784. */
  106785. /**
  106786. * Sets the value of the `Start` button
  106787. */
  106788. buttonStart: number;
  106789. /**
  106790. * Gets the value of the `Back` button
  106791. */
  106792. /**
  106793. * Sets the value of the `Back` button
  106794. */
  106795. buttonBack: number;
  106796. /**
  106797. * Gets the value of the `Left` button
  106798. */
  106799. /**
  106800. * Sets the value of the `Left` button
  106801. */
  106802. buttonLB: number;
  106803. /**
  106804. * Gets the value of the `Right` button
  106805. */
  106806. /**
  106807. * Sets the value of the `Right` button
  106808. */
  106809. buttonRB: number;
  106810. /**
  106811. * Gets the value of the Left joystick
  106812. */
  106813. /**
  106814. * Sets the value of the Left joystick
  106815. */
  106816. buttonLeftStick: number;
  106817. /**
  106818. * Gets the value of the Right joystick
  106819. */
  106820. /**
  106821. * Sets the value of the Right joystick
  106822. */
  106823. buttonRightStick: number;
  106824. /**
  106825. * Gets the value of D-pad up
  106826. */
  106827. /**
  106828. * Sets the value of D-pad up
  106829. */
  106830. dPadUp: number;
  106831. /**
  106832. * Gets the value of D-pad down
  106833. */
  106834. /**
  106835. * Sets the value of D-pad down
  106836. */
  106837. dPadDown: number;
  106838. /**
  106839. * Gets the value of D-pad left
  106840. */
  106841. /**
  106842. * Sets the value of D-pad left
  106843. */
  106844. dPadLeft: number;
  106845. /**
  106846. * Gets the value of D-pad right
  106847. */
  106848. /**
  106849. * Sets the value of D-pad right
  106850. */
  106851. dPadRight: number;
  106852. /**
  106853. * Force the gamepad to synchronize with device values
  106854. */
  106855. update(): void;
  106856. /**
  106857. * Disposes the gamepad
  106858. */
  106859. dispose(): void;
  106860. }
  106861. }
  106862. declare module BABYLON {
  106863. /**
  106864. * Defines supported buttons for DualShock compatible gamepads
  106865. */
  106866. export enum DualShockButton {
  106867. /** Cross */
  106868. Cross = 0,
  106869. /** Circle */
  106870. Circle = 1,
  106871. /** Square */
  106872. Square = 2,
  106873. /** Triangle */
  106874. Triangle = 3,
  106875. /** Options */
  106876. Options = 4,
  106877. /** Share */
  106878. Share = 5,
  106879. /** L1 */
  106880. L1 = 6,
  106881. /** R1 */
  106882. R1 = 7,
  106883. /** Left stick */
  106884. LeftStick = 8,
  106885. /** Right stick */
  106886. RightStick = 9
  106887. }
  106888. /** Defines values for DualShock DPad */
  106889. export enum DualShockDpad {
  106890. /** Up */
  106891. Up = 0,
  106892. /** Down */
  106893. Down = 1,
  106894. /** Left */
  106895. Left = 2,
  106896. /** Right */
  106897. Right = 3
  106898. }
  106899. /**
  106900. * Defines a DualShock gamepad
  106901. */
  106902. export class DualShockPad extends Gamepad {
  106903. private _leftTrigger;
  106904. private _rightTrigger;
  106905. private _onlefttriggerchanged;
  106906. private _onrighttriggerchanged;
  106907. private _onbuttondown;
  106908. private _onbuttonup;
  106909. private _ondpaddown;
  106910. private _ondpadup;
  106911. /** Observable raised when a button is pressed */
  106912. onButtonDownObservable: Observable<DualShockButton>;
  106913. /** Observable raised when a button is released */
  106914. onButtonUpObservable: Observable<DualShockButton>;
  106915. /** Observable raised when a pad is pressed */
  106916. onPadDownObservable: Observable<DualShockDpad>;
  106917. /** Observable raised when a pad is released */
  106918. onPadUpObservable: Observable<DualShockDpad>;
  106919. private _buttonCross;
  106920. private _buttonCircle;
  106921. private _buttonSquare;
  106922. private _buttonTriangle;
  106923. private _buttonShare;
  106924. private _buttonOptions;
  106925. private _buttonL1;
  106926. private _buttonR1;
  106927. private _buttonLeftStick;
  106928. private _buttonRightStick;
  106929. private _dPadUp;
  106930. private _dPadDown;
  106931. private _dPadLeft;
  106932. private _dPadRight;
  106933. /**
  106934. * Creates a new DualShock gamepad object
  106935. * @param id defines the id of this gamepad
  106936. * @param index defines its index
  106937. * @param gamepad defines the internal HTML gamepad object
  106938. */
  106939. constructor(id: string, index: number, gamepad: any);
  106940. /**
  106941. * Defines the callback to call when left trigger is pressed
  106942. * @param callback defines the callback to use
  106943. */
  106944. onlefttriggerchanged(callback: (value: number) => void): void;
  106945. /**
  106946. * Defines the callback to call when right trigger is pressed
  106947. * @param callback defines the callback to use
  106948. */
  106949. onrighttriggerchanged(callback: (value: number) => void): void;
  106950. /**
  106951. * Gets the left trigger value
  106952. */
  106953. /**
  106954. * Sets the left trigger value
  106955. */
  106956. leftTrigger: number;
  106957. /**
  106958. * Gets the right trigger value
  106959. */
  106960. /**
  106961. * Sets the right trigger value
  106962. */
  106963. rightTrigger: number;
  106964. /**
  106965. * Defines the callback to call when a button is pressed
  106966. * @param callback defines the callback to use
  106967. */
  106968. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106969. /**
  106970. * Defines the callback to call when a button is released
  106971. * @param callback defines the callback to use
  106972. */
  106973. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106974. /**
  106975. * Defines the callback to call when a pad is pressed
  106976. * @param callback defines the callback to use
  106977. */
  106978. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106979. /**
  106980. * Defines the callback to call when a pad is released
  106981. * @param callback defines the callback to use
  106982. */
  106983. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106984. private _setButtonValue;
  106985. private _setDPadValue;
  106986. /**
  106987. * Gets the value of the `Cross` button
  106988. */
  106989. /**
  106990. * Sets the value of the `Cross` button
  106991. */
  106992. buttonCross: number;
  106993. /**
  106994. * Gets the value of the `Circle` button
  106995. */
  106996. /**
  106997. * Sets the value of the `Circle` button
  106998. */
  106999. buttonCircle: number;
  107000. /**
  107001. * Gets the value of the `Square` button
  107002. */
  107003. /**
  107004. * Sets the value of the `Square` button
  107005. */
  107006. buttonSquare: number;
  107007. /**
  107008. * Gets the value of the `Triangle` button
  107009. */
  107010. /**
  107011. * Sets the value of the `Triangle` button
  107012. */
  107013. buttonTriangle: number;
  107014. /**
  107015. * Gets the value of the `Options` button
  107016. */
  107017. /**
  107018. * Sets the value of the `Options` button
  107019. */
  107020. buttonOptions: number;
  107021. /**
  107022. * Gets the value of the `Share` button
  107023. */
  107024. /**
  107025. * Sets the value of the `Share` button
  107026. */
  107027. buttonShare: number;
  107028. /**
  107029. * Gets the value of the `L1` button
  107030. */
  107031. /**
  107032. * Sets the value of the `L1` button
  107033. */
  107034. buttonL1: number;
  107035. /**
  107036. * Gets the value of the `R1` button
  107037. */
  107038. /**
  107039. * Sets the value of the `R1` button
  107040. */
  107041. buttonR1: number;
  107042. /**
  107043. * Gets the value of the Left joystick
  107044. */
  107045. /**
  107046. * Sets the value of the Left joystick
  107047. */
  107048. buttonLeftStick: number;
  107049. /**
  107050. * Gets the value of the Right joystick
  107051. */
  107052. /**
  107053. * Sets the value of the Right joystick
  107054. */
  107055. buttonRightStick: number;
  107056. /**
  107057. * Gets the value of D-pad up
  107058. */
  107059. /**
  107060. * Sets the value of D-pad up
  107061. */
  107062. dPadUp: number;
  107063. /**
  107064. * Gets the value of D-pad down
  107065. */
  107066. /**
  107067. * Sets the value of D-pad down
  107068. */
  107069. dPadDown: number;
  107070. /**
  107071. * Gets the value of D-pad left
  107072. */
  107073. /**
  107074. * Sets the value of D-pad left
  107075. */
  107076. dPadLeft: number;
  107077. /**
  107078. * Gets the value of D-pad right
  107079. */
  107080. /**
  107081. * Sets the value of D-pad right
  107082. */
  107083. dPadRight: number;
  107084. /**
  107085. * Force the gamepad to synchronize with device values
  107086. */
  107087. update(): void;
  107088. /**
  107089. * Disposes the gamepad
  107090. */
  107091. dispose(): void;
  107092. }
  107093. }
  107094. declare module BABYLON {
  107095. /**
  107096. * Manager for handling gamepads
  107097. */
  107098. export class GamepadManager {
  107099. private _scene?;
  107100. private _babylonGamepads;
  107101. private _oneGamepadConnected;
  107102. /** @hidden */
  107103. _isMonitoring: boolean;
  107104. private _gamepadEventSupported;
  107105. private _gamepadSupport;
  107106. /**
  107107. * observable to be triggered when the gamepad controller has been connected
  107108. */
  107109. onGamepadConnectedObservable: Observable<Gamepad>;
  107110. /**
  107111. * observable to be triggered when the gamepad controller has been disconnected
  107112. */
  107113. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107114. private _onGamepadConnectedEvent;
  107115. private _onGamepadDisconnectedEvent;
  107116. /**
  107117. * Initializes the gamepad manager
  107118. * @param _scene BabylonJS scene
  107119. */
  107120. constructor(_scene?: Scene | undefined);
  107121. /**
  107122. * The gamepads in the game pad manager
  107123. */
  107124. readonly gamepads: Gamepad[];
  107125. /**
  107126. * Get the gamepad controllers based on type
  107127. * @param type The type of gamepad controller
  107128. * @returns Nullable gamepad
  107129. */
  107130. getGamepadByType(type?: number): Nullable<Gamepad>;
  107131. /**
  107132. * Disposes the gamepad manager
  107133. */
  107134. dispose(): void;
  107135. private _addNewGamepad;
  107136. private _startMonitoringGamepads;
  107137. private _stopMonitoringGamepads;
  107138. /** @hidden */
  107139. _checkGamepadsStatus(): void;
  107140. private _updateGamepadObjects;
  107141. }
  107142. }
  107143. declare module BABYLON {
  107144. interface Scene {
  107145. /** @hidden */
  107146. _gamepadManager: Nullable<GamepadManager>;
  107147. /**
  107148. * Gets the gamepad manager associated with the scene
  107149. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107150. */
  107151. gamepadManager: GamepadManager;
  107152. }
  107153. /**
  107154. * Interface representing a free camera inputs manager
  107155. */
  107156. interface FreeCameraInputsManager {
  107157. /**
  107158. * Adds gamepad input support to the FreeCameraInputsManager.
  107159. * @returns the FreeCameraInputsManager
  107160. */
  107161. addGamepad(): FreeCameraInputsManager;
  107162. }
  107163. /**
  107164. * Interface representing an arc rotate camera inputs manager
  107165. */
  107166. interface ArcRotateCameraInputsManager {
  107167. /**
  107168. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107169. * @returns the camera inputs manager
  107170. */
  107171. addGamepad(): ArcRotateCameraInputsManager;
  107172. }
  107173. /**
  107174. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107175. */
  107176. export class GamepadSystemSceneComponent implements ISceneComponent {
  107177. /**
  107178. * The component name helpfull to identify the component in the list of scene components.
  107179. */
  107180. readonly name: string;
  107181. /**
  107182. * The scene the component belongs to.
  107183. */
  107184. scene: Scene;
  107185. /**
  107186. * Creates a new instance of the component for the given scene
  107187. * @param scene Defines the scene to register the component in
  107188. */
  107189. constructor(scene: Scene);
  107190. /**
  107191. * Registers the component in a given scene
  107192. */
  107193. register(): void;
  107194. /**
  107195. * Rebuilds the elements related to this component in case of
  107196. * context lost for instance.
  107197. */
  107198. rebuild(): void;
  107199. /**
  107200. * Disposes the component and the associated ressources
  107201. */
  107202. dispose(): void;
  107203. private _beforeCameraUpdate;
  107204. }
  107205. }
  107206. declare module BABYLON {
  107207. /**
  107208. * 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,
  107209. * which still works and will still be found in many Playgrounds.
  107210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107211. */
  107212. export class UniversalCamera extends TouchCamera {
  107213. /**
  107214. * Defines the gamepad rotation sensiblity.
  107215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107216. */
  107217. gamepadAngularSensibility: number;
  107218. /**
  107219. * Defines the gamepad move sensiblity.
  107220. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107221. */
  107222. gamepadMoveSensibility: number;
  107223. /**
  107224. * 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,
  107225. * which still works and will still be found in many Playgrounds.
  107226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107227. * @param name Define the name of the camera in the scene
  107228. * @param position Define the start position of the camera in the scene
  107229. * @param scene Define the scene the camera belongs to
  107230. */
  107231. constructor(name: string, position: Vector3, scene: Scene);
  107232. /**
  107233. * Gets the current object class name.
  107234. * @return the class name
  107235. */
  107236. getClassName(): string;
  107237. }
  107238. }
  107239. declare module BABYLON {
  107240. /**
  107241. * This represents a FPS type of camera. This is only here for back compat purpose.
  107242. * Please use the UniversalCamera instead as both are identical.
  107243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107244. */
  107245. export class GamepadCamera extends UniversalCamera {
  107246. /**
  107247. * Instantiates a new Gamepad Camera
  107248. * This represents a FPS type of camera. This is only here for back compat purpose.
  107249. * Please use the UniversalCamera instead as both are identical.
  107250. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107251. * @param name Define the name of the camera in the scene
  107252. * @param position Define the start position of the camera in the scene
  107253. * @param scene Define the scene the camera belongs to
  107254. */
  107255. constructor(name: string, position: Vector3, scene: Scene);
  107256. /**
  107257. * Gets the current object class name.
  107258. * @return the class name
  107259. */
  107260. getClassName(): string;
  107261. }
  107262. }
  107263. declare module BABYLON {
  107264. /** @hidden */
  107265. export var passPixelShader: {
  107266. name: string;
  107267. shader: string;
  107268. };
  107269. }
  107270. declare module BABYLON {
  107271. /** @hidden */
  107272. export var passCubePixelShader: {
  107273. name: string;
  107274. shader: string;
  107275. };
  107276. }
  107277. declare module BABYLON {
  107278. /**
  107279. * PassPostProcess which produces an output the same as it's input
  107280. */
  107281. export class PassPostProcess extends PostProcess {
  107282. /**
  107283. * Creates the PassPostProcess
  107284. * @param name The name of the effect.
  107285. * @param options The required width/height ratio to downsize to before computing the render pass.
  107286. * @param camera The camera to apply the render pass to.
  107287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107288. * @param engine The engine which the post process will be applied. (default: current engine)
  107289. * @param reusable If the post process can be reused on the same frame. (default: false)
  107290. * @param textureType The type of texture to be used when performing the post processing.
  107291. * @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)
  107292. */
  107293. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107294. }
  107295. /**
  107296. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107297. */
  107298. export class PassCubePostProcess extends PostProcess {
  107299. private _face;
  107300. /**
  107301. * Gets or sets the cube face to display.
  107302. * * 0 is +X
  107303. * * 1 is -X
  107304. * * 2 is +Y
  107305. * * 3 is -Y
  107306. * * 4 is +Z
  107307. * * 5 is -Z
  107308. */
  107309. face: number;
  107310. /**
  107311. * Creates the PassCubePostProcess
  107312. * @param name The name of the effect.
  107313. * @param options The required width/height ratio to downsize to before computing the render pass.
  107314. * @param camera The camera to apply the render pass to.
  107315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107316. * @param engine The engine which the post process will be applied. (default: current engine)
  107317. * @param reusable If the post process can be reused on the same frame. (default: false)
  107318. * @param textureType The type of texture to be used when performing the post processing.
  107319. * @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)
  107320. */
  107321. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107322. }
  107323. }
  107324. declare module BABYLON {
  107325. /** @hidden */
  107326. export var anaglyphPixelShader: {
  107327. name: string;
  107328. shader: string;
  107329. };
  107330. }
  107331. declare module BABYLON {
  107332. /**
  107333. * Postprocess used to generate anaglyphic rendering
  107334. */
  107335. export class AnaglyphPostProcess extends PostProcess {
  107336. private _passedProcess;
  107337. /**
  107338. * Creates a new AnaglyphPostProcess
  107339. * @param name defines postprocess name
  107340. * @param options defines creation options or target ratio scale
  107341. * @param rigCameras defines cameras using this postprocess
  107342. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107343. * @param engine defines hosting engine
  107344. * @param reusable defines if the postprocess will be reused multiple times per frame
  107345. */
  107346. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107347. }
  107348. }
  107349. declare module BABYLON {
  107350. /**
  107351. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107352. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107353. */
  107354. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107355. /**
  107356. * Creates a new AnaglyphArcRotateCamera
  107357. * @param name defines camera name
  107358. * @param alpha defines alpha angle (in radians)
  107359. * @param beta defines beta angle (in radians)
  107360. * @param radius defines radius
  107361. * @param target defines camera target
  107362. * @param interaxialDistance defines distance between each color axis
  107363. * @param scene defines the hosting scene
  107364. */
  107365. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107366. /**
  107367. * Gets camera class name
  107368. * @returns AnaglyphArcRotateCamera
  107369. */
  107370. getClassName(): string;
  107371. }
  107372. }
  107373. declare module BABYLON {
  107374. /**
  107375. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107376. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107377. */
  107378. export class AnaglyphFreeCamera extends FreeCamera {
  107379. /**
  107380. * Creates a new AnaglyphFreeCamera
  107381. * @param name defines camera name
  107382. * @param position defines initial position
  107383. * @param interaxialDistance defines distance between each color axis
  107384. * @param scene defines the hosting scene
  107385. */
  107386. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107387. /**
  107388. * Gets camera class name
  107389. * @returns AnaglyphFreeCamera
  107390. */
  107391. getClassName(): string;
  107392. }
  107393. }
  107394. declare module BABYLON {
  107395. /**
  107396. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107397. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107398. */
  107399. export class AnaglyphGamepadCamera extends GamepadCamera {
  107400. /**
  107401. * Creates a new AnaglyphGamepadCamera
  107402. * @param name defines camera name
  107403. * @param position defines initial position
  107404. * @param interaxialDistance defines distance between each color axis
  107405. * @param scene defines the hosting scene
  107406. */
  107407. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107408. /**
  107409. * Gets camera class name
  107410. * @returns AnaglyphGamepadCamera
  107411. */
  107412. getClassName(): string;
  107413. }
  107414. }
  107415. declare module BABYLON {
  107416. /**
  107417. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107418. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107419. */
  107420. export class AnaglyphUniversalCamera extends UniversalCamera {
  107421. /**
  107422. * Creates a new AnaglyphUniversalCamera
  107423. * @param name defines camera name
  107424. * @param position defines initial position
  107425. * @param interaxialDistance defines distance between each color axis
  107426. * @param scene defines the hosting scene
  107427. */
  107428. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107429. /**
  107430. * Gets camera class name
  107431. * @returns AnaglyphUniversalCamera
  107432. */
  107433. getClassName(): string;
  107434. }
  107435. }
  107436. declare module BABYLON {
  107437. /** @hidden */
  107438. export var stereoscopicInterlacePixelShader: {
  107439. name: string;
  107440. shader: string;
  107441. };
  107442. }
  107443. declare module BABYLON {
  107444. /**
  107445. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107446. */
  107447. export class StereoscopicInterlacePostProcess extends PostProcess {
  107448. private _stepSize;
  107449. private _passedProcess;
  107450. /**
  107451. * Initializes a StereoscopicInterlacePostProcess
  107452. * @param name The name of the effect.
  107453. * @param rigCameras The rig cameras to be appled to the post process
  107454. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107456. * @param engine The engine which the post process will be applied. (default: current engine)
  107457. * @param reusable If the post process can be reused on the same frame. (default: false)
  107458. */
  107459. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107460. }
  107461. }
  107462. declare module BABYLON {
  107463. /**
  107464. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107465. * @see http://doc.babylonjs.com/features/cameras
  107466. */
  107467. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107468. /**
  107469. * Creates a new StereoscopicArcRotateCamera
  107470. * @param name defines camera name
  107471. * @param alpha defines alpha angle (in radians)
  107472. * @param beta defines beta angle (in radians)
  107473. * @param radius defines radius
  107474. * @param target defines camera target
  107475. * @param interaxialDistance defines distance between each color axis
  107476. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107477. * @param scene defines the hosting scene
  107478. */
  107479. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107480. /**
  107481. * Gets camera class name
  107482. * @returns StereoscopicArcRotateCamera
  107483. */
  107484. getClassName(): string;
  107485. }
  107486. }
  107487. declare module BABYLON {
  107488. /**
  107489. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107490. * @see http://doc.babylonjs.com/features/cameras
  107491. */
  107492. export class StereoscopicFreeCamera extends FreeCamera {
  107493. /**
  107494. * Creates a new StereoscopicFreeCamera
  107495. * @param name defines camera name
  107496. * @param position defines initial position
  107497. * @param interaxialDistance defines distance between each color axis
  107498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107499. * @param scene defines the hosting scene
  107500. */
  107501. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107502. /**
  107503. * Gets camera class name
  107504. * @returns StereoscopicFreeCamera
  107505. */
  107506. getClassName(): string;
  107507. }
  107508. }
  107509. declare module BABYLON {
  107510. /**
  107511. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107512. * @see http://doc.babylonjs.com/features/cameras
  107513. */
  107514. export class StereoscopicGamepadCamera extends GamepadCamera {
  107515. /**
  107516. * Creates a new StereoscopicGamepadCamera
  107517. * @param name defines camera name
  107518. * @param position defines initial position
  107519. * @param interaxialDistance defines distance between each color axis
  107520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107521. * @param scene defines the hosting scene
  107522. */
  107523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107524. /**
  107525. * Gets camera class name
  107526. * @returns StereoscopicGamepadCamera
  107527. */
  107528. getClassName(): string;
  107529. }
  107530. }
  107531. declare module BABYLON {
  107532. /**
  107533. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107534. * @see http://doc.babylonjs.com/features/cameras
  107535. */
  107536. export class StereoscopicUniversalCamera extends UniversalCamera {
  107537. /**
  107538. * Creates a new StereoscopicUniversalCamera
  107539. * @param name defines camera name
  107540. * @param position defines initial position
  107541. * @param interaxialDistance defines distance between each color axis
  107542. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107543. * @param scene defines the hosting scene
  107544. */
  107545. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107546. /**
  107547. * Gets camera class name
  107548. * @returns StereoscopicUniversalCamera
  107549. */
  107550. getClassName(): string;
  107551. }
  107552. }
  107553. declare module BABYLON {
  107554. /**
  107555. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107556. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107557. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107558. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107559. */
  107560. export class VirtualJoysticksCamera extends FreeCamera {
  107561. /**
  107562. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107563. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107564. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107565. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107566. * @param name Define the name of the camera in the scene
  107567. * @param position Define the start position of the camera in the scene
  107568. * @param scene Define the scene the camera belongs to
  107569. */
  107570. constructor(name: string, position: Vector3, scene: Scene);
  107571. /**
  107572. * Gets the current object class name.
  107573. * @return the class name
  107574. */
  107575. getClassName(): string;
  107576. }
  107577. }
  107578. declare module BABYLON {
  107579. /**
  107580. * This represents all the required metrics to create a VR camera.
  107581. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107582. */
  107583. export class VRCameraMetrics {
  107584. /**
  107585. * Define the horizontal resolution off the screen.
  107586. */
  107587. hResolution: number;
  107588. /**
  107589. * Define the vertical resolution off the screen.
  107590. */
  107591. vResolution: number;
  107592. /**
  107593. * Define the horizontal screen size.
  107594. */
  107595. hScreenSize: number;
  107596. /**
  107597. * Define the vertical screen size.
  107598. */
  107599. vScreenSize: number;
  107600. /**
  107601. * Define the vertical screen center position.
  107602. */
  107603. vScreenCenter: number;
  107604. /**
  107605. * Define the distance of the eyes to the screen.
  107606. */
  107607. eyeToScreenDistance: number;
  107608. /**
  107609. * Define the distance between both lenses
  107610. */
  107611. lensSeparationDistance: number;
  107612. /**
  107613. * Define the distance between both viewer's eyes.
  107614. */
  107615. interpupillaryDistance: number;
  107616. /**
  107617. * Define the distortion factor of the VR postprocess.
  107618. * Please, touch with care.
  107619. */
  107620. distortionK: number[];
  107621. /**
  107622. * Define the chromatic aberration correction factors for the VR post process.
  107623. */
  107624. chromaAbCorrection: number[];
  107625. /**
  107626. * Define the scale factor of the post process.
  107627. * The smaller the better but the slower.
  107628. */
  107629. postProcessScaleFactor: number;
  107630. /**
  107631. * Define an offset for the lens center.
  107632. */
  107633. lensCenterOffset: number;
  107634. /**
  107635. * Define if the current vr camera should compensate the distortion of the lense or not.
  107636. */
  107637. compensateDistortion: boolean;
  107638. /**
  107639. * Defines if multiview should be enabled when rendering (Default: false)
  107640. */
  107641. multiviewEnabled: boolean;
  107642. /**
  107643. * Gets the rendering aspect ratio based on the provided resolutions.
  107644. */
  107645. readonly aspectRatio: number;
  107646. /**
  107647. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107648. */
  107649. readonly aspectRatioFov: number;
  107650. /**
  107651. * @hidden
  107652. */
  107653. readonly leftHMatrix: Matrix;
  107654. /**
  107655. * @hidden
  107656. */
  107657. readonly rightHMatrix: Matrix;
  107658. /**
  107659. * @hidden
  107660. */
  107661. readonly leftPreViewMatrix: Matrix;
  107662. /**
  107663. * @hidden
  107664. */
  107665. readonly rightPreViewMatrix: Matrix;
  107666. /**
  107667. * Get the default VRMetrics based on the most generic setup.
  107668. * @returns the default vr metrics
  107669. */
  107670. static GetDefault(): VRCameraMetrics;
  107671. }
  107672. }
  107673. declare module BABYLON {
  107674. /** @hidden */
  107675. export var vrDistortionCorrectionPixelShader: {
  107676. name: string;
  107677. shader: string;
  107678. };
  107679. }
  107680. declare module BABYLON {
  107681. /**
  107682. * VRDistortionCorrectionPostProcess used for mobile VR
  107683. */
  107684. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107685. private _isRightEye;
  107686. private _distortionFactors;
  107687. private _postProcessScaleFactor;
  107688. private _lensCenterOffset;
  107689. private _scaleIn;
  107690. private _scaleFactor;
  107691. private _lensCenter;
  107692. /**
  107693. * Initializes the VRDistortionCorrectionPostProcess
  107694. * @param name The name of the effect.
  107695. * @param camera The camera to apply the render pass to.
  107696. * @param isRightEye If this is for the right eye distortion
  107697. * @param vrMetrics All the required metrics for the VR camera
  107698. */
  107699. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107700. }
  107701. }
  107702. declare module BABYLON {
  107703. /**
  107704. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107705. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107706. */
  107707. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107708. /**
  107709. * Creates a new VRDeviceOrientationArcRotateCamera
  107710. * @param name defines camera name
  107711. * @param alpha defines the camera rotation along the logitudinal axis
  107712. * @param beta defines the camera rotation along the latitudinal axis
  107713. * @param radius defines the camera distance from its target
  107714. * @param target defines the camera target
  107715. * @param scene defines the scene the camera belongs to
  107716. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107717. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107718. */
  107719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107720. /**
  107721. * Gets camera class name
  107722. * @returns VRDeviceOrientationArcRotateCamera
  107723. */
  107724. getClassName(): string;
  107725. }
  107726. }
  107727. declare module BABYLON {
  107728. /**
  107729. * Camera used to simulate VR rendering (based on FreeCamera)
  107730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107731. */
  107732. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107733. /**
  107734. * Creates a new VRDeviceOrientationFreeCamera
  107735. * @param name defines camera name
  107736. * @param position defines the start position of the camera
  107737. * @param scene defines the scene the camera belongs to
  107738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107740. */
  107741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107742. /**
  107743. * Gets camera class name
  107744. * @returns VRDeviceOrientationFreeCamera
  107745. */
  107746. getClassName(): string;
  107747. }
  107748. }
  107749. declare module BABYLON {
  107750. /**
  107751. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107752. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107753. */
  107754. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107755. /**
  107756. * Creates a new VRDeviceOrientationGamepadCamera
  107757. * @param name defines camera name
  107758. * @param position defines the start position of the camera
  107759. * @param scene defines the scene the camera belongs to
  107760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107762. */
  107763. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107764. /**
  107765. * Gets camera class name
  107766. * @returns VRDeviceOrientationGamepadCamera
  107767. */
  107768. getClassName(): string;
  107769. }
  107770. }
  107771. declare module BABYLON {
  107772. /**
  107773. * Base class of materials working in push mode in babylon JS
  107774. * @hidden
  107775. */
  107776. export class PushMaterial extends Material {
  107777. protected _activeEffect: Effect;
  107778. protected _normalMatrix: Matrix;
  107779. /**
  107780. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107781. * This means that the material can keep using a previous shader while a new one is being compiled.
  107782. * This is mostly used when shader parallel compilation is supported (true by default)
  107783. */
  107784. allowShaderHotSwapping: boolean;
  107785. constructor(name: string, scene: Scene);
  107786. getEffect(): Effect;
  107787. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107788. /**
  107789. * Binds the given world matrix to the active effect
  107790. *
  107791. * @param world the matrix to bind
  107792. */
  107793. bindOnlyWorldMatrix(world: Matrix): void;
  107794. /**
  107795. * Binds the given normal matrix to the active effect
  107796. *
  107797. * @param normalMatrix the matrix to bind
  107798. */
  107799. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107800. bind(world: Matrix, mesh?: Mesh): void;
  107801. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107802. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /**
  107807. * This groups all the flags used to control the materials channel.
  107808. */
  107809. export class MaterialFlags {
  107810. private static _DiffuseTextureEnabled;
  107811. /**
  107812. * Are diffuse textures enabled in the application.
  107813. */
  107814. static DiffuseTextureEnabled: boolean;
  107815. private static _AmbientTextureEnabled;
  107816. /**
  107817. * Are ambient textures enabled in the application.
  107818. */
  107819. static AmbientTextureEnabled: boolean;
  107820. private static _OpacityTextureEnabled;
  107821. /**
  107822. * Are opacity textures enabled in the application.
  107823. */
  107824. static OpacityTextureEnabled: boolean;
  107825. private static _ReflectionTextureEnabled;
  107826. /**
  107827. * Are reflection textures enabled in the application.
  107828. */
  107829. static ReflectionTextureEnabled: boolean;
  107830. private static _EmissiveTextureEnabled;
  107831. /**
  107832. * Are emissive textures enabled in the application.
  107833. */
  107834. static EmissiveTextureEnabled: boolean;
  107835. private static _SpecularTextureEnabled;
  107836. /**
  107837. * Are specular textures enabled in the application.
  107838. */
  107839. static SpecularTextureEnabled: boolean;
  107840. private static _BumpTextureEnabled;
  107841. /**
  107842. * Are bump textures enabled in the application.
  107843. */
  107844. static BumpTextureEnabled: boolean;
  107845. private static _LightmapTextureEnabled;
  107846. /**
  107847. * Are lightmap textures enabled in the application.
  107848. */
  107849. static LightmapTextureEnabled: boolean;
  107850. private static _RefractionTextureEnabled;
  107851. /**
  107852. * Are refraction textures enabled in the application.
  107853. */
  107854. static RefractionTextureEnabled: boolean;
  107855. private static _ColorGradingTextureEnabled;
  107856. /**
  107857. * Are color grading textures enabled in the application.
  107858. */
  107859. static ColorGradingTextureEnabled: boolean;
  107860. private static _FresnelEnabled;
  107861. /**
  107862. * Are fresnels enabled in the application.
  107863. */
  107864. static FresnelEnabled: boolean;
  107865. private static _ClearCoatTextureEnabled;
  107866. /**
  107867. * Are clear coat textures enabled in the application.
  107868. */
  107869. static ClearCoatTextureEnabled: boolean;
  107870. private static _ClearCoatBumpTextureEnabled;
  107871. /**
  107872. * Are clear coat bump textures enabled in the application.
  107873. */
  107874. static ClearCoatBumpTextureEnabled: boolean;
  107875. private static _ClearCoatTintTextureEnabled;
  107876. /**
  107877. * Are clear coat tint textures enabled in the application.
  107878. */
  107879. static ClearCoatTintTextureEnabled: boolean;
  107880. private static _SheenTextureEnabled;
  107881. /**
  107882. * Are sheen textures enabled in the application.
  107883. */
  107884. static SheenTextureEnabled: boolean;
  107885. private static _AnisotropicTextureEnabled;
  107886. /**
  107887. * Are anisotropic textures enabled in the application.
  107888. */
  107889. static AnisotropicTextureEnabled: boolean;
  107890. private static _ThicknessTextureEnabled;
  107891. /**
  107892. * Are thickness textures enabled in the application.
  107893. */
  107894. static ThicknessTextureEnabled: boolean;
  107895. }
  107896. }
  107897. declare module BABYLON {
  107898. /** @hidden */
  107899. export var defaultFragmentDeclaration: {
  107900. name: string;
  107901. shader: string;
  107902. };
  107903. }
  107904. declare module BABYLON {
  107905. /** @hidden */
  107906. export var defaultUboDeclaration: {
  107907. name: string;
  107908. shader: string;
  107909. };
  107910. }
  107911. declare module BABYLON {
  107912. /** @hidden */
  107913. export var lightFragmentDeclaration: {
  107914. name: string;
  107915. shader: string;
  107916. };
  107917. }
  107918. declare module BABYLON {
  107919. /** @hidden */
  107920. export var lightUboDeclaration: {
  107921. name: string;
  107922. shader: string;
  107923. };
  107924. }
  107925. declare module BABYLON {
  107926. /** @hidden */
  107927. export var lightsFragmentFunctions: {
  107928. name: string;
  107929. shader: string;
  107930. };
  107931. }
  107932. declare module BABYLON {
  107933. /** @hidden */
  107934. export var shadowsFragmentFunctions: {
  107935. name: string;
  107936. shader: string;
  107937. };
  107938. }
  107939. declare module BABYLON {
  107940. /** @hidden */
  107941. export var fresnelFunction: {
  107942. name: string;
  107943. shader: string;
  107944. };
  107945. }
  107946. declare module BABYLON {
  107947. /** @hidden */
  107948. export var reflectionFunction: {
  107949. name: string;
  107950. shader: string;
  107951. };
  107952. }
  107953. declare module BABYLON {
  107954. /** @hidden */
  107955. export var bumpFragmentFunctions: {
  107956. name: string;
  107957. shader: string;
  107958. };
  107959. }
  107960. declare module BABYLON {
  107961. /** @hidden */
  107962. export var logDepthDeclaration: {
  107963. name: string;
  107964. shader: string;
  107965. };
  107966. }
  107967. declare module BABYLON {
  107968. /** @hidden */
  107969. export var bumpFragment: {
  107970. name: string;
  107971. shader: string;
  107972. };
  107973. }
  107974. declare module BABYLON {
  107975. /** @hidden */
  107976. export var depthPrePass: {
  107977. name: string;
  107978. shader: string;
  107979. };
  107980. }
  107981. declare module BABYLON {
  107982. /** @hidden */
  107983. export var lightFragment: {
  107984. name: string;
  107985. shader: string;
  107986. };
  107987. }
  107988. declare module BABYLON {
  107989. /** @hidden */
  107990. export var logDepthFragment: {
  107991. name: string;
  107992. shader: string;
  107993. };
  107994. }
  107995. declare module BABYLON {
  107996. /** @hidden */
  107997. export var defaultPixelShader: {
  107998. name: string;
  107999. shader: string;
  108000. };
  108001. }
  108002. declare module BABYLON {
  108003. /** @hidden */
  108004. export var defaultVertexDeclaration: {
  108005. name: string;
  108006. shader: string;
  108007. };
  108008. }
  108009. declare module BABYLON {
  108010. /** @hidden */
  108011. export var bumpVertexDeclaration: {
  108012. name: string;
  108013. shader: string;
  108014. };
  108015. }
  108016. declare module BABYLON {
  108017. /** @hidden */
  108018. export var bumpVertex: {
  108019. name: string;
  108020. shader: string;
  108021. };
  108022. }
  108023. declare module BABYLON {
  108024. /** @hidden */
  108025. export var fogVertex: {
  108026. name: string;
  108027. shader: string;
  108028. };
  108029. }
  108030. declare module BABYLON {
  108031. /** @hidden */
  108032. export var shadowsVertex: {
  108033. name: string;
  108034. shader: string;
  108035. };
  108036. }
  108037. declare module BABYLON {
  108038. /** @hidden */
  108039. export var pointCloudVertex: {
  108040. name: string;
  108041. shader: string;
  108042. };
  108043. }
  108044. declare module BABYLON {
  108045. /** @hidden */
  108046. export var logDepthVertex: {
  108047. name: string;
  108048. shader: string;
  108049. };
  108050. }
  108051. declare module BABYLON {
  108052. /** @hidden */
  108053. export var defaultVertexShader: {
  108054. name: string;
  108055. shader: string;
  108056. };
  108057. }
  108058. declare module BABYLON {
  108059. /** @hidden */
  108060. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108061. MAINUV1: boolean;
  108062. MAINUV2: boolean;
  108063. DIFFUSE: boolean;
  108064. DIFFUSEDIRECTUV: number;
  108065. AMBIENT: boolean;
  108066. AMBIENTDIRECTUV: number;
  108067. OPACITY: boolean;
  108068. OPACITYDIRECTUV: number;
  108069. OPACITYRGB: boolean;
  108070. REFLECTION: boolean;
  108071. EMISSIVE: boolean;
  108072. EMISSIVEDIRECTUV: number;
  108073. SPECULAR: boolean;
  108074. SPECULARDIRECTUV: number;
  108075. BUMP: boolean;
  108076. BUMPDIRECTUV: number;
  108077. PARALLAX: boolean;
  108078. PARALLAXOCCLUSION: boolean;
  108079. SPECULAROVERALPHA: boolean;
  108080. CLIPPLANE: boolean;
  108081. CLIPPLANE2: boolean;
  108082. CLIPPLANE3: boolean;
  108083. CLIPPLANE4: boolean;
  108084. ALPHATEST: boolean;
  108085. DEPTHPREPASS: boolean;
  108086. ALPHAFROMDIFFUSE: boolean;
  108087. POINTSIZE: boolean;
  108088. FOG: boolean;
  108089. SPECULARTERM: boolean;
  108090. DIFFUSEFRESNEL: boolean;
  108091. OPACITYFRESNEL: boolean;
  108092. REFLECTIONFRESNEL: boolean;
  108093. REFRACTIONFRESNEL: boolean;
  108094. EMISSIVEFRESNEL: boolean;
  108095. FRESNEL: boolean;
  108096. NORMAL: boolean;
  108097. UV1: boolean;
  108098. UV2: boolean;
  108099. VERTEXCOLOR: boolean;
  108100. VERTEXALPHA: boolean;
  108101. NUM_BONE_INFLUENCERS: number;
  108102. BonesPerMesh: number;
  108103. BONETEXTURE: boolean;
  108104. INSTANCES: boolean;
  108105. GLOSSINESS: boolean;
  108106. ROUGHNESS: boolean;
  108107. EMISSIVEASILLUMINATION: boolean;
  108108. LINKEMISSIVEWITHDIFFUSE: boolean;
  108109. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108110. LIGHTMAP: boolean;
  108111. LIGHTMAPDIRECTUV: number;
  108112. OBJECTSPACE_NORMALMAP: boolean;
  108113. USELIGHTMAPASSHADOWMAP: boolean;
  108114. REFLECTIONMAP_3D: boolean;
  108115. REFLECTIONMAP_SPHERICAL: boolean;
  108116. REFLECTIONMAP_PLANAR: boolean;
  108117. REFLECTIONMAP_CUBIC: boolean;
  108118. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108119. REFLECTIONMAP_PROJECTION: boolean;
  108120. REFLECTIONMAP_SKYBOX: boolean;
  108121. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108122. REFLECTIONMAP_EXPLICIT: boolean;
  108123. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108124. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108125. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108126. INVERTCUBICMAP: boolean;
  108127. LOGARITHMICDEPTH: boolean;
  108128. REFRACTION: boolean;
  108129. REFRACTIONMAP_3D: boolean;
  108130. REFLECTIONOVERALPHA: boolean;
  108131. TWOSIDEDLIGHTING: boolean;
  108132. SHADOWFLOAT: boolean;
  108133. MORPHTARGETS: boolean;
  108134. MORPHTARGETS_NORMAL: boolean;
  108135. MORPHTARGETS_TANGENT: boolean;
  108136. MORPHTARGETS_UV: boolean;
  108137. NUM_MORPH_INFLUENCERS: number;
  108138. NONUNIFORMSCALING: boolean;
  108139. PREMULTIPLYALPHA: boolean;
  108140. IMAGEPROCESSING: boolean;
  108141. VIGNETTE: boolean;
  108142. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108143. VIGNETTEBLENDMODEOPAQUE: boolean;
  108144. TONEMAPPING: boolean;
  108145. TONEMAPPING_ACES: boolean;
  108146. CONTRAST: boolean;
  108147. COLORCURVES: boolean;
  108148. COLORGRADING: boolean;
  108149. COLORGRADING3D: boolean;
  108150. SAMPLER3DGREENDEPTH: boolean;
  108151. SAMPLER3DBGRMAP: boolean;
  108152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108153. MULTIVIEW: boolean;
  108154. /**
  108155. * If the reflection texture on this material is in linear color space
  108156. * @hidden
  108157. */
  108158. IS_REFLECTION_LINEAR: boolean;
  108159. /**
  108160. * If the refraction texture on this material is in linear color space
  108161. * @hidden
  108162. */
  108163. IS_REFRACTION_LINEAR: boolean;
  108164. EXPOSURE: boolean;
  108165. constructor();
  108166. setReflectionMode(modeToEnable: string): void;
  108167. }
  108168. /**
  108169. * This is the default material used in Babylon. It is the best trade off between quality
  108170. * and performances.
  108171. * @see http://doc.babylonjs.com/babylon101/materials
  108172. */
  108173. export class StandardMaterial extends PushMaterial {
  108174. private _diffuseTexture;
  108175. /**
  108176. * The basic texture of the material as viewed under a light.
  108177. */
  108178. diffuseTexture: Nullable<BaseTexture>;
  108179. private _ambientTexture;
  108180. /**
  108181. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108182. */
  108183. ambientTexture: Nullable<BaseTexture>;
  108184. private _opacityTexture;
  108185. /**
  108186. * Define the transparency of the material from a texture.
  108187. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108188. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108189. */
  108190. opacityTexture: Nullable<BaseTexture>;
  108191. private _reflectionTexture;
  108192. /**
  108193. * Define the texture used to display the reflection.
  108194. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108195. */
  108196. reflectionTexture: Nullable<BaseTexture>;
  108197. private _emissiveTexture;
  108198. /**
  108199. * Define texture of the material as if self lit.
  108200. * This will be mixed in the final result even in the absence of light.
  108201. */
  108202. emissiveTexture: Nullable<BaseTexture>;
  108203. private _specularTexture;
  108204. /**
  108205. * Define how the color and intensity of the highlight given by the light in the material.
  108206. */
  108207. specularTexture: Nullable<BaseTexture>;
  108208. private _bumpTexture;
  108209. /**
  108210. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108211. * 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.
  108212. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108213. */
  108214. bumpTexture: Nullable<BaseTexture>;
  108215. private _lightmapTexture;
  108216. /**
  108217. * Complex lighting can be computationally expensive to compute at runtime.
  108218. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108219. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108220. */
  108221. lightmapTexture: Nullable<BaseTexture>;
  108222. private _refractionTexture;
  108223. /**
  108224. * Define the texture used to display the refraction.
  108225. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108226. */
  108227. refractionTexture: Nullable<BaseTexture>;
  108228. /**
  108229. * The color of the material lit by the environmental background lighting.
  108230. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108231. */
  108232. ambientColor: Color3;
  108233. /**
  108234. * The basic color of the material as viewed under a light.
  108235. */
  108236. diffuseColor: Color3;
  108237. /**
  108238. * Define how the color and intensity of the highlight given by the light in the material.
  108239. */
  108240. specularColor: Color3;
  108241. /**
  108242. * Define the color of the material as if self lit.
  108243. * This will be mixed in the final result even in the absence of light.
  108244. */
  108245. emissiveColor: Color3;
  108246. /**
  108247. * Defines how sharp are the highlights in the material.
  108248. * The bigger the value the sharper giving a more glossy feeling to the result.
  108249. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108250. */
  108251. specularPower: number;
  108252. private _useAlphaFromDiffuseTexture;
  108253. /**
  108254. * Does the transparency come from the diffuse texture alpha channel.
  108255. */
  108256. useAlphaFromDiffuseTexture: boolean;
  108257. private _useEmissiveAsIllumination;
  108258. /**
  108259. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108260. */
  108261. useEmissiveAsIllumination: boolean;
  108262. private _linkEmissiveWithDiffuse;
  108263. /**
  108264. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108265. * the emissive level when the final color is close to one.
  108266. */
  108267. linkEmissiveWithDiffuse: boolean;
  108268. private _useSpecularOverAlpha;
  108269. /**
  108270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108272. */
  108273. useSpecularOverAlpha: boolean;
  108274. private _useReflectionOverAlpha;
  108275. /**
  108276. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108277. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108278. */
  108279. useReflectionOverAlpha: boolean;
  108280. private _disableLighting;
  108281. /**
  108282. * Does lights from the scene impacts this material.
  108283. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108284. */
  108285. disableLighting: boolean;
  108286. private _useObjectSpaceNormalMap;
  108287. /**
  108288. * Allows using an object space normal map (instead of tangent space).
  108289. */
  108290. useObjectSpaceNormalMap: boolean;
  108291. private _useParallax;
  108292. /**
  108293. * Is parallax enabled or not.
  108294. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108295. */
  108296. useParallax: boolean;
  108297. private _useParallaxOcclusion;
  108298. /**
  108299. * Is parallax occlusion enabled or not.
  108300. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108301. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108302. */
  108303. useParallaxOcclusion: boolean;
  108304. /**
  108305. * 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.
  108306. */
  108307. parallaxScaleBias: number;
  108308. private _roughness;
  108309. /**
  108310. * Helps to define how blurry the reflections should appears in the material.
  108311. */
  108312. roughness: number;
  108313. /**
  108314. * In case of refraction, define the value of the index of refraction.
  108315. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108316. */
  108317. indexOfRefraction: number;
  108318. /**
  108319. * Invert the refraction texture alongside the y axis.
  108320. * It can be useful with procedural textures or probe for instance.
  108321. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108322. */
  108323. invertRefractionY: boolean;
  108324. /**
  108325. * Defines the alpha limits in alpha test mode.
  108326. */
  108327. alphaCutOff: number;
  108328. private _useLightmapAsShadowmap;
  108329. /**
  108330. * In case of light mapping, define whether the map contains light or shadow informations.
  108331. */
  108332. useLightmapAsShadowmap: boolean;
  108333. private _diffuseFresnelParameters;
  108334. /**
  108335. * Define the diffuse fresnel parameters of the material.
  108336. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108337. */
  108338. diffuseFresnelParameters: FresnelParameters;
  108339. private _opacityFresnelParameters;
  108340. /**
  108341. * Define the opacity fresnel parameters of the material.
  108342. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108343. */
  108344. opacityFresnelParameters: FresnelParameters;
  108345. private _reflectionFresnelParameters;
  108346. /**
  108347. * Define the reflection fresnel parameters of the material.
  108348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108349. */
  108350. reflectionFresnelParameters: FresnelParameters;
  108351. private _refractionFresnelParameters;
  108352. /**
  108353. * Define the refraction fresnel parameters of the material.
  108354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108355. */
  108356. refractionFresnelParameters: FresnelParameters;
  108357. private _emissiveFresnelParameters;
  108358. /**
  108359. * Define the emissive fresnel parameters of the material.
  108360. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108361. */
  108362. emissiveFresnelParameters: FresnelParameters;
  108363. private _useReflectionFresnelFromSpecular;
  108364. /**
  108365. * If true automatically deducts the fresnels values from the material specularity.
  108366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108367. */
  108368. useReflectionFresnelFromSpecular: boolean;
  108369. private _useGlossinessFromSpecularMapAlpha;
  108370. /**
  108371. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108372. */
  108373. useGlossinessFromSpecularMapAlpha: boolean;
  108374. private _maxSimultaneousLights;
  108375. /**
  108376. * Defines the maximum number of lights that can be used in the material
  108377. */
  108378. maxSimultaneousLights: number;
  108379. private _invertNormalMapX;
  108380. /**
  108381. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108382. */
  108383. invertNormalMapX: boolean;
  108384. private _invertNormalMapY;
  108385. /**
  108386. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108387. */
  108388. invertNormalMapY: boolean;
  108389. private _twoSidedLighting;
  108390. /**
  108391. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108392. */
  108393. twoSidedLighting: boolean;
  108394. /**
  108395. * Default configuration related to image processing available in the standard Material.
  108396. */
  108397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108398. /**
  108399. * Gets the image processing configuration used either in this material.
  108400. */
  108401. /**
  108402. * Sets the Default image processing configuration used either in the this material.
  108403. *
  108404. * If sets to null, the scene one is in use.
  108405. */
  108406. imageProcessingConfiguration: ImageProcessingConfiguration;
  108407. /**
  108408. * Keep track of the image processing observer to allow dispose and replace.
  108409. */
  108410. private _imageProcessingObserver;
  108411. /**
  108412. * Attaches a new image processing configuration to the Standard Material.
  108413. * @param configuration
  108414. */
  108415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108416. /**
  108417. * Gets wether the color curves effect is enabled.
  108418. */
  108419. /**
  108420. * Sets wether the color curves effect is enabled.
  108421. */
  108422. cameraColorCurvesEnabled: boolean;
  108423. /**
  108424. * Gets wether the color grading effect is enabled.
  108425. */
  108426. /**
  108427. * Gets wether the color grading effect is enabled.
  108428. */
  108429. cameraColorGradingEnabled: boolean;
  108430. /**
  108431. * Gets wether tonemapping is enabled or not.
  108432. */
  108433. /**
  108434. * Sets wether tonemapping is enabled or not
  108435. */
  108436. cameraToneMappingEnabled: boolean;
  108437. /**
  108438. * The camera exposure used on this material.
  108439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108440. * This corresponds to a photographic exposure.
  108441. */
  108442. /**
  108443. * The camera exposure used on this material.
  108444. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108445. * This corresponds to a photographic exposure.
  108446. */
  108447. cameraExposure: number;
  108448. /**
  108449. * Gets The camera contrast used on this material.
  108450. */
  108451. /**
  108452. * Sets The camera contrast used on this material.
  108453. */
  108454. cameraContrast: number;
  108455. /**
  108456. * Gets the Color Grading 2D Lookup Texture.
  108457. */
  108458. /**
  108459. * Sets the Color Grading 2D Lookup Texture.
  108460. */
  108461. cameraColorGradingTexture: Nullable<BaseTexture>;
  108462. /**
  108463. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108464. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108465. * 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;
  108466. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108467. */
  108468. /**
  108469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108471. * 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;
  108472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108473. */
  108474. cameraColorCurves: Nullable<ColorCurves>;
  108475. /**
  108476. * Custom callback helping to override the default shader used in the material.
  108477. */
  108478. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108479. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108480. protected _worldViewProjectionMatrix: Matrix;
  108481. protected _globalAmbientColor: Color3;
  108482. protected _useLogarithmicDepth: boolean;
  108483. protected _rebuildInParallel: boolean;
  108484. /**
  108485. * Instantiates a new standard material.
  108486. * This is the default material used in Babylon. It is the best trade off between quality
  108487. * and performances.
  108488. * @see http://doc.babylonjs.com/babylon101/materials
  108489. * @param name Define the name of the material in the scene
  108490. * @param scene Define the scene the material belong to
  108491. */
  108492. constructor(name: string, scene: Scene);
  108493. /**
  108494. * Gets a boolean indicating that current material needs to register RTT
  108495. */
  108496. readonly hasRenderTargetTextures: boolean;
  108497. /**
  108498. * Gets the current class name of the material e.g. "StandardMaterial"
  108499. * Mainly use in serialization.
  108500. * @returns the class name
  108501. */
  108502. getClassName(): string;
  108503. /**
  108504. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108505. * You can try switching to logarithmic depth.
  108506. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108507. */
  108508. useLogarithmicDepth: boolean;
  108509. /**
  108510. * Specifies if the material will require alpha blending
  108511. * @returns a boolean specifying if alpha blending is needed
  108512. */
  108513. needAlphaBlending(): boolean;
  108514. /**
  108515. * Specifies if this material should be rendered in alpha test mode
  108516. * @returns a boolean specifying if an alpha test is needed.
  108517. */
  108518. needAlphaTesting(): boolean;
  108519. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108520. /**
  108521. * Get the texture used for alpha test purpose.
  108522. * @returns the diffuse texture in case of the standard material.
  108523. */
  108524. getAlphaTestTexture(): Nullable<BaseTexture>;
  108525. /**
  108526. * Get if the submesh is ready to be used and all its information available.
  108527. * Child classes can use it to update shaders
  108528. * @param mesh defines the mesh to check
  108529. * @param subMesh defines which submesh to check
  108530. * @param useInstances specifies that instances should be used
  108531. * @returns a boolean indicating that the submesh is ready or not
  108532. */
  108533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108534. /**
  108535. * Builds the material UBO layouts.
  108536. * Used internally during the effect preparation.
  108537. */
  108538. buildUniformLayout(): void;
  108539. /**
  108540. * Unbinds the material from the mesh
  108541. */
  108542. unbind(): void;
  108543. /**
  108544. * Binds the submesh to this material by preparing the effect and shader to draw
  108545. * @param world defines the world transformation matrix
  108546. * @param mesh defines the mesh containing the submesh
  108547. * @param subMesh defines the submesh to bind the material to
  108548. */
  108549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108550. /**
  108551. * Get the list of animatables in the material.
  108552. * @returns the list of animatables object used in the material
  108553. */
  108554. getAnimatables(): IAnimatable[];
  108555. /**
  108556. * Gets the active textures from the material
  108557. * @returns an array of textures
  108558. */
  108559. getActiveTextures(): BaseTexture[];
  108560. /**
  108561. * Specifies if the material uses a texture
  108562. * @param texture defines the texture to check against the material
  108563. * @returns a boolean specifying if the material uses the texture
  108564. */
  108565. hasTexture(texture: BaseTexture): boolean;
  108566. /**
  108567. * Disposes the material
  108568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108570. */
  108571. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108572. /**
  108573. * Makes a duplicate of the material, and gives it a new name
  108574. * @param name defines the new name for the duplicated material
  108575. * @returns the cloned material
  108576. */
  108577. clone(name: string): StandardMaterial;
  108578. /**
  108579. * Serializes this material in a JSON representation
  108580. * @returns the serialized material object
  108581. */
  108582. serialize(): any;
  108583. /**
  108584. * Creates a standard material from parsed material data
  108585. * @param source defines the JSON representation of the material
  108586. * @param scene defines the hosting scene
  108587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108588. * @returns a new standard material
  108589. */
  108590. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108591. /**
  108592. * Are diffuse textures enabled in the application.
  108593. */
  108594. static DiffuseTextureEnabled: boolean;
  108595. /**
  108596. * Are ambient textures enabled in the application.
  108597. */
  108598. static AmbientTextureEnabled: boolean;
  108599. /**
  108600. * Are opacity textures enabled in the application.
  108601. */
  108602. static OpacityTextureEnabled: boolean;
  108603. /**
  108604. * Are reflection textures enabled in the application.
  108605. */
  108606. static ReflectionTextureEnabled: boolean;
  108607. /**
  108608. * Are emissive textures enabled in the application.
  108609. */
  108610. static EmissiveTextureEnabled: boolean;
  108611. /**
  108612. * Are specular textures enabled in the application.
  108613. */
  108614. static SpecularTextureEnabled: boolean;
  108615. /**
  108616. * Are bump textures enabled in the application.
  108617. */
  108618. static BumpTextureEnabled: boolean;
  108619. /**
  108620. * Are lightmap textures enabled in the application.
  108621. */
  108622. static LightmapTextureEnabled: boolean;
  108623. /**
  108624. * Are refraction textures enabled in the application.
  108625. */
  108626. static RefractionTextureEnabled: boolean;
  108627. /**
  108628. * Are color grading textures enabled in the application.
  108629. */
  108630. static ColorGradingTextureEnabled: boolean;
  108631. /**
  108632. * Are fresnels enabled in the application.
  108633. */
  108634. static FresnelEnabled: boolean;
  108635. }
  108636. }
  108637. declare module BABYLON {
  108638. /** @hidden */
  108639. export var imageProcessingPixelShader: {
  108640. name: string;
  108641. shader: string;
  108642. };
  108643. }
  108644. declare module BABYLON {
  108645. /**
  108646. * ImageProcessingPostProcess
  108647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108648. */
  108649. export class ImageProcessingPostProcess extends PostProcess {
  108650. /**
  108651. * Default configuration related to image processing available in the PBR Material.
  108652. */
  108653. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108654. /**
  108655. * Gets the image processing configuration used either in this material.
  108656. */
  108657. /**
  108658. * Sets the Default image processing configuration used either in the this material.
  108659. *
  108660. * If sets to null, the scene one is in use.
  108661. */
  108662. imageProcessingConfiguration: ImageProcessingConfiguration;
  108663. /**
  108664. * Keep track of the image processing observer to allow dispose and replace.
  108665. */
  108666. private _imageProcessingObserver;
  108667. /**
  108668. * Attaches a new image processing configuration to the PBR Material.
  108669. * @param configuration
  108670. */
  108671. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108672. /**
  108673. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108674. */
  108675. /**
  108676. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108677. */
  108678. colorCurves: Nullable<ColorCurves>;
  108679. /**
  108680. * Gets wether the color curves effect is enabled.
  108681. */
  108682. /**
  108683. * Sets wether the color curves effect is enabled.
  108684. */
  108685. colorCurvesEnabled: boolean;
  108686. /**
  108687. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108688. */
  108689. /**
  108690. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108691. */
  108692. colorGradingTexture: Nullable<BaseTexture>;
  108693. /**
  108694. * Gets wether the color grading effect is enabled.
  108695. */
  108696. /**
  108697. * Gets wether the color grading effect is enabled.
  108698. */
  108699. colorGradingEnabled: boolean;
  108700. /**
  108701. * Gets exposure used in the effect.
  108702. */
  108703. /**
  108704. * Sets exposure used in the effect.
  108705. */
  108706. exposure: number;
  108707. /**
  108708. * Gets wether tonemapping is enabled or not.
  108709. */
  108710. /**
  108711. * Sets wether tonemapping is enabled or not
  108712. */
  108713. toneMappingEnabled: boolean;
  108714. /**
  108715. * Gets the type of tone mapping effect.
  108716. */
  108717. /**
  108718. * Sets the type of tone mapping effect.
  108719. */
  108720. toneMappingType: number;
  108721. /**
  108722. * Gets contrast used in the effect.
  108723. */
  108724. /**
  108725. * Sets contrast used in the effect.
  108726. */
  108727. contrast: number;
  108728. /**
  108729. * Gets Vignette stretch size.
  108730. */
  108731. /**
  108732. * Sets Vignette stretch size.
  108733. */
  108734. vignetteStretch: number;
  108735. /**
  108736. * Gets Vignette centre X Offset.
  108737. */
  108738. /**
  108739. * Sets Vignette centre X Offset.
  108740. */
  108741. vignetteCentreX: number;
  108742. /**
  108743. * Gets Vignette centre Y Offset.
  108744. */
  108745. /**
  108746. * Sets Vignette centre Y Offset.
  108747. */
  108748. vignetteCentreY: number;
  108749. /**
  108750. * Gets Vignette weight or intensity of the vignette effect.
  108751. */
  108752. /**
  108753. * Sets Vignette weight or intensity of the vignette effect.
  108754. */
  108755. vignetteWeight: number;
  108756. /**
  108757. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108758. * if vignetteEnabled is set to true.
  108759. */
  108760. /**
  108761. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108762. * if vignetteEnabled is set to true.
  108763. */
  108764. vignetteColor: Color4;
  108765. /**
  108766. * Gets Camera field of view used by the Vignette effect.
  108767. */
  108768. /**
  108769. * Sets Camera field of view used by the Vignette effect.
  108770. */
  108771. vignetteCameraFov: number;
  108772. /**
  108773. * Gets the vignette blend mode allowing different kind of effect.
  108774. */
  108775. /**
  108776. * Sets the vignette blend mode allowing different kind of effect.
  108777. */
  108778. vignetteBlendMode: number;
  108779. /**
  108780. * Gets wether the vignette effect is enabled.
  108781. */
  108782. /**
  108783. * Sets wether the vignette effect is enabled.
  108784. */
  108785. vignetteEnabled: boolean;
  108786. private _fromLinearSpace;
  108787. /**
  108788. * Gets wether the input of the processing is in Gamma or Linear Space.
  108789. */
  108790. /**
  108791. * Sets wether the input of the processing is in Gamma or Linear Space.
  108792. */
  108793. fromLinearSpace: boolean;
  108794. /**
  108795. * Defines cache preventing GC.
  108796. */
  108797. private _defines;
  108798. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108799. /**
  108800. * "ImageProcessingPostProcess"
  108801. * @returns "ImageProcessingPostProcess"
  108802. */
  108803. getClassName(): string;
  108804. protected _updateParameters(): void;
  108805. dispose(camera?: Camera): void;
  108806. }
  108807. }
  108808. declare module BABYLON {
  108809. /**
  108810. * Class containing static functions to help procedurally build meshes
  108811. */
  108812. export class GroundBuilder {
  108813. /**
  108814. * Creates a ground mesh
  108815. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108816. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108818. * @param name defines the name of the mesh
  108819. * @param options defines the options used to create the mesh
  108820. * @param scene defines the hosting scene
  108821. * @returns the ground mesh
  108822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108823. */
  108824. static CreateGround(name: string, options: {
  108825. width?: number;
  108826. height?: number;
  108827. subdivisions?: number;
  108828. subdivisionsX?: number;
  108829. subdivisionsY?: number;
  108830. updatable?: boolean;
  108831. }, scene: any): Mesh;
  108832. /**
  108833. * Creates a tiled ground mesh
  108834. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108835. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108836. * * 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
  108837. * * 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
  108838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108839. * @param name defines the name of the mesh
  108840. * @param options defines the options used to create the mesh
  108841. * @param scene defines the hosting scene
  108842. * @returns the tiled ground mesh
  108843. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108844. */
  108845. static CreateTiledGround(name: string, options: {
  108846. xmin: number;
  108847. zmin: number;
  108848. xmax: number;
  108849. zmax: number;
  108850. subdivisions?: {
  108851. w: number;
  108852. h: number;
  108853. };
  108854. precision?: {
  108855. w: number;
  108856. h: number;
  108857. };
  108858. updatable?: boolean;
  108859. }, scene?: Nullable<Scene>): Mesh;
  108860. /**
  108861. * Creates a ground mesh from a height map
  108862. * * The parameter `url` sets the URL of the height map image resource.
  108863. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108864. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108865. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108866. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108867. * * 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.
  108868. * * 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).
  108869. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108871. * @param name defines the name of the mesh
  108872. * @param url defines the url to the height map
  108873. * @param options defines the options used to create the mesh
  108874. * @param scene defines the hosting scene
  108875. * @returns the ground mesh
  108876. * @see https://doc.babylonjs.com/babylon101/height_map
  108877. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108878. */
  108879. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108880. width?: number;
  108881. height?: number;
  108882. subdivisions?: number;
  108883. minHeight?: number;
  108884. maxHeight?: number;
  108885. colorFilter?: Color3;
  108886. alphaFilter?: number;
  108887. updatable?: boolean;
  108888. onReady?: (mesh: GroundMesh) => void;
  108889. }, scene?: Nullable<Scene>): GroundMesh;
  108890. }
  108891. }
  108892. declare module BABYLON {
  108893. /**
  108894. * Class containing static functions to help procedurally build meshes
  108895. */
  108896. export class TorusBuilder {
  108897. /**
  108898. * Creates a torus mesh
  108899. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108900. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108901. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108905. * @param name defines the name of the mesh
  108906. * @param options defines the options used to create the mesh
  108907. * @param scene defines the hosting scene
  108908. * @returns the torus mesh
  108909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108910. */
  108911. static CreateTorus(name: string, options: {
  108912. diameter?: number;
  108913. thickness?: number;
  108914. tessellation?: number;
  108915. updatable?: boolean;
  108916. sideOrientation?: number;
  108917. frontUVs?: Vector4;
  108918. backUVs?: Vector4;
  108919. }, scene: any): Mesh;
  108920. }
  108921. }
  108922. declare module BABYLON {
  108923. /**
  108924. * Class containing static functions to help procedurally build meshes
  108925. */
  108926. export class CylinderBuilder {
  108927. /**
  108928. * Creates a cylinder or a cone mesh
  108929. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108930. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108931. * * 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.
  108932. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108933. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108934. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108935. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108936. * * 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).
  108937. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108938. * * 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).
  108939. * * 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
  108940. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108941. * * 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
  108942. * * 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.
  108943. * * If `enclose` is false, a ring surface is one element.
  108944. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108945. * * 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
  108946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108949. * @param name defines the name of the mesh
  108950. * @param options defines the options used to create the mesh
  108951. * @param scene defines the hosting scene
  108952. * @returns the cylinder mesh
  108953. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108954. */
  108955. static CreateCylinder(name: string, options: {
  108956. height?: number;
  108957. diameterTop?: number;
  108958. diameterBottom?: number;
  108959. diameter?: number;
  108960. tessellation?: number;
  108961. subdivisions?: number;
  108962. arc?: number;
  108963. faceColors?: Color4[];
  108964. faceUV?: Vector4[];
  108965. updatable?: boolean;
  108966. hasRings?: boolean;
  108967. enclose?: boolean;
  108968. cap?: number;
  108969. sideOrientation?: number;
  108970. frontUVs?: Vector4;
  108971. backUVs?: Vector4;
  108972. }, scene: any): Mesh;
  108973. }
  108974. }
  108975. declare module BABYLON {
  108976. /**
  108977. * Options to modify the vr teleportation behavior.
  108978. */
  108979. export interface VRTeleportationOptions {
  108980. /**
  108981. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108982. */
  108983. floorMeshName?: string;
  108984. /**
  108985. * A list of meshes to be used as the teleportation floor. (default: empty)
  108986. */
  108987. floorMeshes?: Mesh[];
  108988. }
  108989. /**
  108990. * Options to modify the vr experience helper's behavior.
  108991. */
  108992. export interface VRExperienceHelperOptions extends WebVROptions {
  108993. /**
  108994. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108995. */
  108996. createDeviceOrientationCamera?: boolean;
  108997. /**
  108998. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108999. */
  109000. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109001. /**
  109002. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109003. */
  109004. laserToggle?: boolean;
  109005. /**
  109006. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109007. */
  109008. floorMeshes?: Mesh[];
  109009. /**
  109010. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109011. */
  109012. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109013. }
  109014. /**
  109015. * Event containing information after VR has been entered
  109016. */
  109017. export class OnAfterEnteringVRObservableEvent {
  109018. /**
  109019. * If entering vr was successful
  109020. */
  109021. success: boolean;
  109022. }
  109023. /**
  109024. * Helps to quickly add VR support to an existing scene.
  109025. * See http://doc.babylonjs.com/how_to/webvr_helper
  109026. */
  109027. export class VRExperienceHelper {
  109028. /** Options to modify the vr experience helper's behavior. */
  109029. webVROptions: VRExperienceHelperOptions;
  109030. private _scene;
  109031. private _position;
  109032. private _btnVR;
  109033. private _btnVRDisplayed;
  109034. private _webVRsupported;
  109035. private _webVRready;
  109036. private _webVRrequesting;
  109037. private _webVRpresenting;
  109038. private _hasEnteredVR;
  109039. private _fullscreenVRpresenting;
  109040. private _inputElement;
  109041. private _webVRCamera;
  109042. private _vrDeviceOrientationCamera;
  109043. private _deviceOrientationCamera;
  109044. private _existingCamera;
  109045. private _onKeyDown;
  109046. private _onVrDisplayPresentChange;
  109047. private _onVRDisplayChanged;
  109048. private _onVRRequestPresentStart;
  109049. private _onVRRequestPresentComplete;
  109050. /**
  109051. * 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)
  109052. */
  109053. enableGazeEvenWhenNoPointerLock: boolean;
  109054. /**
  109055. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109056. */
  109057. exitVROnDoubleTap: boolean;
  109058. /**
  109059. * Observable raised right before entering VR.
  109060. */
  109061. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109062. /**
  109063. * Observable raised when entering VR has completed.
  109064. */
  109065. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109066. /**
  109067. * Observable raised when exiting VR.
  109068. */
  109069. onExitingVRObservable: Observable<VRExperienceHelper>;
  109070. /**
  109071. * Observable raised when controller mesh is loaded.
  109072. */
  109073. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109074. /** Return this.onEnteringVRObservable
  109075. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109076. */
  109077. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109078. /** Return this.onExitingVRObservable
  109079. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109080. */
  109081. readonly onExitingVR: Observable<VRExperienceHelper>;
  109082. /** Return this.onControllerMeshLoadedObservable
  109083. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109084. */
  109085. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109086. private _rayLength;
  109087. private _useCustomVRButton;
  109088. private _teleportationRequested;
  109089. private _teleportActive;
  109090. private _floorMeshName;
  109091. private _floorMeshesCollection;
  109092. private _rotationAllowed;
  109093. private _teleportBackwardsVector;
  109094. private _teleportationTarget;
  109095. private _isDefaultTeleportationTarget;
  109096. private _postProcessMove;
  109097. private _teleportationFillColor;
  109098. private _teleportationBorderColor;
  109099. private _rotationAngle;
  109100. private _haloCenter;
  109101. private _cameraGazer;
  109102. private _padSensibilityUp;
  109103. private _padSensibilityDown;
  109104. private _leftController;
  109105. private _rightController;
  109106. /**
  109107. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109108. */
  109109. onNewMeshSelected: Observable<AbstractMesh>;
  109110. /**
  109111. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109112. * This observable will provide the mesh and the controller used to select the mesh
  109113. */
  109114. onMeshSelectedWithController: Observable<{
  109115. mesh: AbstractMesh;
  109116. controller: WebVRController;
  109117. }>;
  109118. /**
  109119. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109120. */
  109121. onNewMeshPicked: Observable<PickingInfo>;
  109122. private _circleEase;
  109123. /**
  109124. * Observable raised before camera teleportation
  109125. */
  109126. onBeforeCameraTeleport: Observable<Vector3>;
  109127. /**
  109128. * Observable raised after camera teleportation
  109129. */
  109130. onAfterCameraTeleport: Observable<Vector3>;
  109131. /**
  109132. * Observable raised when current selected mesh gets unselected
  109133. */
  109134. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109135. private _raySelectionPredicate;
  109136. /**
  109137. * To be optionaly changed by user to define custom ray selection
  109138. */
  109139. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109140. /**
  109141. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109142. */
  109143. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109144. /**
  109145. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109146. */
  109147. teleportationEnabled: boolean;
  109148. private _defaultHeight;
  109149. private _teleportationInitialized;
  109150. private _interactionsEnabled;
  109151. private _interactionsRequested;
  109152. private _displayGaze;
  109153. private _displayLaserPointer;
  109154. /**
  109155. * The mesh used to display where the user is going to teleport.
  109156. */
  109157. /**
  109158. * Sets the mesh to be used to display where the user is going to teleport.
  109159. */
  109160. teleportationTarget: Mesh;
  109161. /**
  109162. * 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
  109163. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109164. * See http://doc.babylonjs.com/resources/baking_transformations
  109165. */
  109166. gazeTrackerMesh: Mesh;
  109167. /**
  109168. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109169. */
  109170. updateGazeTrackerScale: boolean;
  109171. /**
  109172. * If the gaze trackers color should be updated when selecting meshes
  109173. */
  109174. updateGazeTrackerColor: boolean;
  109175. /**
  109176. * If the controller laser color should be updated when selecting meshes
  109177. */
  109178. updateControllerLaserColor: boolean;
  109179. /**
  109180. * The gaze tracking mesh corresponding to the left controller
  109181. */
  109182. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109183. /**
  109184. * The gaze tracking mesh corresponding to the right controller
  109185. */
  109186. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109187. /**
  109188. * If the ray of the gaze should be displayed.
  109189. */
  109190. /**
  109191. * Sets if the ray of the gaze should be displayed.
  109192. */
  109193. displayGaze: boolean;
  109194. /**
  109195. * If the ray of the LaserPointer should be displayed.
  109196. */
  109197. /**
  109198. * Sets if the ray of the LaserPointer should be displayed.
  109199. */
  109200. displayLaserPointer: boolean;
  109201. /**
  109202. * The deviceOrientationCamera used as the camera when not in VR.
  109203. */
  109204. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109205. /**
  109206. * Based on the current WebVR support, returns the current VR camera used.
  109207. */
  109208. readonly currentVRCamera: Nullable<Camera>;
  109209. /**
  109210. * The webVRCamera which is used when in VR.
  109211. */
  109212. readonly webVRCamera: WebVRFreeCamera;
  109213. /**
  109214. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109215. */
  109216. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109217. /**
  109218. * The html button that is used to trigger entering into VR.
  109219. */
  109220. readonly vrButton: Nullable<HTMLButtonElement>;
  109221. private readonly _teleportationRequestInitiated;
  109222. /**
  109223. * Defines wether or not Pointer lock should be requested when switching to
  109224. * full screen.
  109225. */
  109226. requestPointerLockOnFullScreen: boolean;
  109227. /**
  109228. * Instantiates a VRExperienceHelper.
  109229. * Helps to quickly add VR support to an existing scene.
  109230. * @param scene The scene the VRExperienceHelper belongs to.
  109231. * @param webVROptions Options to modify the vr experience helper's behavior.
  109232. */
  109233. constructor(scene: Scene,
  109234. /** Options to modify the vr experience helper's behavior. */
  109235. webVROptions?: VRExperienceHelperOptions);
  109236. private _onDefaultMeshLoaded;
  109237. private _onResize;
  109238. private _onFullscreenChange;
  109239. /**
  109240. * Gets a value indicating if we are currently in VR mode.
  109241. */
  109242. readonly isInVRMode: boolean;
  109243. private onVrDisplayPresentChange;
  109244. private onVRDisplayChanged;
  109245. private moveButtonToBottomRight;
  109246. private displayVRButton;
  109247. private updateButtonVisibility;
  109248. private _cachedAngularSensibility;
  109249. /**
  109250. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109251. * Otherwise, will use the fullscreen API.
  109252. */
  109253. enterVR(): void;
  109254. /**
  109255. * Attempt to exit VR, or fullscreen.
  109256. */
  109257. exitVR(): void;
  109258. /**
  109259. * The position of the vr experience helper.
  109260. */
  109261. /**
  109262. * Sets the position of the vr experience helper.
  109263. */
  109264. position: Vector3;
  109265. /**
  109266. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109267. */
  109268. enableInteractions(): void;
  109269. private readonly _noControllerIsActive;
  109270. private beforeRender;
  109271. private _isTeleportationFloor;
  109272. /**
  109273. * Adds a floor mesh to be used for teleportation.
  109274. * @param floorMesh the mesh to be used for teleportation.
  109275. */
  109276. addFloorMesh(floorMesh: Mesh): void;
  109277. /**
  109278. * Removes a floor mesh from being used for teleportation.
  109279. * @param floorMesh the mesh to be removed.
  109280. */
  109281. removeFloorMesh(floorMesh: Mesh): void;
  109282. /**
  109283. * Enables interactions and teleportation using the VR controllers and gaze.
  109284. * @param vrTeleportationOptions options to modify teleportation behavior.
  109285. */
  109286. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109287. private _onNewGamepadConnected;
  109288. private _tryEnableInteractionOnController;
  109289. private _onNewGamepadDisconnected;
  109290. private _enableInteractionOnController;
  109291. private _checkTeleportWithRay;
  109292. private _checkRotate;
  109293. private _checkTeleportBackwards;
  109294. private _enableTeleportationOnController;
  109295. private _createTeleportationCircles;
  109296. private _displayTeleportationTarget;
  109297. private _hideTeleportationTarget;
  109298. private _rotateCamera;
  109299. private _moveTeleportationSelectorTo;
  109300. private _workingVector;
  109301. private _workingQuaternion;
  109302. private _workingMatrix;
  109303. /**
  109304. * Teleports the users feet to the desired location
  109305. * @param location The location where the user's feet should be placed
  109306. */
  109307. teleportCamera(location: Vector3): void;
  109308. private _convertNormalToDirectionOfRay;
  109309. private _castRayAndSelectObject;
  109310. private _notifySelectedMeshUnselected;
  109311. /**
  109312. * Sets the color of the laser ray from the vr controllers.
  109313. * @param color new color for the ray.
  109314. */
  109315. changeLaserColor(color: Color3): void;
  109316. /**
  109317. * Sets the color of the ray from the vr headsets gaze.
  109318. * @param color new color for the ray.
  109319. */
  109320. changeGazeColor(color: Color3): void;
  109321. /**
  109322. * Exits VR and disposes of the vr experience helper
  109323. */
  109324. dispose(): void;
  109325. /**
  109326. * Gets the name of the VRExperienceHelper class
  109327. * @returns "VRExperienceHelper"
  109328. */
  109329. getClassName(): string;
  109330. }
  109331. }
  109332. declare module BABYLON {
  109333. /**
  109334. * States of the webXR experience
  109335. */
  109336. export enum WebXRState {
  109337. /**
  109338. * Transitioning to being in XR mode
  109339. */
  109340. ENTERING_XR = 0,
  109341. /**
  109342. * Transitioning to non XR mode
  109343. */
  109344. EXITING_XR = 1,
  109345. /**
  109346. * In XR mode and presenting
  109347. */
  109348. IN_XR = 2,
  109349. /**
  109350. * Not entered XR mode
  109351. */
  109352. NOT_IN_XR = 3
  109353. }
  109354. /**
  109355. * Abstraction of the XR render target
  109356. */
  109357. export interface WebXRRenderTarget extends IDisposable {
  109358. /**
  109359. * xrpresent context of the canvas which can be used to display/mirror xr content
  109360. */
  109361. canvasContext: WebGLRenderingContext;
  109362. /**
  109363. * xr layer for the canvas
  109364. */
  109365. xrLayer: Nullable<XRWebGLLayer>;
  109366. /**
  109367. * Initializes the xr layer for the session
  109368. * @param xrSession xr session
  109369. * @returns a promise that will resolve once the XR Layer has been created
  109370. */
  109371. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109372. }
  109373. }
  109374. declare module BABYLON {
  109375. /**
  109376. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109377. */
  109378. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109379. private _engine;
  109380. private _canvas;
  109381. /**
  109382. * xrpresent context of the canvas which can be used to display/mirror xr content
  109383. */
  109384. canvasContext: WebGLRenderingContext;
  109385. /**
  109386. * xr layer for the canvas
  109387. */
  109388. xrLayer: Nullable<XRWebGLLayer>;
  109389. /**
  109390. * Initializes the xr layer for the session
  109391. * @param xrSession xr session
  109392. * @returns a promise that will resolve once the XR Layer has been created
  109393. */
  109394. initializeXRLayerAsync(xrSession: any): any;
  109395. /**
  109396. * Initializes the canvas to be added/removed upon entering/exiting xr
  109397. * @param engine the Babylon engine
  109398. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109399. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109400. */
  109401. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109402. /**
  109403. * Disposes of the object
  109404. */
  109405. dispose(): void;
  109406. private _setManagedOutputCanvas;
  109407. private _addCanvas;
  109408. private _removeCanvas;
  109409. }
  109410. }
  109411. declare module BABYLON {
  109412. /**
  109413. * Manages an XRSession to work with Babylon's engine
  109414. * @see https://doc.babylonjs.com/how_to/webxr
  109415. */
  109416. export class WebXRSessionManager implements IDisposable {
  109417. private scene;
  109418. /**
  109419. * Fires every time a new xrFrame arrives which can be used to update the camera
  109420. */
  109421. onXRFrameObservable: Observable<any>;
  109422. /**
  109423. * Fires when the xr session is ended either by the device or manually done
  109424. */
  109425. onXRSessionEnded: Observable<any>;
  109426. /**
  109427. * Underlying xr session
  109428. */
  109429. session: XRSession;
  109430. /**
  109431. * Type of reference space used when creating the session
  109432. */
  109433. referenceSpace: XRReferenceSpace;
  109434. /**
  109435. * Current XR frame
  109436. */
  109437. currentFrame: Nullable<XRFrame>;
  109438. private _xrNavigator;
  109439. private baseLayer;
  109440. private _rttProvider;
  109441. private _sessionEnded;
  109442. /**
  109443. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109444. * @param scene The scene which the session should be created for
  109445. */
  109446. constructor(scene: Scene);
  109447. /**
  109448. * Initializes the manager
  109449. * After initialization enterXR can be called to start an XR session
  109450. * @returns Promise which resolves after it is initialized
  109451. */
  109452. initializeAsync(): Promise<void>;
  109453. /**
  109454. * Initializes an xr session
  109455. * @param xrSessionMode mode to initialize
  109456. * @param optionalFeatures defines optional values to pass to the session builder
  109457. * @returns a promise which will resolve once the session has been initialized
  109458. */
  109459. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109460. /**
  109461. * Sets the reference space on the xr session
  109462. * @param referenceSpace space to set
  109463. * @returns a promise that will resolve once the reference space has been set
  109464. */
  109465. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109466. /**
  109467. * Updates the render state of the session
  109468. * @param state state to set
  109469. * @returns a promise that resolves once the render state has been updated
  109470. */
  109471. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109472. /**
  109473. * Starts rendering to the xr layer
  109474. * @returns a promise that will resolve once rendering has started
  109475. */
  109476. startRenderingToXRAsync(): Promise<void>;
  109477. /**
  109478. * Gets the correct render target texture to be rendered this frame for this eye
  109479. * @param eye the eye for which to get the render target
  109480. * @returns the render target for the specified eye
  109481. */
  109482. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109483. /**
  109484. * Stops the xrSession and restores the renderloop
  109485. * @returns Promise which resolves after it exits XR
  109486. */
  109487. exitXRAsync(): Promise<void>;
  109488. /**
  109489. * Checks if a session would be supported for the creation options specified
  109490. * @param sessionMode session mode to check if supported eg. immersive-vr
  109491. * @returns true if supported
  109492. */
  109493. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109494. /**
  109495. * Creates a WebXRRenderTarget object for the XR session
  109496. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109497. * @returns a WebXR render target to which the session can render
  109498. */
  109499. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109500. /**
  109501. * @hidden
  109502. * Converts the render layer of xrSession to a render target
  109503. * @param session session to create render target for
  109504. * @param scene scene the new render target should be created for
  109505. */
  109506. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109507. /**
  109508. * Disposes of the session manager
  109509. */
  109510. dispose(): void;
  109511. }
  109512. }
  109513. declare module BABYLON {
  109514. /**
  109515. * WebXR Camera which holds the views for the xrSession
  109516. * @see https://doc.babylonjs.com/how_to/webxr
  109517. */
  109518. export class WebXRCamera extends FreeCamera {
  109519. private static _TmpMatrix;
  109520. /**
  109521. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109522. * @param name the name of the camera
  109523. * @param scene the scene to add the camera to
  109524. */
  109525. constructor(name: string, scene: Scene);
  109526. private _updateNumberOfRigCameras;
  109527. /** @hidden */
  109528. _updateForDualEyeDebugging(): void;
  109529. /**
  109530. * Updates the cameras position from the current pose information of the XR session
  109531. * @param xrSessionManager the session containing pose information
  109532. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109533. */
  109534. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109535. }
  109536. }
  109537. declare module BABYLON {
  109538. /**
  109539. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109540. * @see https://doc.babylonjs.com/how_to/webxr
  109541. */
  109542. export class WebXRExperienceHelper implements IDisposable {
  109543. private scene;
  109544. /**
  109545. * 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
  109546. */
  109547. container: AbstractMesh;
  109548. /**
  109549. * Camera used to render xr content
  109550. */
  109551. camera: WebXRCamera;
  109552. /**
  109553. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109554. */
  109555. state: WebXRState;
  109556. private _setState;
  109557. private static _TmpVector;
  109558. /**
  109559. * Fires when the state of the experience helper has changed
  109560. */
  109561. onStateChangedObservable: Observable<WebXRState>;
  109562. /** Session manager used to keep track of xr session */
  109563. sessionManager: WebXRSessionManager;
  109564. private _nonVRCamera;
  109565. private _originalSceneAutoClear;
  109566. private _supported;
  109567. /**
  109568. * Creates the experience helper
  109569. * @param scene the scene to attach the experience helper to
  109570. * @returns a promise for the experience helper
  109571. */
  109572. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109573. /**
  109574. * Creates a WebXRExperienceHelper
  109575. * @param scene The scene the helper should be created in
  109576. */
  109577. private constructor();
  109578. /**
  109579. * Exits XR mode and returns the scene to its original state
  109580. * @returns promise that resolves after xr mode has exited
  109581. */
  109582. exitXRAsync(): Promise<void>;
  109583. /**
  109584. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109585. * @param sessionMode options for the XR session
  109586. * @param referenceSpaceType frame of reference of the XR session
  109587. * @param renderTarget the output canvas that will be used to enter XR mode
  109588. * @returns promise that resolves after xr mode has entered
  109589. */
  109590. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  109591. /**
  109592. * Updates the global position of the camera by moving the camera's container
  109593. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109594. * @param position The desired global position of the camera
  109595. */
  109596. setPositionOfCameraUsingContainer(position: Vector3): void;
  109597. /**
  109598. * Rotates the xr camera by rotating the camera's container around the camera's position
  109599. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109600. * @param rotation the desired quaternion rotation to apply to the camera
  109601. */
  109602. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109603. /**
  109604. * Disposes of the experience helper
  109605. */
  109606. dispose(): void;
  109607. }
  109608. }
  109609. declare module BABYLON {
  109610. /**
  109611. * Button which can be used to enter a different mode of XR
  109612. */
  109613. export class WebXREnterExitUIButton {
  109614. /** button element */
  109615. element: HTMLElement;
  109616. /** XR initialization options for the button */
  109617. sessionMode: XRSessionMode;
  109618. /** Reference space type */
  109619. referenceSpaceType: XRReferenceSpaceType;
  109620. /**
  109621. * Creates a WebXREnterExitUIButton
  109622. * @param element button element
  109623. * @param sessionMode XR initialization session mode
  109624. * @param referenceSpaceType the type of reference space to be used
  109625. */
  109626. constructor(
  109627. /** button element */
  109628. element: HTMLElement,
  109629. /** XR initialization options for the button */
  109630. sessionMode: XRSessionMode,
  109631. /** Reference space type */
  109632. referenceSpaceType: XRReferenceSpaceType);
  109633. /**
  109634. * Overwritable function which can be used to update the button's visuals when the state changes
  109635. * @param activeButton the current active button in the UI
  109636. */
  109637. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109638. }
  109639. /**
  109640. * Options to create the webXR UI
  109641. */
  109642. export class WebXREnterExitUIOptions {
  109643. /**
  109644. * Context to enter xr with
  109645. */
  109646. renderTarget?: Nullable<WebXRRenderTarget>;
  109647. /**
  109648. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109649. */
  109650. customButtons?: Array<WebXREnterExitUIButton>;
  109651. }
  109652. /**
  109653. * UI to allow the user to enter/exit XR mode
  109654. */
  109655. export class WebXREnterExitUI implements IDisposable {
  109656. private scene;
  109657. private _overlay;
  109658. private _buttons;
  109659. private _activeButton;
  109660. /**
  109661. * Fired every time the active button is changed.
  109662. *
  109663. * When xr is entered via a button that launches xr that button will be the callback parameter
  109664. *
  109665. * When exiting xr the callback parameter will be null)
  109666. */
  109667. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109668. /**
  109669. * Creates UI to allow the user to enter/exit XR mode
  109670. * @param scene the scene to add the ui to
  109671. * @param helper the xr experience helper to enter/exit xr with
  109672. * @param options options to configure the UI
  109673. * @returns the created ui
  109674. */
  109675. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109676. private constructor();
  109677. private _updateButtons;
  109678. /**
  109679. * Disposes of the object
  109680. */
  109681. dispose(): void;
  109682. }
  109683. }
  109684. declare module BABYLON {
  109685. /**
  109686. * Represents an XR input
  109687. */
  109688. export class WebXRController {
  109689. private scene;
  109690. /** The underlying input source for the controller */
  109691. inputSource: XRInputSource;
  109692. private parentContainer;
  109693. /**
  109694. * 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
  109695. */
  109696. grip?: AbstractMesh;
  109697. /**
  109698. * Pointer which can be used to select objects or attach a visible laser to
  109699. */
  109700. pointer: AbstractMesh;
  109701. private _gamepadMode;
  109702. /**
  109703. * If available, this is the gamepad object related to this controller.
  109704. * Using this object it is possible to get click events and trackpad changes of the
  109705. * webxr controller that is currently being used.
  109706. */
  109707. gamepadController?: WebVRController;
  109708. /**
  109709. * Event that fires when the controller is removed/disposed
  109710. */
  109711. onDisposeObservable: Observable<{}>;
  109712. private _tmpMatrix;
  109713. private _tmpQuaternion;
  109714. private _tmpVector;
  109715. /**
  109716. * Creates the controller
  109717. * @see https://doc.babylonjs.com/how_to/webxr
  109718. * @param scene the scene which the controller should be associated to
  109719. * @param inputSource the underlying input source for the controller
  109720. * @param parentContainer parent that the controller meshes should be children of
  109721. */
  109722. constructor(scene: Scene,
  109723. /** The underlying input source for the controller */
  109724. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109725. /**
  109726. * Updates the controller pose based on the given XRFrame
  109727. * @param xrFrame xr frame to update the pose with
  109728. * @param referenceSpace reference space to use
  109729. */
  109730. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109731. /**
  109732. * Gets a world space ray coming from the controller
  109733. * @param result the resulting ray
  109734. */
  109735. getWorldPointerRayToRef(result: Ray): void;
  109736. /**
  109737. * Get the scene associated with this controller
  109738. * @returns the scene object
  109739. */
  109740. getScene(): Scene;
  109741. /**
  109742. * Disposes of the object
  109743. */
  109744. dispose(): void;
  109745. }
  109746. }
  109747. declare module BABYLON {
  109748. /**
  109749. * XR input used to track XR inputs such as controllers/rays
  109750. */
  109751. export class WebXRInput implements IDisposable {
  109752. /**
  109753. * Base experience the input listens to
  109754. */
  109755. baseExperience: WebXRExperienceHelper;
  109756. /**
  109757. * XR controllers being tracked
  109758. */
  109759. controllers: Array<WebXRController>;
  109760. private _frameObserver;
  109761. private _stateObserver;
  109762. /**
  109763. * Event when a controller has been connected/added
  109764. */
  109765. onControllerAddedObservable: Observable<WebXRController>;
  109766. /**
  109767. * Event when a controller has been removed/disconnected
  109768. */
  109769. onControllerRemovedObservable: Observable<WebXRController>;
  109770. /**
  109771. * Initializes the WebXRInput
  109772. * @param baseExperience experience helper which the input should be created for
  109773. */
  109774. constructor(
  109775. /**
  109776. * Base experience the input listens to
  109777. */
  109778. baseExperience: WebXRExperienceHelper);
  109779. private _onInputSourcesChange;
  109780. private _addAndRemoveControllers;
  109781. /**
  109782. * Disposes of the object
  109783. */
  109784. dispose(): void;
  109785. }
  109786. }
  109787. declare module BABYLON {
  109788. /**
  109789. * Enables teleportation
  109790. */
  109791. export class WebXRControllerTeleportation {
  109792. private _teleportationFillColor;
  109793. private _teleportationBorderColor;
  109794. private _tmpRay;
  109795. private _tmpVector;
  109796. /**
  109797. * Creates a WebXRControllerTeleportation
  109798. * @param input input manager to add teleportation to
  109799. * @param floorMeshes floormeshes which can be teleported to
  109800. */
  109801. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109802. }
  109803. }
  109804. declare module BABYLON {
  109805. /**
  109806. * Handles pointer input automatically for the pointer of XR controllers
  109807. */
  109808. export class WebXRControllerPointerSelection {
  109809. private static _idCounter;
  109810. private _tmpRay;
  109811. /**
  109812. * Creates a WebXRControllerPointerSelection
  109813. * @param input input manager to setup pointer selection
  109814. */
  109815. constructor(input: WebXRInput);
  109816. private _convertNormalToDirectionOfRay;
  109817. private _updatePointerDistance;
  109818. }
  109819. }
  109820. declare module BABYLON {
  109821. /**
  109822. * Class used to represent data loading progression
  109823. */
  109824. export class SceneLoaderProgressEvent {
  109825. /** defines if data length to load can be evaluated */
  109826. readonly lengthComputable: boolean;
  109827. /** defines the loaded data length */
  109828. readonly loaded: number;
  109829. /** defines the data length to load */
  109830. readonly total: number;
  109831. /**
  109832. * Create a new progress event
  109833. * @param lengthComputable defines if data length to load can be evaluated
  109834. * @param loaded defines the loaded data length
  109835. * @param total defines the data length to load
  109836. */
  109837. constructor(
  109838. /** defines if data length to load can be evaluated */
  109839. lengthComputable: boolean,
  109840. /** defines the loaded data length */
  109841. loaded: number,
  109842. /** defines the data length to load */
  109843. total: number);
  109844. /**
  109845. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109846. * @param event defines the source event
  109847. * @returns a new SceneLoaderProgressEvent
  109848. */
  109849. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109850. }
  109851. /**
  109852. * Interface used by SceneLoader plugins to define supported file extensions
  109853. */
  109854. export interface ISceneLoaderPluginExtensions {
  109855. /**
  109856. * Defines the list of supported extensions
  109857. */
  109858. [extension: string]: {
  109859. isBinary: boolean;
  109860. };
  109861. }
  109862. /**
  109863. * Interface used by SceneLoader plugin factory
  109864. */
  109865. export interface ISceneLoaderPluginFactory {
  109866. /**
  109867. * Defines the name of the factory
  109868. */
  109869. name: string;
  109870. /**
  109871. * Function called to create a new plugin
  109872. * @return the new plugin
  109873. */
  109874. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109875. /**
  109876. * The callback that returns true if the data can be directly loaded.
  109877. * @param data string containing the file data
  109878. * @returns if the data can be loaded directly
  109879. */
  109880. canDirectLoad?(data: string): boolean;
  109881. }
  109882. /**
  109883. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109884. */
  109885. export interface ISceneLoaderPluginBase {
  109886. /**
  109887. * The friendly name of this plugin.
  109888. */
  109889. name: string;
  109890. /**
  109891. * The file extensions supported by this plugin.
  109892. */
  109893. extensions: string | ISceneLoaderPluginExtensions;
  109894. /**
  109895. * The callback called when loading from a url.
  109896. * @param scene scene loading this url
  109897. * @param url url to load
  109898. * @param onSuccess callback called when the file successfully loads
  109899. * @param onProgress callback called while file is loading (if the server supports this mode)
  109900. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109901. * @param onError callback called when the file fails to load
  109902. * @returns a file request object
  109903. */
  109904. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109905. /**
  109906. * The callback called when loading from a file object.
  109907. * @param scene scene loading this file
  109908. * @param file defines the file to load
  109909. * @param onSuccess defines the callback to call when data is loaded
  109910. * @param onProgress defines the callback to call during loading process
  109911. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109912. * @param onError defines the callback to call when an error occurs
  109913. * @returns a file request object
  109914. */
  109915. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109916. /**
  109917. * The callback that returns true if the data can be directly loaded.
  109918. * @param data string containing the file data
  109919. * @returns if the data can be loaded directly
  109920. */
  109921. canDirectLoad?(data: string): boolean;
  109922. /**
  109923. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109924. * @param scene scene loading this data
  109925. * @param data string containing the data
  109926. * @returns data to pass to the plugin
  109927. */
  109928. directLoad?(scene: Scene, data: string): any;
  109929. /**
  109930. * The callback that allows custom handling of the root url based on the response url.
  109931. * @param rootUrl the original root url
  109932. * @param responseURL the response url if available
  109933. * @returns the new root url
  109934. */
  109935. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109936. }
  109937. /**
  109938. * Interface used to define a SceneLoader plugin
  109939. */
  109940. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109941. /**
  109942. * Import meshes into a scene.
  109943. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109944. * @param scene The scene to import into
  109945. * @param data The data to import
  109946. * @param rootUrl The root url for scene and resources
  109947. * @param meshes The meshes array to import into
  109948. * @param particleSystems The particle systems array to import into
  109949. * @param skeletons The skeletons array to import into
  109950. * @param onError The callback when import fails
  109951. * @returns True if successful or false otherwise
  109952. */
  109953. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109954. /**
  109955. * Load into a scene.
  109956. * @param scene The scene to load into
  109957. * @param data The data to import
  109958. * @param rootUrl The root url for scene and resources
  109959. * @param onError The callback when import fails
  109960. * @returns True if successful or false otherwise
  109961. */
  109962. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109963. /**
  109964. * Load into an asset container.
  109965. * @param scene The scene to load into
  109966. * @param data The data to import
  109967. * @param rootUrl The root url for scene and resources
  109968. * @param onError The callback when import fails
  109969. * @returns The loaded asset container
  109970. */
  109971. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109972. }
  109973. /**
  109974. * Interface used to define an async SceneLoader plugin
  109975. */
  109976. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109977. /**
  109978. * Import meshes into a scene.
  109979. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109980. * @param scene The scene to import into
  109981. * @param data The data to import
  109982. * @param rootUrl The root url for scene and resources
  109983. * @param onProgress The callback when the load progresses
  109984. * @param fileName Defines the name of the file to load
  109985. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109986. */
  109987. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109988. meshes: AbstractMesh[];
  109989. particleSystems: IParticleSystem[];
  109990. skeletons: Skeleton[];
  109991. animationGroups: AnimationGroup[];
  109992. }>;
  109993. /**
  109994. * Load into a scene.
  109995. * @param scene The scene to load into
  109996. * @param data The data to import
  109997. * @param rootUrl The root url for scene and resources
  109998. * @param onProgress The callback when the load progresses
  109999. * @param fileName Defines the name of the file to load
  110000. * @returns Nothing
  110001. */
  110002. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110003. /**
  110004. * Load into an asset container.
  110005. * @param scene The scene to load into
  110006. * @param data The data to import
  110007. * @param rootUrl The root url for scene and resources
  110008. * @param onProgress The callback when the load progresses
  110009. * @param fileName Defines the name of the file to load
  110010. * @returns The loaded asset container
  110011. */
  110012. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110013. }
  110014. /**
  110015. * Class used to load scene from various file formats using registered plugins
  110016. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110017. */
  110018. export class SceneLoader {
  110019. /**
  110020. * No logging while loading
  110021. */
  110022. static readonly NO_LOGGING: number;
  110023. /**
  110024. * Minimal logging while loading
  110025. */
  110026. static readonly MINIMAL_LOGGING: number;
  110027. /**
  110028. * Summary logging while loading
  110029. */
  110030. static readonly SUMMARY_LOGGING: number;
  110031. /**
  110032. * Detailled logging while loading
  110033. */
  110034. static readonly DETAILED_LOGGING: number;
  110035. /**
  110036. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110037. */
  110038. static ForceFullSceneLoadingForIncremental: boolean;
  110039. /**
  110040. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110041. */
  110042. static ShowLoadingScreen: boolean;
  110043. /**
  110044. * Defines the current logging level (while loading the scene)
  110045. * @ignorenaming
  110046. */
  110047. static loggingLevel: number;
  110048. /**
  110049. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110050. */
  110051. static CleanBoneMatrixWeights: boolean;
  110052. /**
  110053. * Event raised when a plugin is used to load a scene
  110054. */
  110055. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110056. private static _registeredPlugins;
  110057. private static _getDefaultPlugin;
  110058. private static _getPluginForExtension;
  110059. private static _getPluginForDirectLoad;
  110060. private static _getPluginForFilename;
  110061. private static _getDirectLoad;
  110062. private static _loadData;
  110063. private static _getFileInfo;
  110064. /**
  110065. * Gets a plugin that can load the given extension
  110066. * @param extension defines the extension to load
  110067. * @returns a plugin or null if none works
  110068. */
  110069. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110070. /**
  110071. * Gets a boolean indicating that the given extension can be loaded
  110072. * @param extension defines the extension to load
  110073. * @returns true if the extension is supported
  110074. */
  110075. static IsPluginForExtensionAvailable(extension: string): boolean;
  110076. /**
  110077. * Adds a new plugin to the list of registered plugins
  110078. * @param plugin defines the plugin to add
  110079. */
  110080. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110081. /**
  110082. * Import meshes into a scene
  110083. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110084. * @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)
  110085. * @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)
  110086. * @param scene the instance of BABYLON.Scene to append to
  110087. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110088. * @param onProgress a callback with a progress event for each file being loaded
  110089. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110090. * @param pluginExtension the extension used to determine the plugin
  110091. * @returns The loaded plugin
  110092. */
  110093. 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>;
  110094. /**
  110095. * Import meshes into a scene
  110096. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110097. * @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)
  110098. * @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)
  110099. * @param scene the instance of BABYLON.Scene to append to
  110100. * @param onProgress a callback with a progress event for each file being loaded
  110101. * @param pluginExtension the extension used to determine the plugin
  110102. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110103. */
  110104. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110105. meshes: AbstractMesh[];
  110106. particleSystems: IParticleSystem[];
  110107. skeletons: Skeleton[];
  110108. animationGroups: AnimationGroup[];
  110109. }>;
  110110. /**
  110111. * Load a scene
  110112. * @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)
  110113. * @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)
  110114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110115. * @param onSuccess a callback with the scene when import succeeds
  110116. * @param onProgress a callback with a progress event for each file being loaded
  110117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110118. * @param pluginExtension the extension used to determine the plugin
  110119. * @returns The loaded plugin
  110120. */
  110121. 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>;
  110122. /**
  110123. * Load a scene
  110124. * @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)
  110125. * @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)
  110126. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110127. * @param onProgress a callback with a progress event for each file being loaded
  110128. * @param pluginExtension the extension used to determine the plugin
  110129. * @returns The loaded scene
  110130. */
  110131. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110132. /**
  110133. * Append a scene
  110134. * @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)
  110135. * @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)
  110136. * @param scene is the instance of BABYLON.Scene to append to
  110137. * @param onSuccess a callback with the scene when import succeeds
  110138. * @param onProgress a callback with a progress event for each file being loaded
  110139. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110140. * @param pluginExtension the extension used to determine the plugin
  110141. * @returns The loaded plugin
  110142. */
  110143. 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>;
  110144. /**
  110145. * Append a scene
  110146. * @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)
  110147. * @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)
  110148. * @param scene is the instance of BABYLON.Scene to append to
  110149. * @param onProgress a callback with a progress event for each file being loaded
  110150. * @param pluginExtension the extension used to determine the plugin
  110151. * @returns The given scene
  110152. */
  110153. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110154. /**
  110155. * Load a scene into an asset container
  110156. * @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)
  110157. * @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)
  110158. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110159. * @param onSuccess a callback with the scene when import succeeds
  110160. * @param onProgress a callback with a progress event for each file being loaded
  110161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110162. * @param pluginExtension the extension used to determine the plugin
  110163. * @returns The loaded plugin
  110164. */
  110165. 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>;
  110166. /**
  110167. * Load a scene into an asset container
  110168. * @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)
  110169. * @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)
  110170. * @param scene is the instance of Scene to append to
  110171. * @param onProgress a callback with a progress event for each file being loaded
  110172. * @param pluginExtension the extension used to determine the plugin
  110173. * @returns The loaded asset container
  110174. */
  110175. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110176. }
  110177. }
  110178. declare module BABYLON {
  110179. /**
  110180. * Generic Controller
  110181. */
  110182. export class GenericController extends WebVRController {
  110183. /**
  110184. * Base Url for the controller model.
  110185. */
  110186. static readonly MODEL_BASE_URL: string;
  110187. /**
  110188. * File name for the controller model.
  110189. */
  110190. static readonly MODEL_FILENAME: string;
  110191. /**
  110192. * Creates a new GenericController from a gamepad
  110193. * @param vrGamepad the gamepad that the controller should be created from
  110194. */
  110195. constructor(vrGamepad: any);
  110196. /**
  110197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110198. * @param scene scene in which to add meshes
  110199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110200. */
  110201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110202. /**
  110203. * Called once for each button that changed state since the last frame
  110204. * @param buttonIdx Which button index changed
  110205. * @param state New state of the button
  110206. * @param changes Which properties on the state changed since last frame
  110207. */
  110208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110209. }
  110210. }
  110211. declare module BABYLON {
  110212. /**
  110213. * Defines the WindowsMotionController object that the state of the windows motion controller
  110214. */
  110215. export class WindowsMotionController extends WebVRController {
  110216. /**
  110217. * The base url used to load the left and right controller models
  110218. */
  110219. static MODEL_BASE_URL: string;
  110220. /**
  110221. * The name of the left controller model file
  110222. */
  110223. static MODEL_LEFT_FILENAME: string;
  110224. /**
  110225. * The name of the right controller model file
  110226. */
  110227. static MODEL_RIGHT_FILENAME: string;
  110228. /**
  110229. * The controller name prefix for this controller type
  110230. */
  110231. static readonly GAMEPAD_ID_PREFIX: string;
  110232. /**
  110233. * The controller id pattern for this controller type
  110234. */
  110235. private static readonly GAMEPAD_ID_PATTERN;
  110236. private _loadedMeshInfo;
  110237. private readonly _mapping;
  110238. /**
  110239. * Fired when the trackpad on this controller is clicked
  110240. */
  110241. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110242. /**
  110243. * Fired when the trackpad on this controller is modified
  110244. */
  110245. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110246. /**
  110247. * The current x and y values of this controller's trackpad
  110248. */
  110249. trackpad: StickValues;
  110250. /**
  110251. * Creates a new WindowsMotionController from a gamepad
  110252. * @param vrGamepad the gamepad that the controller should be created from
  110253. */
  110254. constructor(vrGamepad: any);
  110255. /**
  110256. * Fired when the trigger on this controller is modified
  110257. */
  110258. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110259. /**
  110260. * Fired when the menu button on this controller is modified
  110261. */
  110262. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110263. /**
  110264. * Fired when the grip button on this controller is modified
  110265. */
  110266. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110267. /**
  110268. * Fired when the thumbstick button on this controller is modified
  110269. */
  110270. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110271. /**
  110272. * Fired when the touchpad button on this controller is modified
  110273. */
  110274. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110275. /**
  110276. * Fired when the touchpad values on this controller are modified
  110277. */
  110278. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110279. private _updateTrackpad;
  110280. /**
  110281. * Called once per frame by the engine.
  110282. */
  110283. update(): void;
  110284. /**
  110285. * Called once for each button that changed state since the last frame
  110286. * @param buttonIdx Which button index changed
  110287. * @param state New state of the button
  110288. * @param changes Which properties on the state changed since last frame
  110289. */
  110290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110291. /**
  110292. * Moves the buttons on the controller mesh based on their current state
  110293. * @param buttonName the name of the button to move
  110294. * @param buttonValue the value of the button which determines the buttons new position
  110295. */
  110296. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110297. /**
  110298. * Moves the axis on the controller mesh based on its current state
  110299. * @param axis the index of the axis
  110300. * @param axisValue the value of the axis which determines the meshes new position
  110301. * @hidden
  110302. */
  110303. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110304. /**
  110305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110306. * @param scene scene in which to add meshes
  110307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110308. */
  110309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110310. /**
  110311. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110312. * can be transformed by button presses and axes values, based on this._mapping.
  110313. *
  110314. * @param scene scene in which the meshes exist
  110315. * @param meshes list of meshes that make up the controller model to process
  110316. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110317. */
  110318. private processModel;
  110319. private createMeshInfo;
  110320. /**
  110321. * Gets the ray of the controller in the direction the controller is pointing
  110322. * @param length the length the resulting ray should be
  110323. * @returns a ray in the direction the controller is pointing
  110324. */
  110325. getForwardRay(length?: number): Ray;
  110326. /**
  110327. * Disposes of the controller
  110328. */
  110329. dispose(): void;
  110330. }
  110331. }
  110332. declare module BABYLON {
  110333. /**
  110334. * Oculus Touch Controller
  110335. */
  110336. export class OculusTouchController extends WebVRController {
  110337. /**
  110338. * Base Url for the controller model.
  110339. */
  110340. static MODEL_BASE_URL: string;
  110341. /**
  110342. * File name for the left controller model.
  110343. */
  110344. static MODEL_LEFT_FILENAME: string;
  110345. /**
  110346. * File name for the right controller model.
  110347. */
  110348. static MODEL_RIGHT_FILENAME: string;
  110349. /**
  110350. * Base Url for the Quest controller model.
  110351. */
  110352. static QUEST_MODEL_BASE_URL: string;
  110353. /**
  110354. * @hidden
  110355. * If the controllers are running on a device that needs the updated Quest controller models
  110356. */
  110357. static _IsQuest: boolean;
  110358. /**
  110359. * Fired when the secondary trigger on this controller is modified
  110360. */
  110361. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110362. /**
  110363. * Fired when the thumb rest on this controller is modified
  110364. */
  110365. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110366. /**
  110367. * Creates a new OculusTouchController from a gamepad
  110368. * @param vrGamepad the gamepad that the controller should be created from
  110369. */
  110370. constructor(vrGamepad: any);
  110371. /**
  110372. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110373. * @param scene scene in which to add meshes
  110374. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110375. */
  110376. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110377. /**
  110378. * Fired when the A button on this controller is modified
  110379. */
  110380. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110381. /**
  110382. * Fired when the B button on this controller is modified
  110383. */
  110384. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110385. /**
  110386. * Fired when the X button on this controller is modified
  110387. */
  110388. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110389. /**
  110390. * Fired when the Y button on this controller is modified
  110391. */
  110392. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110393. /**
  110394. * Called once for each button that changed state since the last frame
  110395. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110396. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110397. * 2) secondary trigger (same)
  110398. * 3) A (right) X (left), touch, pressed = value
  110399. * 4) B / Y
  110400. * 5) thumb rest
  110401. * @param buttonIdx Which button index changed
  110402. * @param state New state of the button
  110403. * @param changes Which properties on the state changed since last frame
  110404. */
  110405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110406. }
  110407. }
  110408. declare module BABYLON {
  110409. /**
  110410. * Vive Controller
  110411. */
  110412. export class ViveController extends WebVRController {
  110413. /**
  110414. * Base Url for the controller model.
  110415. */
  110416. static MODEL_BASE_URL: string;
  110417. /**
  110418. * File name for the controller model.
  110419. */
  110420. static MODEL_FILENAME: string;
  110421. /**
  110422. * Creates a new ViveController from a gamepad
  110423. * @param vrGamepad the gamepad that the controller should be created from
  110424. */
  110425. constructor(vrGamepad: any);
  110426. /**
  110427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110428. * @param scene scene in which to add meshes
  110429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110430. */
  110431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110432. /**
  110433. * Fired when the left button on this controller is modified
  110434. */
  110435. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110436. /**
  110437. * Fired when the right button on this controller is modified
  110438. */
  110439. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110440. /**
  110441. * Fired when the menu button on this controller is modified
  110442. */
  110443. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110444. /**
  110445. * Called once for each button that changed state since the last frame
  110446. * Vive mapping:
  110447. * 0: touchpad
  110448. * 1: trigger
  110449. * 2: left AND right buttons
  110450. * 3: menu button
  110451. * @param buttonIdx Which button index changed
  110452. * @param state New state of the button
  110453. * @param changes Which properties on the state changed since last frame
  110454. */
  110455. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110456. }
  110457. }
  110458. declare module BABYLON {
  110459. /**
  110460. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110461. */
  110462. export class WebXRControllerModelLoader {
  110463. /**
  110464. * Creates the WebXRControllerModelLoader
  110465. * @param input xr input that creates the controllers
  110466. */
  110467. constructor(input: WebXRInput);
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /**
  110472. * Contains an array of blocks representing the octree
  110473. */
  110474. export interface IOctreeContainer<T> {
  110475. /**
  110476. * Blocks within the octree
  110477. */
  110478. blocks: Array<OctreeBlock<T>>;
  110479. }
  110480. /**
  110481. * Class used to store a cell in an octree
  110482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110483. */
  110484. export class OctreeBlock<T> {
  110485. /**
  110486. * Gets the content of the current block
  110487. */
  110488. entries: T[];
  110489. /**
  110490. * Gets the list of block children
  110491. */
  110492. blocks: Array<OctreeBlock<T>>;
  110493. private _depth;
  110494. private _maxDepth;
  110495. private _capacity;
  110496. private _minPoint;
  110497. private _maxPoint;
  110498. private _boundingVectors;
  110499. private _creationFunc;
  110500. /**
  110501. * Creates a new block
  110502. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110503. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110504. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110505. * @param depth defines the current depth of this block in the octree
  110506. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110507. * @param creationFunc defines a callback to call when an element is added to the block
  110508. */
  110509. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110510. /**
  110511. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110512. */
  110513. readonly capacity: number;
  110514. /**
  110515. * Gets the minimum vector (in world space) of the block's bounding box
  110516. */
  110517. readonly minPoint: Vector3;
  110518. /**
  110519. * Gets the maximum vector (in world space) of the block's bounding box
  110520. */
  110521. readonly maxPoint: Vector3;
  110522. /**
  110523. * Add a new element to this block
  110524. * @param entry defines the element to add
  110525. */
  110526. addEntry(entry: T): void;
  110527. /**
  110528. * Remove an element from this block
  110529. * @param entry defines the element to remove
  110530. */
  110531. removeEntry(entry: T): void;
  110532. /**
  110533. * Add an array of elements to this block
  110534. * @param entries defines the array of elements to add
  110535. */
  110536. addEntries(entries: T[]): void;
  110537. /**
  110538. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110539. * @param frustumPlanes defines the frustum planes to test
  110540. * @param selection defines the array to store current content if selection is positive
  110541. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110542. */
  110543. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110544. /**
  110545. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110546. * @param sphereCenter defines the bounding sphere center
  110547. * @param sphereRadius defines the bounding sphere radius
  110548. * @param selection defines the array to store current content if selection is positive
  110549. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110550. */
  110551. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110552. /**
  110553. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110554. * @param ray defines the ray to test with
  110555. * @param selection defines the array to store current content if selection is positive
  110556. */
  110557. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110558. /**
  110559. * Subdivide the content into child blocks (this block will then be empty)
  110560. */
  110561. createInnerBlocks(): void;
  110562. /**
  110563. * @hidden
  110564. */
  110565. 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;
  110566. }
  110567. }
  110568. declare module BABYLON {
  110569. /**
  110570. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110572. */
  110573. export class Octree<T> {
  110574. /** 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.) */
  110575. maxDepth: number;
  110576. /**
  110577. * Blocks within the octree containing objects
  110578. */
  110579. blocks: Array<OctreeBlock<T>>;
  110580. /**
  110581. * Content stored in the octree
  110582. */
  110583. dynamicContent: T[];
  110584. private _maxBlockCapacity;
  110585. private _selectionContent;
  110586. private _creationFunc;
  110587. /**
  110588. * Creates a octree
  110589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110590. * @param creationFunc function to be used to instatiate the octree
  110591. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110592. * @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.)
  110593. */
  110594. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110595. /** 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.) */
  110596. maxDepth?: number);
  110597. /**
  110598. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110599. * @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);
  110600. * @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);
  110601. * @param entries meshes to be added to the octree blocks
  110602. */
  110603. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110604. /**
  110605. * Adds a mesh to the octree
  110606. * @param entry Mesh to add to the octree
  110607. */
  110608. addMesh(entry: T): void;
  110609. /**
  110610. * Remove an element from the octree
  110611. * @param entry defines the element to remove
  110612. */
  110613. removeMesh(entry: T): void;
  110614. /**
  110615. * Selects an array of meshes within the frustum
  110616. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110617. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110618. * @returns array of meshes within the frustum
  110619. */
  110620. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110621. /**
  110622. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110623. * @param sphereCenter defines the bounding sphere center
  110624. * @param sphereRadius defines the bounding sphere radius
  110625. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110626. * @returns an array of objects that intersect the sphere
  110627. */
  110628. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110629. /**
  110630. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110631. * @param ray defines the ray to test with
  110632. * @returns array of intersected objects
  110633. */
  110634. intersectsRay(ray: Ray): SmartArray<T>;
  110635. /**
  110636. * Adds a mesh into the octree block if it intersects the block
  110637. */
  110638. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110639. /**
  110640. * Adds a submesh into the octree block if it intersects the block
  110641. */
  110642. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110643. }
  110644. }
  110645. declare module BABYLON {
  110646. interface Scene {
  110647. /**
  110648. * @hidden
  110649. * Backing Filed
  110650. */
  110651. _selectionOctree: Octree<AbstractMesh>;
  110652. /**
  110653. * Gets the octree used to boost mesh selection (picking)
  110654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110655. */
  110656. selectionOctree: Octree<AbstractMesh>;
  110657. /**
  110658. * Creates or updates the octree used to boost selection (picking)
  110659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110660. * @param maxCapacity defines the maximum capacity per leaf
  110661. * @param maxDepth defines the maximum depth of the octree
  110662. * @returns an octree of AbstractMesh
  110663. */
  110664. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110665. }
  110666. interface AbstractMesh {
  110667. /**
  110668. * @hidden
  110669. * Backing Field
  110670. */
  110671. _submeshesOctree: Octree<SubMesh>;
  110672. /**
  110673. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110674. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110675. * @param maxCapacity defines the maximum size of each block (64 by default)
  110676. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110677. * @returns the new octree
  110678. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110680. */
  110681. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110682. }
  110683. /**
  110684. * Defines the octree scene component responsible to manage any octrees
  110685. * in a given scene.
  110686. */
  110687. export class OctreeSceneComponent {
  110688. /**
  110689. * The component name help to identify the component in the list of scene components.
  110690. */
  110691. readonly name: string;
  110692. /**
  110693. * The scene the component belongs to.
  110694. */
  110695. scene: Scene;
  110696. /**
  110697. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110698. */
  110699. readonly checksIsEnabled: boolean;
  110700. /**
  110701. * Creates a new instance of the component for the given scene
  110702. * @param scene Defines the scene to register the component in
  110703. */
  110704. constructor(scene: Scene);
  110705. /**
  110706. * Registers the component in a given scene
  110707. */
  110708. register(): void;
  110709. /**
  110710. * Return the list of active meshes
  110711. * @returns the list of active meshes
  110712. */
  110713. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110714. /**
  110715. * Return the list of active sub meshes
  110716. * @param mesh The mesh to get the candidates sub meshes from
  110717. * @returns the list of active sub meshes
  110718. */
  110719. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110720. private _tempRay;
  110721. /**
  110722. * Return the list of sub meshes intersecting with a given local ray
  110723. * @param mesh defines the mesh to find the submesh for
  110724. * @param localRay defines the ray in local space
  110725. * @returns the list of intersecting sub meshes
  110726. */
  110727. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110728. /**
  110729. * Return the list of sub meshes colliding with a collider
  110730. * @param mesh defines the mesh to find the submesh for
  110731. * @param collider defines the collider to evaluate the collision against
  110732. * @returns the list of colliding sub meshes
  110733. */
  110734. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110735. /**
  110736. * Rebuilds the elements related to this component in case of
  110737. * context lost for instance.
  110738. */
  110739. rebuild(): void;
  110740. /**
  110741. * Disposes the component and the associated ressources.
  110742. */
  110743. dispose(): void;
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. /**
  110748. * Renders a layer on top of an existing scene
  110749. */
  110750. export class UtilityLayerRenderer implements IDisposable {
  110751. /** the original scene that will be rendered on top of */
  110752. originalScene: Scene;
  110753. private _pointerCaptures;
  110754. private _lastPointerEvents;
  110755. private static _DefaultUtilityLayer;
  110756. private static _DefaultKeepDepthUtilityLayer;
  110757. private _sharedGizmoLight;
  110758. private _renderCamera;
  110759. /**
  110760. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110761. * @returns the camera that is used when rendering the utility layer
  110762. */
  110763. getRenderCamera(): Nullable<Camera>;
  110764. /**
  110765. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110766. * @param cam the camera that should be used when rendering the utility layer
  110767. */
  110768. setRenderCamera(cam: Nullable<Camera>): void;
  110769. /**
  110770. * @hidden
  110771. * Light which used by gizmos to get light shading
  110772. */
  110773. _getSharedGizmoLight(): HemisphericLight;
  110774. /**
  110775. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110776. */
  110777. pickUtilitySceneFirst: boolean;
  110778. /**
  110779. * 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)
  110780. */
  110781. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110782. /**
  110783. * 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)
  110784. */
  110785. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110786. /**
  110787. * The scene that is rendered on top of the original scene
  110788. */
  110789. utilityLayerScene: Scene;
  110790. /**
  110791. * If the utility layer should automatically be rendered on top of existing scene
  110792. */
  110793. shouldRender: boolean;
  110794. /**
  110795. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110796. */
  110797. onlyCheckPointerDownEvents: boolean;
  110798. /**
  110799. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110800. */
  110801. processAllEvents: boolean;
  110802. /**
  110803. * Observable raised when the pointer move from the utility layer scene to the main scene
  110804. */
  110805. onPointerOutObservable: Observable<number>;
  110806. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110807. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110808. private _afterRenderObserver;
  110809. private _sceneDisposeObserver;
  110810. private _originalPointerObserver;
  110811. /**
  110812. * Instantiates a UtilityLayerRenderer
  110813. * @param originalScene the original scene that will be rendered on top of
  110814. * @param handleEvents boolean indicating if the utility layer should handle events
  110815. */
  110816. constructor(
  110817. /** the original scene that will be rendered on top of */
  110818. originalScene: Scene, handleEvents?: boolean);
  110819. private _notifyObservers;
  110820. /**
  110821. * Renders the utility layers scene on top of the original scene
  110822. */
  110823. render(): void;
  110824. /**
  110825. * Disposes of the renderer
  110826. */
  110827. dispose(): void;
  110828. private _updateCamera;
  110829. }
  110830. }
  110831. declare module BABYLON {
  110832. /**
  110833. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110834. */
  110835. export class Gizmo implements IDisposable {
  110836. /** The utility layer the gizmo will be added to */
  110837. gizmoLayer: UtilityLayerRenderer;
  110838. /**
  110839. * The root mesh of the gizmo
  110840. */
  110841. _rootMesh: Mesh;
  110842. private _attachedMesh;
  110843. /**
  110844. * Ratio for the scale of the gizmo (Default: 1)
  110845. */
  110846. scaleRatio: number;
  110847. /**
  110848. * If a custom mesh has been set (Default: false)
  110849. */
  110850. protected _customMeshSet: boolean;
  110851. /**
  110852. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110853. * * When set, interactions will be enabled
  110854. */
  110855. attachedMesh: Nullable<AbstractMesh>;
  110856. /**
  110857. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110858. * @param mesh The mesh to replace the default mesh of the gizmo
  110859. */
  110860. setCustomMesh(mesh: Mesh): void;
  110861. /**
  110862. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110863. */
  110864. updateGizmoRotationToMatchAttachedMesh: boolean;
  110865. /**
  110866. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110867. */
  110868. updateGizmoPositionToMatchAttachedMesh: boolean;
  110869. /**
  110870. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110871. */
  110872. updateScale: boolean;
  110873. protected _interactionsEnabled: boolean;
  110874. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110875. private _beforeRenderObserver;
  110876. private _tempVector;
  110877. /**
  110878. * Creates a gizmo
  110879. * @param gizmoLayer The utility layer the gizmo will be added to
  110880. */
  110881. constructor(
  110882. /** The utility layer the gizmo will be added to */
  110883. gizmoLayer?: UtilityLayerRenderer);
  110884. /**
  110885. * Updates the gizmo to match the attached mesh's position/rotation
  110886. */
  110887. protected _update(): void;
  110888. /**
  110889. * Disposes of the gizmo
  110890. */
  110891. dispose(): void;
  110892. }
  110893. }
  110894. declare module BABYLON {
  110895. /**
  110896. * Single plane drag gizmo
  110897. */
  110898. export class PlaneDragGizmo extends Gizmo {
  110899. /**
  110900. * Drag behavior responsible for the gizmos dragging interactions
  110901. */
  110902. dragBehavior: PointerDragBehavior;
  110903. private _pointerObserver;
  110904. /**
  110905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110906. */
  110907. snapDistance: number;
  110908. /**
  110909. * Event that fires each time the gizmo snaps to a new location.
  110910. * * snapDistance is the the change in distance
  110911. */
  110912. onSnapObservable: Observable<{
  110913. snapDistance: number;
  110914. }>;
  110915. private _plane;
  110916. private _coloredMaterial;
  110917. private _hoverMaterial;
  110918. private _isEnabled;
  110919. private _parent;
  110920. /** @hidden */
  110921. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110922. /** @hidden */
  110923. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110924. /**
  110925. * Creates a PlaneDragGizmo
  110926. * @param gizmoLayer The utility layer the gizmo will be added to
  110927. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110928. * @param color The color of the gizmo
  110929. */
  110930. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110932. /**
  110933. * If the gizmo is enabled
  110934. */
  110935. isEnabled: boolean;
  110936. /**
  110937. * Disposes of the gizmo
  110938. */
  110939. dispose(): void;
  110940. }
  110941. }
  110942. declare module BABYLON {
  110943. /**
  110944. * Gizmo that enables dragging a mesh along 3 axis
  110945. */
  110946. export class PositionGizmo extends Gizmo {
  110947. /**
  110948. * Internal gizmo used for interactions on the x axis
  110949. */
  110950. xGizmo: AxisDragGizmo;
  110951. /**
  110952. * Internal gizmo used for interactions on the y axis
  110953. */
  110954. yGizmo: AxisDragGizmo;
  110955. /**
  110956. * Internal gizmo used for interactions on the z axis
  110957. */
  110958. zGizmo: AxisDragGizmo;
  110959. /**
  110960. * Internal gizmo used for interactions on the yz plane
  110961. */
  110962. xPlaneGizmo: PlaneDragGizmo;
  110963. /**
  110964. * Internal gizmo used for interactions on the xz plane
  110965. */
  110966. yPlaneGizmo: PlaneDragGizmo;
  110967. /**
  110968. * Internal gizmo used for interactions on the xy plane
  110969. */
  110970. zPlaneGizmo: PlaneDragGizmo;
  110971. /**
  110972. * private variables
  110973. */
  110974. private _meshAttached;
  110975. private _updateGizmoRotationToMatchAttachedMesh;
  110976. private _snapDistance;
  110977. private _scaleRatio;
  110978. /** Fires an event when any of it's sub gizmos are dragged */
  110979. onDragStartObservable: Observable<unknown>;
  110980. /** Fires an event when any of it's sub gizmos are released from dragging */
  110981. onDragEndObservable: Observable<unknown>;
  110982. /**
  110983. * If set to true, planar drag is enabled
  110984. */
  110985. private _planarGizmoEnabled;
  110986. attachedMesh: Nullable<AbstractMesh>;
  110987. /**
  110988. * Creates a PositionGizmo
  110989. * @param gizmoLayer The utility layer the gizmo will be added to
  110990. */
  110991. constructor(gizmoLayer?: UtilityLayerRenderer);
  110992. /**
  110993. * If the planar drag gizmo is enabled
  110994. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110995. */
  110996. planarGizmoEnabled: boolean;
  110997. updateGizmoRotationToMatchAttachedMesh: boolean;
  110998. /**
  110999. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111000. */
  111001. snapDistance: number;
  111002. /**
  111003. * Ratio for the scale of the gizmo (Default: 1)
  111004. */
  111005. scaleRatio: number;
  111006. /**
  111007. * Disposes of the gizmo
  111008. */
  111009. dispose(): void;
  111010. /**
  111011. * CustomMeshes are not supported by this gizmo
  111012. * @param mesh The mesh to replace the default mesh of the gizmo
  111013. */
  111014. setCustomMesh(mesh: Mesh): void;
  111015. }
  111016. }
  111017. declare module BABYLON {
  111018. /**
  111019. * Single axis drag gizmo
  111020. */
  111021. export class AxisDragGizmo extends Gizmo {
  111022. /**
  111023. * Drag behavior responsible for the gizmos dragging interactions
  111024. */
  111025. dragBehavior: PointerDragBehavior;
  111026. private _pointerObserver;
  111027. /**
  111028. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111029. */
  111030. snapDistance: number;
  111031. /**
  111032. * Event that fires each time the gizmo snaps to a new location.
  111033. * * snapDistance is the the change in distance
  111034. */
  111035. onSnapObservable: Observable<{
  111036. snapDistance: number;
  111037. }>;
  111038. private _isEnabled;
  111039. private _parent;
  111040. private _arrow;
  111041. private _coloredMaterial;
  111042. private _hoverMaterial;
  111043. /** @hidden */
  111044. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111045. /** @hidden */
  111046. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111047. /**
  111048. * Creates an AxisDragGizmo
  111049. * @param gizmoLayer The utility layer the gizmo will be added to
  111050. * @param dragAxis The axis which the gizmo will be able to drag on
  111051. * @param color The color of the gizmo
  111052. */
  111053. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111055. /**
  111056. * If the gizmo is enabled
  111057. */
  111058. isEnabled: boolean;
  111059. /**
  111060. * Disposes of the gizmo
  111061. */
  111062. dispose(): void;
  111063. }
  111064. }
  111065. declare module BABYLON.Debug {
  111066. /**
  111067. * The Axes viewer will show 3 axes in a specific point in space
  111068. */
  111069. export class AxesViewer {
  111070. private _xAxis;
  111071. private _yAxis;
  111072. private _zAxis;
  111073. private _scaleLinesFactor;
  111074. private _instanced;
  111075. /**
  111076. * Gets the hosting scene
  111077. */
  111078. scene: Scene;
  111079. /**
  111080. * Gets or sets a number used to scale line length
  111081. */
  111082. scaleLines: number;
  111083. /** Gets the node hierarchy used to render x-axis */
  111084. readonly xAxis: TransformNode;
  111085. /** Gets the node hierarchy used to render y-axis */
  111086. readonly yAxis: TransformNode;
  111087. /** Gets the node hierarchy used to render z-axis */
  111088. readonly zAxis: TransformNode;
  111089. /**
  111090. * Creates a new AxesViewer
  111091. * @param scene defines the hosting scene
  111092. * @param scaleLines defines a number used to scale line length (1 by default)
  111093. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111094. * @param xAxis defines the node hierarchy used to render the x-axis
  111095. * @param yAxis defines the node hierarchy used to render the y-axis
  111096. * @param zAxis defines the node hierarchy used to render the z-axis
  111097. */
  111098. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111099. /**
  111100. * Force the viewer to update
  111101. * @param position defines the position of the viewer
  111102. * @param xaxis defines the x axis of the viewer
  111103. * @param yaxis defines the y axis of the viewer
  111104. * @param zaxis defines the z axis of the viewer
  111105. */
  111106. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111107. /**
  111108. * Creates an instance of this axes viewer.
  111109. * @returns a new axes viewer with instanced meshes
  111110. */
  111111. createInstance(): AxesViewer;
  111112. /** Releases resources */
  111113. dispose(): void;
  111114. private static _SetRenderingGroupId;
  111115. }
  111116. }
  111117. declare module BABYLON.Debug {
  111118. /**
  111119. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111120. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111121. */
  111122. export class BoneAxesViewer extends AxesViewer {
  111123. /**
  111124. * Gets or sets the target mesh where to display the axes viewer
  111125. */
  111126. mesh: Nullable<Mesh>;
  111127. /**
  111128. * Gets or sets the target bone where to display the axes viewer
  111129. */
  111130. bone: Nullable<Bone>;
  111131. /** Gets current position */
  111132. pos: Vector3;
  111133. /** Gets direction of X axis */
  111134. xaxis: Vector3;
  111135. /** Gets direction of Y axis */
  111136. yaxis: Vector3;
  111137. /** Gets direction of Z axis */
  111138. zaxis: Vector3;
  111139. /**
  111140. * Creates a new BoneAxesViewer
  111141. * @param scene defines the hosting scene
  111142. * @param bone defines the target bone
  111143. * @param mesh defines the target mesh
  111144. * @param scaleLines defines a scaling factor for line length (1 by default)
  111145. */
  111146. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111147. /**
  111148. * Force the viewer to update
  111149. */
  111150. update(): void;
  111151. /** Releases resources */
  111152. dispose(): void;
  111153. }
  111154. }
  111155. declare module BABYLON {
  111156. /**
  111157. * Interface used to define scene explorer extensibility option
  111158. */
  111159. export interface IExplorerExtensibilityOption {
  111160. /**
  111161. * Define the option label
  111162. */
  111163. label: string;
  111164. /**
  111165. * Defines the action to execute on click
  111166. */
  111167. action: (entity: any) => void;
  111168. }
  111169. /**
  111170. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111171. */
  111172. export interface IExplorerExtensibilityGroup {
  111173. /**
  111174. * Defines a predicate to test if a given type mut be extended
  111175. */
  111176. predicate: (entity: any) => boolean;
  111177. /**
  111178. * Gets the list of options added to a type
  111179. */
  111180. entries: IExplorerExtensibilityOption[];
  111181. }
  111182. /**
  111183. * Interface used to define the options to use to create the Inspector
  111184. */
  111185. export interface IInspectorOptions {
  111186. /**
  111187. * Display in overlay mode (default: false)
  111188. */
  111189. overlay?: boolean;
  111190. /**
  111191. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111192. */
  111193. globalRoot?: HTMLElement;
  111194. /**
  111195. * Display the Scene explorer
  111196. */
  111197. showExplorer?: boolean;
  111198. /**
  111199. * Display the property inspector
  111200. */
  111201. showInspector?: boolean;
  111202. /**
  111203. * Display in embed mode (both panes on the right)
  111204. */
  111205. embedMode?: boolean;
  111206. /**
  111207. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111208. */
  111209. handleResize?: boolean;
  111210. /**
  111211. * Allow the panes to popup (default: true)
  111212. */
  111213. enablePopup?: boolean;
  111214. /**
  111215. * Allow the panes to be closed by users (default: true)
  111216. */
  111217. enableClose?: boolean;
  111218. /**
  111219. * Optional list of extensibility entries
  111220. */
  111221. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111222. /**
  111223. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111224. */
  111225. inspectorURL?: string;
  111226. }
  111227. interface Scene {
  111228. /**
  111229. * @hidden
  111230. * Backing field
  111231. */
  111232. _debugLayer: DebugLayer;
  111233. /**
  111234. * Gets the debug layer (aka Inspector) associated with the scene
  111235. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111236. */
  111237. debugLayer: DebugLayer;
  111238. }
  111239. /**
  111240. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111241. * what is happening in your scene
  111242. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111243. */
  111244. export class DebugLayer {
  111245. /**
  111246. * Define the url to get the inspector script from.
  111247. * By default it uses the babylonjs CDN.
  111248. * @ignoreNaming
  111249. */
  111250. static InspectorURL: string;
  111251. private _scene;
  111252. private BJSINSPECTOR;
  111253. private _onPropertyChangedObservable?;
  111254. /**
  111255. * Observable triggered when a property is changed through the inspector.
  111256. */
  111257. readonly onPropertyChangedObservable: any;
  111258. /**
  111259. * Instantiates a new debug layer.
  111260. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111261. * what is happening in your scene
  111262. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111263. * @param scene Defines the scene to inspect
  111264. */
  111265. constructor(scene: Scene);
  111266. /** Creates the inspector window. */
  111267. private _createInspector;
  111268. /**
  111269. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111270. * @param entity defines the entity to select
  111271. * @param lineContainerTitle defines the specific block to highlight
  111272. */
  111273. select(entity: any, lineContainerTitle?: string): void;
  111274. /** Get the inspector from bundle or global */
  111275. private _getGlobalInspector;
  111276. /**
  111277. * Get if the inspector is visible or not.
  111278. * @returns true if visible otherwise, false
  111279. */
  111280. isVisible(): boolean;
  111281. /**
  111282. * Hide the inspector and close its window.
  111283. */
  111284. hide(): void;
  111285. /**
  111286. * Launch the debugLayer.
  111287. * @param config Define the configuration of the inspector
  111288. * @return a promise fulfilled when the debug layer is visible
  111289. */
  111290. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111291. }
  111292. }
  111293. declare module BABYLON {
  111294. /**
  111295. * Class containing static functions to help procedurally build meshes
  111296. */
  111297. export class BoxBuilder {
  111298. /**
  111299. * Creates a box mesh
  111300. * * The parameter `size` sets the size (float) of each box side (default 1)
  111301. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111302. * * 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)
  111303. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111307. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111308. * @param name defines the name of the mesh
  111309. * @param options defines the options used to create the mesh
  111310. * @param scene defines the hosting scene
  111311. * @returns the box mesh
  111312. */
  111313. static CreateBox(name: string, options: {
  111314. size?: number;
  111315. width?: number;
  111316. height?: number;
  111317. depth?: number;
  111318. faceUV?: Vector4[];
  111319. faceColors?: Color4[];
  111320. sideOrientation?: number;
  111321. frontUVs?: Vector4;
  111322. backUVs?: Vector4;
  111323. wrap?: boolean;
  111324. topBaseAt?: number;
  111325. bottomBaseAt?: number;
  111326. updatable?: boolean;
  111327. }, scene?: Nullable<Scene>): Mesh;
  111328. }
  111329. }
  111330. declare module BABYLON {
  111331. /**
  111332. * Class containing static functions to help procedurally build meshes
  111333. */
  111334. export class SphereBuilder {
  111335. /**
  111336. * Creates a sphere mesh
  111337. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111338. * * 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`)
  111339. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111340. * * 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
  111341. * * 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)
  111342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111345. * @param name defines the name of the mesh
  111346. * @param options defines the options used to create the mesh
  111347. * @param scene defines the hosting scene
  111348. * @returns the sphere mesh
  111349. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111350. */
  111351. static CreateSphere(name: string, options: {
  111352. segments?: number;
  111353. diameter?: number;
  111354. diameterX?: number;
  111355. diameterY?: number;
  111356. diameterZ?: number;
  111357. arc?: number;
  111358. slice?: number;
  111359. sideOrientation?: number;
  111360. frontUVs?: Vector4;
  111361. backUVs?: Vector4;
  111362. updatable?: boolean;
  111363. }, scene?: Nullable<Scene>): Mesh;
  111364. }
  111365. }
  111366. declare module BABYLON.Debug {
  111367. /**
  111368. * Used to show the physics impostor around the specific mesh
  111369. */
  111370. export class PhysicsViewer {
  111371. /** @hidden */
  111372. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111373. /** @hidden */
  111374. protected _meshes: Array<Nullable<AbstractMesh>>;
  111375. /** @hidden */
  111376. protected _scene: Nullable<Scene>;
  111377. /** @hidden */
  111378. protected _numMeshes: number;
  111379. /** @hidden */
  111380. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111381. private _renderFunction;
  111382. private _utilityLayer;
  111383. private _debugBoxMesh;
  111384. private _debugSphereMesh;
  111385. private _debugCylinderMesh;
  111386. private _debugMaterial;
  111387. private _debugMeshMeshes;
  111388. /**
  111389. * Creates a new PhysicsViewer
  111390. * @param scene defines the hosting scene
  111391. */
  111392. constructor(scene: Scene);
  111393. /** @hidden */
  111394. protected _updateDebugMeshes(): void;
  111395. /**
  111396. * Renders a specified physic impostor
  111397. * @param impostor defines the impostor to render
  111398. * @param targetMesh defines the mesh represented by the impostor
  111399. * @returns the new debug mesh used to render the impostor
  111400. */
  111401. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111402. /**
  111403. * Hides a specified physic impostor
  111404. * @param impostor defines the impostor to hide
  111405. */
  111406. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111407. private _getDebugMaterial;
  111408. private _getDebugBoxMesh;
  111409. private _getDebugSphereMesh;
  111410. private _getDebugCylinderMesh;
  111411. private _getDebugMeshMesh;
  111412. private _getDebugMesh;
  111413. /** Releases all resources */
  111414. dispose(): void;
  111415. }
  111416. }
  111417. declare module BABYLON {
  111418. /**
  111419. * Class containing static functions to help procedurally build meshes
  111420. */
  111421. export class LinesBuilder {
  111422. /**
  111423. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111424. * * 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
  111425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111426. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111427. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111428. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111430. * * 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
  111431. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111434. * @param name defines the name of the new line system
  111435. * @param options defines the options used to create the line system
  111436. * @param scene defines the hosting scene
  111437. * @returns a new line system mesh
  111438. */
  111439. static CreateLineSystem(name: string, options: {
  111440. lines: Vector3[][];
  111441. updatable?: boolean;
  111442. instance?: Nullable<LinesMesh>;
  111443. colors?: Nullable<Color4[][]>;
  111444. useVertexAlpha?: boolean;
  111445. }, scene: Nullable<Scene>): LinesMesh;
  111446. /**
  111447. * Creates a line mesh
  111448. * 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
  111449. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111450. * * The parameter `points` is an array successive Vector3
  111451. * * 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
  111452. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111453. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111454. * * When updating an instance, remember that only point positions can change, not the number of points
  111455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111457. * @param name defines the name of the new line system
  111458. * @param options defines the options used to create the line system
  111459. * @param scene defines the hosting scene
  111460. * @returns a new line mesh
  111461. */
  111462. static CreateLines(name: string, options: {
  111463. points: Vector3[];
  111464. updatable?: boolean;
  111465. instance?: Nullable<LinesMesh>;
  111466. colors?: Color4[];
  111467. useVertexAlpha?: boolean;
  111468. }, scene?: Nullable<Scene>): LinesMesh;
  111469. /**
  111470. * Creates a dashed line mesh
  111471. * * 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
  111472. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111473. * * The parameter `points` is an array successive Vector3
  111474. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111475. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111476. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111477. * * 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
  111478. * * When updating an instance, remember that only point positions can change, not the number of points
  111479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111480. * @param name defines the name of the mesh
  111481. * @param options defines the options used to create the mesh
  111482. * @param scene defines the hosting scene
  111483. * @returns the dashed line mesh
  111484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111485. */
  111486. static CreateDashedLines(name: string, options: {
  111487. points: Vector3[];
  111488. dashSize?: number;
  111489. gapSize?: number;
  111490. dashNb?: number;
  111491. updatable?: boolean;
  111492. instance?: LinesMesh;
  111493. }, scene?: Nullable<Scene>): LinesMesh;
  111494. }
  111495. }
  111496. declare module BABYLON {
  111497. /**
  111498. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111499. * in order to better appreciate the issue one might have.
  111500. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111501. */
  111502. export class RayHelper {
  111503. /**
  111504. * Defines the ray we are currently tryin to visualize.
  111505. */
  111506. ray: Nullable<Ray>;
  111507. private _renderPoints;
  111508. private _renderLine;
  111509. private _renderFunction;
  111510. private _scene;
  111511. private _updateToMeshFunction;
  111512. private _attachedToMesh;
  111513. private _meshSpaceDirection;
  111514. private _meshSpaceOrigin;
  111515. /**
  111516. * Helper function to create a colored helper in a scene in one line.
  111517. * @param ray Defines the ray we are currently tryin to visualize
  111518. * @param scene Defines the scene the ray is used in
  111519. * @param color Defines the color we want to see the ray in
  111520. * @returns The newly created ray helper.
  111521. */
  111522. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111523. /**
  111524. * Instantiate a new ray helper.
  111525. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111526. * in order to better appreciate the issue one might have.
  111527. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111528. * @param ray Defines the ray we are currently tryin to visualize
  111529. */
  111530. constructor(ray: Ray);
  111531. /**
  111532. * Shows the ray we are willing to debug.
  111533. * @param scene Defines the scene the ray needs to be rendered in
  111534. * @param color Defines the color the ray needs to be rendered in
  111535. */
  111536. show(scene: Scene, color?: Color3): void;
  111537. /**
  111538. * Hides the ray we are debugging.
  111539. */
  111540. hide(): void;
  111541. private _render;
  111542. /**
  111543. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111544. * @param mesh Defines the mesh we want the helper attached to
  111545. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111546. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111547. * @param length Defines the length of the ray
  111548. */
  111549. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111550. /**
  111551. * Detach the ray helper from the mesh it has previously been attached to.
  111552. */
  111553. detachFromMesh(): void;
  111554. private _updateToMesh;
  111555. /**
  111556. * Dispose the helper and release its associated resources.
  111557. */
  111558. dispose(): void;
  111559. }
  111560. }
  111561. declare module BABYLON.Debug {
  111562. /**
  111563. * Class used to render a debug view of a given skeleton
  111564. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111565. */
  111566. export class SkeletonViewer {
  111567. /** defines the skeleton to render */
  111568. skeleton: Skeleton;
  111569. /** defines the mesh attached to the skeleton */
  111570. mesh: AbstractMesh;
  111571. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111572. autoUpdateBonesMatrices: boolean;
  111573. /** defines the rendering group id to use with the viewer */
  111574. renderingGroupId: number;
  111575. /** Gets or sets the color used to render the skeleton */
  111576. color: Color3;
  111577. private _scene;
  111578. private _debugLines;
  111579. private _debugMesh;
  111580. private _isEnabled;
  111581. private _renderFunction;
  111582. private _utilityLayer;
  111583. /**
  111584. * Returns the mesh used to render the bones
  111585. */
  111586. readonly debugMesh: Nullable<LinesMesh>;
  111587. /**
  111588. * Creates a new SkeletonViewer
  111589. * @param skeleton defines the skeleton to render
  111590. * @param mesh defines the mesh attached to the skeleton
  111591. * @param scene defines the hosting scene
  111592. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111593. * @param renderingGroupId defines the rendering group id to use with the viewer
  111594. */
  111595. constructor(
  111596. /** defines the skeleton to render */
  111597. skeleton: Skeleton,
  111598. /** defines the mesh attached to the skeleton */
  111599. mesh: AbstractMesh, scene: Scene,
  111600. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111601. autoUpdateBonesMatrices?: boolean,
  111602. /** defines the rendering group id to use with the viewer */
  111603. renderingGroupId?: number);
  111604. /** Gets or sets a boolean indicating if the viewer is enabled */
  111605. isEnabled: boolean;
  111606. private _getBonePosition;
  111607. private _getLinesForBonesWithLength;
  111608. private _getLinesForBonesNoLength;
  111609. /** Update the viewer to sync with current skeleton state */
  111610. update(): void;
  111611. /** Release associated resources */
  111612. dispose(): void;
  111613. }
  111614. }
  111615. declare module BABYLON {
  111616. /**
  111617. * Options to create the null engine
  111618. */
  111619. export class NullEngineOptions {
  111620. /**
  111621. * Render width (Default: 512)
  111622. */
  111623. renderWidth: number;
  111624. /**
  111625. * Render height (Default: 256)
  111626. */
  111627. renderHeight: number;
  111628. /**
  111629. * Texture size (Default: 512)
  111630. */
  111631. textureSize: number;
  111632. /**
  111633. * If delta time between frames should be constant
  111634. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111635. */
  111636. deterministicLockstep: boolean;
  111637. /**
  111638. * Maximum about of steps between frames (Default: 4)
  111639. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111640. */
  111641. lockstepMaxSteps: number;
  111642. }
  111643. /**
  111644. * The null engine class provides support for headless version of babylon.js.
  111645. * This can be used in server side scenario or for testing purposes
  111646. */
  111647. export class NullEngine extends Engine {
  111648. private _options;
  111649. /**
  111650. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111652. * @returns true if engine is in deterministic lock step mode
  111653. */
  111654. isDeterministicLockStep(): boolean;
  111655. /**
  111656. * Gets the max steps when engine is running in deterministic lock step
  111657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111658. * @returns the max steps
  111659. */
  111660. getLockstepMaxSteps(): number;
  111661. /**
  111662. * Gets the current hardware scaling level.
  111663. * By default the hardware scaling level is computed from the window device ratio.
  111664. * 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.
  111665. * @returns a number indicating the current hardware scaling level
  111666. */
  111667. getHardwareScalingLevel(): number;
  111668. constructor(options?: NullEngineOptions);
  111669. /**
  111670. * Creates a vertex buffer
  111671. * @param vertices the data for the vertex buffer
  111672. * @returns the new WebGL static buffer
  111673. */
  111674. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111675. /**
  111676. * Creates a new index buffer
  111677. * @param indices defines the content of the index buffer
  111678. * @param updatable defines if the index buffer must be updatable
  111679. * @returns a new webGL buffer
  111680. */
  111681. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111682. /**
  111683. * Clear the current render buffer or the current render target (if any is set up)
  111684. * @param color defines the color to use
  111685. * @param backBuffer defines if the back buffer must be cleared
  111686. * @param depth defines if the depth buffer must be cleared
  111687. * @param stencil defines if the stencil buffer must be cleared
  111688. */
  111689. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111690. /**
  111691. * Gets the current render width
  111692. * @param useScreen defines if screen size must be used (or the current render target if any)
  111693. * @returns a number defining the current render width
  111694. */
  111695. getRenderWidth(useScreen?: boolean): number;
  111696. /**
  111697. * Gets the current render height
  111698. * @param useScreen defines if screen size must be used (or the current render target if any)
  111699. * @returns a number defining the current render height
  111700. */
  111701. getRenderHeight(useScreen?: boolean): number;
  111702. /**
  111703. * Set the WebGL's viewport
  111704. * @param viewport defines the viewport element to be used
  111705. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111706. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111707. */
  111708. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111709. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111710. /**
  111711. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111712. * @param pipelineContext defines the pipeline context to use
  111713. * @param uniformsNames defines the list of uniform names
  111714. * @returns an array of webGL uniform locations
  111715. */
  111716. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111717. /**
  111718. * Gets the lsit of active attributes for a given webGL program
  111719. * @param pipelineContext defines the pipeline context to use
  111720. * @param attributesNames defines the list of attribute names to get
  111721. * @returns an array of indices indicating the offset of each attribute
  111722. */
  111723. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111724. /**
  111725. * Binds an effect to the webGL context
  111726. * @param effect defines the effect to bind
  111727. */
  111728. bindSamplers(effect: Effect): void;
  111729. /**
  111730. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111731. * @param effect defines the effect to activate
  111732. */
  111733. enableEffect(effect: Effect): void;
  111734. /**
  111735. * Set various states to the webGL context
  111736. * @param culling defines backface culling state
  111737. * @param zOffset defines the value to apply to zOffset (0 by default)
  111738. * @param force defines if states must be applied even if cache is up to date
  111739. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111740. */
  111741. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111742. /**
  111743. * Set the value of an uniform to an array of int32
  111744. * @param uniform defines the webGL uniform location where to store the value
  111745. * @param array defines the array of int32 to store
  111746. */
  111747. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111748. /**
  111749. * Set the value of an uniform to an array of int32 (stored as vec2)
  111750. * @param uniform defines the webGL uniform location where to store the value
  111751. * @param array defines the array of int32 to store
  111752. */
  111753. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111754. /**
  111755. * Set the value of an uniform to an array of int32 (stored as vec3)
  111756. * @param uniform defines the webGL uniform location where to store the value
  111757. * @param array defines the array of int32 to store
  111758. */
  111759. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111760. /**
  111761. * Set the value of an uniform to an array of int32 (stored as vec4)
  111762. * @param uniform defines the webGL uniform location where to store the value
  111763. * @param array defines the array of int32 to store
  111764. */
  111765. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111766. /**
  111767. * Set the value of an uniform to an array of float32
  111768. * @param uniform defines the webGL uniform location where to store the value
  111769. * @param array defines the array of float32 to store
  111770. */
  111771. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111772. /**
  111773. * Set the value of an uniform to an array of float32 (stored as vec2)
  111774. * @param uniform defines the webGL uniform location where to store the value
  111775. * @param array defines the array of float32 to store
  111776. */
  111777. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111778. /**
  111779. * Set the value of an uniform to an array of float32 (stored as vec3)
  111780. * @param uniform defines the webGL uniform location where to store the value
  111781. * @param array defines the array of float32 to store
  111782. */
  111783. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111784. /**
  111785. * Set the value of an uniform to an array of float32 (stored as vec4)
  111786. * @param uniform defines the webGL uniform location where to store the value
  111787. * @param array defines the array of float32 to store
  111788. */
  111789. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111790. /**
  111791. * Set the value of an uniform to an array of number
  111792. * @param uniform defines the webGL uniform location where to store the value
  111793. * @param array defines the array of number to store
  111794. */
  111795. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111796. /**
  111797. * Set the value of an uniform to an array of number (stored as vec2)
  111798. * @param uniform defines the webGL uniform location where to store the value
  111799. * @param array defines the array of number to store
  111800. */
  111801. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111802. /**
  111803. * Set the value of an uniform to an array of number (stored as vec3)
  111804. * @param uniform defines the webGL uniform location where to store the value
  111805. * @param array defines the array of number to store
  111806. */
  111807. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111808. /**
  111809. * Set the value of an uniform to an array of number (stored as vec4)
  111810. * @param uniform defines the webGL uniform location where to store the value
  111811. * @param array defines the array of number to store
  111812. */
  111813. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111814. /**
  111815. * Set the value of an uniform to an array of float32 (stored as matrices)
  111816. * @param uniform defines the webGL uniform location where to store the value
  111817. * @param matrices defines the array of float32 to store
  111818. */
  111819. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111820. /**
  111821. * Set the value of an uniform to a matrix (3x3)
  111822. * @param uniform defines the webGL uniform location where to store the value
  111823. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111824. */
  111825. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111826. /**
  111827. * Set the value of an uniform to a matrix (2x2)
  111828. * @param uniform defines the webGL uniform location where to store the value
  111829. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111830. */
  111831. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111832. /**
  111833. * Set the value of an uniform to a number (float)
  111834. * @param uniform defines the webGL uniform location where to store the value
  111835. * @param value defines the float number to store
  111836. */
  111837. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111838. /**
  111839. * Set the value of an uniform to a vec2
  111840. * @param uniform defines the webGL uniform location where to store the value
  111841. * @param x defines the 1st component of the value
  111842. * @param y defines the 2nd component of the value
  111843. */
  111844. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111845. /**
  111846. * Set the value of an uniform to a vec3
  111847. * @param uniform defines the webGL uniform location where to store the value
  111848. * @param x defines the 1st component of the value
  111849. * @param y defines the 2nd component of the value
  111850. * @param z defines the 3rd component of the value
  111851. */
  111852. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111853. /**
  111854. * Set the value of an uniform to a boolean
  111855. * @param uniform defines the webGL uniform location where to store the value
  111856. * @param bool defines the boolean to store
  111857. */
  111858. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111859. /**
  111860. * Set the value of an uniform to a vec4
  111861. * @param uniform defines the webGL uniform location where to store the value
  111862. * @param x defines the 1st component of the value
  111863. * @param y defines the 2nd component of the value
  111864. * @param z defines the 3rd component of the value
  111865. * @param w defines the 4th component of the value
  111866. */
  111867. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111868. /**
  111869. * Sets the current alpha mode
  111870. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111871. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111872. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111873. */
  111874. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111875. /**
  111876. * Bind webGl buffers directly to the webGL context
  111877. * @param vertexBuffers defines the vertex buffer to bind
  111878. * @param indexBuffer defines the index buffer to bind
  111879. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111880. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111881. * @param effect defines the effect associated with the vertex buffer
  111882. */
  111883. bindBuffers(vertexBuffers: {
  111884. [key: string]: VertexBuffer;
  111885. }, indexBuffer: DataBuffer, effect: Effect): void;
  111886. /**
  111887. * Force the entire cache to be cleared
  111888. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111889. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111890. */
  111891. wipeCaches(bruteForce?: boolean): void;
  111892. /**
  111893. * Send a draw order
  111894. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111895. * @param indexStart defines the starting index
  111896. * @param indexCount defines the number of index to draw
  111897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111898. */
  111899. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111900. /**
  111901. * Draw a list of indexed primitives
  111902. * @param fillMode defines the primitive to use
  111903. * @param indexStart defines the starting index
  111904. * @param indexCount defines the number of index to draw
  111905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111906. */
  111907. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111908. /**
  111909. * Draw a list of unindexed primitives
  111910. * @param fillMode defines the primitive to use
  111911. * @param verticesStart defines the index of first vertex to draw
  111912. * @param verticesCount defines the count of vertices to draw
  111913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111914. */
  111915. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111916. /** @hidden */
  111917. _createTexture(): WebGLTexture;
  111918. /** @hidden */
  111919. _releaseTexture(texture: InternalTexture): void;
  111920. /**
  111921. * Usually called from Texture.ts.
  111922. * Passed information to create a WebGLTexture
  111923. * @param urlArg defines a value which contains one of the following:
  111924. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111925. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111926. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111927. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111928. * @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)
  111929. * @param scene needed for loading to the correct scene
  111930. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111931. * @param onLoad optional callback to be called upon successful completion
  111932. * @param onError optional callback to be called upon failure
  111933. * @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
  111934. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111935. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111936. * @param forcedExtension defines the extension to use to pick the right loader
  111937. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111938. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111939. */
  111940. 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;
  111941. /**
  111942. * Creates a new render target texture
  111943. * @param size defines the size of the texture
  111944. * @param options defines the options used to create the texture
  111945. * @returns a new render target texture stored in an InternalTexture
  111946. */
  111947. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111948. /**
  111949. * Update the sampling mode of a given texture
  111950. * @param samplingMode defines the required sampling mode
  111951. * @param texture defines the texture to update
  111952. */
  111953. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111954. /**
  111955. * Binds the frame buffer to the specified texture.
  111956. * @param texture The texture to render to or null for the default canvas
  111957. * @param faceIndex The face of the texture to render to in case of cube texture
  111958. * @param requiredWidth The width of the target to render to
  111959. * @param requiredHeight The height of the target to render to
  111960. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111961. * @param depthStencilTexture The depth stencil texture to use to render
  111962. * @param lodLevel defines le lod level to bind to the frame buffer
  111963. */
  111964. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111965. /**
  111966. * Unbind the current render target texture from the webGL context
  111967. * @param texture defines the render target texture to unbind
  111968. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111969. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111970. */
  111971. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111972. /**
  111973. * Creates a dynamic vertex buffer
  111974. * @param vertices the data for the dynamic vertex buffer
  111975. * @returns the new WebGL dynamic buffer
  111976. */
  111977. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111978. /**
  111979. * Update the content of a dynamic texture
  111980. * @param texture defines the texture to update
  111981. * @param canvas defines the canvas containing the source
  111982. * @param invertY defines if data must be stored with Y axis inverted
  111983. * @param premulAlpha defines if alpha is stored as premultiplied
  111984. * @param format defines the format of the data
  111985. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111986. */
  111987. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111988. /**
  111989. * Gets a boolean indicating if all created effects are ready
  111990. * @returns true if all effects are ready
  111991. */
  111992. areAllEffectsReady(): boolean;
  111993. /**
  111994. * @hidden
  111995. * Get the current error code of the webGL context
  111996. * @returns the error code
  111997. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111998. */
  111999. getError(): number;
  112000. /** @hidden */
  112001. _getUnpackAlignement(): number;
  112002. /** @hidden */
  112003. _unpackFlipY(value: boolean): void;
  112004. /**
  112005. * Update a dynamic index buffer
  112006. * @param indexBuffer defines the target index buffer
  112007. * @param indices defines the data to update
  112008. * @param offset defines the offset in the target index buffer where update should start
  112009. */
  112010. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112011. /**
  112012. * Updates a dynamic vertex buffer.
  112013. * @param vertexBuffer the vertex buffer to update
  112014. * @param vertices the data used to update the vertex buffer
  112015. * @param byteOffset the byte offset of the data (optional)
  112016. * @param byteLength the byte length of the data (optional)
  112017. */
  112018. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112019. /** @hidden */
  112020. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112021. /** @hidden */
  112022. _bindTexture(channel: number, texture: InternalTexture): void;
  112023. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112024. /**
  112025. * 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
  112026. */
  112027. releaseEffects(): void;
  112028. displayLoadingUI(): void;
  112029. hideLoadingUI(): void;
  112030. /** @hidden */
  112031. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112032. /** @hidden */
  112033. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112034. /** @hidden */
  112035. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112036. /** @hidden */
  112037. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112038. }
  112039. }
  112040. declare module BABYLON {
  112041. /** @hidden */
  112042. export class _OcclusionDataStorage {
  112043. /** @hidden */
  112044. occlusionInternalRetryCounter: number;
  112045. /** @hidden */
  112046. isOcclusionQueryInProgress: boolean;
  112047. /** @hidden */
  112048. isOccluded: boolean;
  112049. /** @hidden */
  112050. occlusionRetryCount: number;
  112051. /** @hidden */
  112052. occlusionType: number;
  112053. /** @hidden */
  112054. occlusionQueryAlgorithmType: number;
  112055. }
  112056. interface Engine {
  112057. /**
  112058. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112059. * @return the new query
  112060. */
  112061. createQuery(): WebGLQuery;
  112062. /**
  112063. * Delete and release a webGL query
  112064. * @param query defines the query to delete
  112065. * @return the current engine
  112066. */
  112067. deleteQuery(query: WebGLQuery): Engine;
  112068. /**
  112069. * Check if a given query has resolved and got its value
  112070. * @param query defines the query to check
  112071. * @returns true if the query got its value
  112072. */
  112073. isQueryResultAvailable(query: WebGLQuery): boolean;
  112074. /**
  112075. * Gets the value of a given query
  112076. * @param query defines the query to check
  112077. * @returns the value of the query
  112078. */
  112079. getQueryResult(query: WebGLQuery): number;
  112080. /**
  112081. * Initiates an occlusion query
  112082. * @param algorithmType defines the algorithm to use
  112083. * @param query defines the query to use
  112084. * @returns the current engine
  112085. * @see http://doc.babylonjs.com/features/occlusionquery
  112086. */
  112087. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112088. /**
  112089. * Ends an occlusion query
  112090. * @see http://doc.babylonjs.com/features/occlusionquery
  112091. * @param algorithmType defines the algorithm to use
  112092. * @returns the current engine
  112093. */
  112094. endOcclusionQuery(algorithmType: number): Engine;
  112095. /**
  112096. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112097. * Please note that only one query can be issued at a time
  112098. * @returns a time token used to track the time span
  112099. */
  112100. startTimeQuery(): Nullable<_TimeToken>;
  112101. /**
  112102. * Ends a time query
  112103. * @param token defines the token used to measure the time span
  112104. * @returns the time spent (in ns)
  112105. */
  112106. endTimeQuery(token: _TimeToken): int;
  112107. /** @hidden */
  112108. _currentNonTimestampToken: Nullable<_TimeToken>;
  112109. /** @hidden */
  112110. _createTimeQuery(): WebGLQuery;
  112111. /** @hidden */
  112112. _deleteTimeQuery(query: WebGLQuery): void;
  112113. /** @hidden */
  112114. _getGlAlgorithmType(algorithmType: number): number;
  112115. /** @hidden */
  112116. _getTimeQueryResult(query: WebGLQuery): any;
  112117. /** @hidden */
  112118. _getTimeQueryAvailability(query: WebGLQuery): any;
  112119. }
  112120. interface AbstractMesh {
  112121. /**
  112122. * Backing filed
  112123. * @hidden
  112124. */
  112125. __occlusionDataStorage: _OcclusionDataStorage;
  112126. /**
  112127. * Access property
  112128. * @hidden
  112129. */
  112130. _occlusionDataStorage: _OcclusionDataStorage;
  112131. /**
  112132. * 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.
  112133. * The default value is -1 which means don't break the query and wait till the result
  112134. * @see http://doc.babylonjs.com/features/occlusionquery
  112135. */
  112136. occlusionRetryCount: number;
  112137. /**
  112138. * 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:
  112139. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112140. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112141. * * 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.
  112142. * @see http://doc.babylonjs.com/features/occlusionquery
  112143. */
  112144. occlusionType: number;
  112145. /**
  112146. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112147. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112148. * * 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.
  112149. * @see http://doc.babylonjs.com/features/occlusionquery
  112150. */
  112151. occlusionQueryAlgorithmType: number;
  112152. /**
  112153. * 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
  112154. * @see http://doc.babylonjs.com/features/occlusionquery
  112155. */
  112156. isOccluded: boolean;
  112157. /**
  112158. * Flag to check the progress status of the query
  112159. * @see http://doc.babylonjs.com/features/occlusionquery
  112160. */
  112161. isOcclusionQueryInProgress: boolean;
  112162. }
  112163. }
  112164. declare module BABYLON {
  112165. /** @hidden */
  112166. export var _forceTransformFeedbackToBundle: boolean;
  112167. interface Engine {
  112168. /**
  112169. * Creates a webGL transform feedback object
  112170. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112171. * @returns the webGL transform feedback object
  112172. */
  112173. createTransformFeedback(): WebGLTransformFeedback;
  112174. /**
  112175. * Delete a webGL transform feedback object
  112176. * @param value defines the webGL transform feedback object to delete
  112177. */
  112178. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112179. /**
  112180. * Bind a webGL transform feedback object to the webgl context
  112181. * @param value defines the webGL transform feedback object to bind
  112182. */
  112183. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112184. /**
  112185. * Begins a transform feedback operation
  112186. * @param usePoints defines if points or triangles must be used
  112187. */
  112188. beginTransformFeedback(usePoints: boolean): void;
  112189. /**
  112190. * Ends a transform feedback operation
  112191. */
  112192. endTransformFeedback(): void;
  112193. /**
  112194. * Specify the varyings to use with transform feedback
  112195. * @param program defines the associated webGL program
  112196. * @param value defines the list of strings representing the varying names
  112197. */
  112198. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112199. /**
  112200. * Bind a webGL buffer for a transform feedback operation
  112201. * @param value defines the webGL buffer to bind
  112202. */
  112203. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112204. }
  112205. }
  112206. declare module BABYLON {
  112207. /**
  112208. * Creation options of the multi render target texture.
  112209. */
  112210. export interface IMultiRenderTargetOptions {
  112211. /**
  112212. * Define if the texture needs to create mip maps after render.
  112213. */
  112214. generateMipMaps?: boolean;
  112215. /**
  112216. * Define the types of all the draw buffers we want to create
  112217. */
  112218. types?: number[];
  112219. /**
  112220. * Define the sampling modes of all the draw buffers we want to create
  112221. */
  112222. samplingModes?: number[];
  112223. /**
  112224. * Define if a depth buffer is required
  112225. */
  112226. generateDepthBuffer?: boolean;
  112227. /**
  112228. * Define if a stencil buffer is required
  112229. */
  112230. generateStencilBuffer?: boolean;
  112231. /**
  112232. * Define if a depth texture is required instead of a depth buffer
  112233. */
  112234. generateDepthTexture?: boolean;
  112235. /**
  112236. * Define the number of desired draw buffers
  112237. */
  112238. textureCount?: number;
  112239. /**
  112240. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112241. */
  112242. doNotChangeAspectRatio?: boolean;
  112243. /**
  112244. * Define the default type of the buffers we are creating
  112245. */
  112246. defaultType?: number;
  112247. }
  112248. /**
  112249. * A multi render target, like a render target provides the ability to render to a texture.
  112250. * Unlike the render target, it can render to several draw buffers in one draw.
  112251. * This is specially interesting in deferred rendering or for any effects requiring more than
  112252. * just one color from a single pass.
  112253. */
  112254. export class MultiRenderTarget extends RenderTargetTexture {
  112255. private _internalTextures;
  112256. private _textures;
  112257. private _multiRenderTargetOptions;
  112258. /**
  112259. * Get if draw buffers are currently supported by the used hardware and browser.
  112260. */
  112261. readonly isSupported: boolean;
  112262. /**
  112263. * Get the list of textures generated by the multi render target.
  112264. */
  112265. readonly textures: Texture[];
  112266. /**
  112267. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112268. */
  112269. readonly depthTexture: Texture;
  112270. /**
  112271. * Set the wrapping mode on U of all the textures we are rendering to.
  112272. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112273. */
  112274. wrapU: number;
  112275. /**
  112276. * Set the wrapping mode on V of all the textures we are rendering to.
  112277. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112278. */
  112279. wrapV: number;
  112280. /**
  112281. * Instantiate a new multi render target texture.
  112282. * A multi render target, like a render target provides the ability to render to a texture.
  112283. * Unlike the render target, it can render to several draw buffers in one draw.
  112284. * This is specially interesting in deferred rendering or for any effects requiring more than
  112285. * just one color from a single pass.
  112286. * @param name Define the name of the texture
  112287. * @param size Define the size of the buffers to render to
  112288. * @param count Define the number of target we are rendering into
  112289. * @param scene Define the scene the texture belongs to
  112290. * @param options Define the options used to create the multi render target
  112291. */
  112292. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112293. /** @hidden */
  112294. _rebuild(): void;
  112295. private _createInternalTextures;
  112296. private _createTextures;
  112297. /**
  112298. * Define the number of samples used if MSAA is enabled.
  112299. */
  112300. samples: number;
  112301. /**
  112302. * Resize all the textures in the multi render target.
  112303. * Be carrefull as it will recreate all the data in the new texture.
  112304. * @param size Define the new size
  112305. */
  112306. resize(size: any): void;
  112307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112308. /**
  112309. * Dispose the render targets and their associated resources
  112310. */
  112311. dispose(): void;
  112312. /**
  112313. * Release all the underlying texture used as draw buffers.
  112314. */
  112315. releaseInternalTextures(): void;
  112316. }
  112317. }
  112318. declare module BABYLON {
  112319. interface ThinEngine {
  112320. /**
  112321. * Unbind a list of render target textures from the webGL context
  112322. * This is used only when drawBuffer extension or webGL2 are active
  112323. * @param textures defines the render target textures to unbind
  112324. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112325. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112326. */
  112327. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112328. /**
  112329. * Create a multi render target texture
  112330. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112331. * @param size defines the size of the texture
  112332. * @param options defines the creation options
  112333. * @returns the cube texture as an InternalTexture
  112334. */
  112335. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112336. /**
  112337. * Update the sample count for a given multiple render target texture
  112338. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112339. * @param textures defines the textures to update
  112340. * @param samples defines the sample count to set
  112341. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112342. */
  112343. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112344. }
  112345. }
  112346. declare module BABYLON {
  112347. /**
  112348. * Class used to define an additional view for the engine
  112349. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112350. */
  112351. export class EngineView {
  112352. /** Defines the canvas where to render the view */
  112353. target: HTMLCanvasElement;
  112354. /** Defines an optional camera used to render the view (will use active camera else) */
  112355. camera?: Camera;
  112356. }
  112357. interface Engine {
  112358. /**
  112359. * Gets or sets the HTML element to use for attaching events
  112360. */
  112361. inputElement: Nullable<HTMLElement>;
  112362. /**
  112363. * Gets the current engine view
  112364. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112365. */
  112366. activeView: Nullable<EngineView>;
  112367. /** Gets or sets the list of views */
  112368. views: EngineView[];
  112369. /**
  112370. * Register a new child canvas
  112371. * @param canvas defines the canvas to register
  112372. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112373. * @returns the associated view
  112374. */
  112375. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112376. /**
  112377. * Remove a registered child canvas
  112378. * @param canvas defines the canvas to remove
  112379. * @returns the current engine
  112380. */
  112381. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112382. }
  112383. }
  112384. declare module BABYLON {
  112385. /**
  112386. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112387. */
  112388. export interface CubeMapInfo {
  112389. /**
  112390. * The pixel array for the front face.
  112391. * This is stored in format, left to right, up to down format.
  112392. */
  112393. front: Nullable<ArrayBufferView>;
  112394. /**
  112395. * The pixel array for the back face.
  112396. * This is stored in format, left to right, up to down format.
  112397. */
  112398. back: Nullable<ArrayBufferView>;
  112399. /**
  112400. * The pixel array for the left face.
  112401. * This is stored in format, left to right, up to down format.
  112402. */
  112403. left: Nullable<ArrayBufferView>;
  112404. /**
  112405. * The pixel array for the right face.
  112406. * This is stored in format, left to right, up to down format.
  112407. */
  112408. right: Nullable<ArrayBufferView>;
  112409. /**
  112410. * The pixel array for the up face.
  112411. * This is stored in format, left to right, up to down format.
  112412. */
  112413. up: Nullable<ArrayBufferView>;
  112414. /**
  112415. * The pixel array for the down face.
  112416. * This is stored in format, left to right, up to down format.
  112417. */
  112418. down: Nullable<ArrayBufferView>;
  112419. /**
  112420. * The size of the cubemap stored.
  112421. *
  112422. * Each faces will be size * size pixels.
  112423. */
  112424. size: number;
  112425. /**
  112426. * The format of the texture.
  112427. *
  112428. * RGBA, RGB.
  112429. */
  112430. format: number;
  112431. /**
  112432. * The type of the texture data.
  112433. *
  112434. * UNSIGNED_INT, FLOAT.
  112435. */
  112436. type: number;
  112437. /**
  112438. * Specifies whether the texture is in gamma space.
  112439. */
  112440. gammaSpace: boolean;
  112441. }
  112442. /**
  112443. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112444. */
  112445. export class PanoramaToCubeMapTools {
  112446. private static FACE_FRONT;
  112447. private static FACE_BACK;
  112448. private static FACE_RIGHT;
  112449. private static FACE_LEFT;
  112450. private static FACE_DOWN;
  112451. private static FACE_UP;
  112452. /**
  112453. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112454. *
  112455. * @param float32Array The source data.
  112456. * @param inputWidth The width of the input panorama.
  112457. * @param inputHeight The height of the input panorama.
  112458. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112459. * @return The cubemap data
  112460. */
  112461. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112462. private static CreateCubemapTexture;
  112463. private static CalcProjectionSpherical;
  112464. }
  112465. }
  112466. declare module BABYLON {
  112467. /**
  112468. * Helper class dealing with the extraction of spherical polynomial dataArray
  112469. * from a cube map.
  112470. */
  112471. export class CubeMapToSphericalPolynomialTools {
  112472. private static FileFaces;
  112473. /**
  112474. * Converts a texture to the according Spherical Polynomial data.
  112475. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112476. *
  112477. * @param texture The texture to extract the information from.
  112478. * @return The Spherical Polynomial data.
  112479. */
  112480. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112481. /**
  112482. * Converts a cubemap to the according Spherical Polynomial data.
  112483. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112484. *
  112485. * @param cubeInfo The Cube map to extract the information from.
  112486. * @return The Spherical Polynomial data.
  112487. */
  112488. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112489. }
  112490. }
  112491. declare module BABYLON {
  112492. interface BaseTexture {
  112493. /**
  112494. * Get the polynomial representation of the texture data.
  112495. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112496. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112497. */
  112498. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112499. }
  112500. }
  112501. declare module BABYLON {
  112502. /** @hidden */
  112503. export var rgbdEncodePixelShader: {
  112504. name: string;
  112505. shader: string;
  112506. };
  112507. }
  112508. declare module BABYLON {
  112509. /** @hidden */
  112510. export var rgbdDecodePixelShader: {
  112511. name: string;
  112512. shader: string;
  112513. };
  112514. }
  112515. declare module BABYLON {
  112516. /**
  112517. * Raw texture data and descriptor sufficient for WebGL texture upload
  112518. */
  112519. export interface EnvironmentTextureInfo {
  112520. /**
  112521. * Version of the environment map
  112522. */
  112523. version: number;
  112524. /**
  112525. * Width of image
  112526. */
  112527. width: number;
  112528. /**
  112529. * Irradiance information stored in the file.
  112530. */
  112531. irradiance: any;
  112532. /**
  112533. * Specular information stored in the file.
  112534. */
  112535. specular: any;
  112536. }
  112537. /**
  112538. * Defines One Image in the file. It requires only the position in the file
  112539. * as well as the length.
  112540. */
  112541. interface BufferImageData {
  112542. /**
  112543. * Length of the image data.
  112544. */
  112545. length: number;
  112546. /**
  112547. * Position of the data from the null terminator delimiting the end of the JSON.
  112548. */
  112549. position: number;
  112550. }
  112551. /**
  112552. * Defines the specular data enclosed in the file.
  112553. * This corresponds to the version 1 of the data.
  112554. */
  112555. export interface EnvironmentTextureSpecularInfoV1 {
  112556. /**
  112557. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112558. */
  112559. specularDataPosition?: number;
  112560. /**
  112561. * This contains all the images data needed to reconstruct the cubemap.
  112562. */
  112563. mipmaps: Array<BufferImageData>;
  112564. /**
  112565. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112566. */
  112567. lodGenerationScale: number;
  112568. }
  112569. /**
  112570. * Sets of helpers addressing the serialization and deserialization of environment texture
  112571. * stored in a BabylonJS env file.
  112572. * Those files are usually stored as .env files.
  112573. */
  112574. export class EnvironmentTextureTools {
  112575. /**
  112576. * Magic number identifying the env file.
  112577. */
  112578. private static _MagicBytes;
  112579. /**
  112580. * Gets the environment info from an env file.
  112581. * @param data The array buffer containing the .env bytes.
  112582. * @returns the environment file info (the json header) if successfully parsed.
  112583. */
  112584. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112585. /**
  112586. * Creates an environment texture from a loaded cube texture.
  112587. * @param texture defines the cube texture to convert in env file
  112588. * @return a promise containing the environment data if succesfull.
  112589. */
  112590. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112591. /**
  112592. * Creates a JSON representation of the spherical data.
  112593. * @param texture defines the texture containing the polynomials
  112594. * @return the JSON representation of the spherical info
  112595. */
  112596. private static _CreateEnvTextureIrradiance;
  112597. /**
  112598. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112599. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112600. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112601. * @return the views described by info providing access to the underlying buffer
  112602. */
  112603. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112604. /**
  112605. * Uploads the texture info contained in the env file to the GPU.
  112606. * @param texture defines the internal texture to upload to
  112607. * @param arrayBuffer defines the buffer cotaining the data to load
  112608. * @param info defines the texture info retrieved through the GetEnvInfo method
  112609. * @returns a promise
  112610. */
  112611. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112612. private static _OnImageReadyAsync;
  112613. /**
  112614. * Uploads the levels of image data to the GPU.
  112615. * @param texture defines the internal texture to upload to
  112616. * @param imageData defines the array buffer views of image data [mipmap][face]
  112617. * @returns a promise
  112618. */
  112619. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112620. /**
  112621. * Uploads spherical polynomials information to the texture.
  112622. * @param texture defines the texture we are trying to upload the information to
  112623. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112624. */
  112625. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112626. /** @hidden */
  112627. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112628. }
  112629. }
  112630. declare module BABYLON {
  112631. /**
  112632. * Contains position and normal vectors for a vertex
  112633. */
  112634. export class PositionNormalVertex {
  112635. /** the position of the vertex (defaut: 0,0,0) */
  112636. position: Vector3;
  112637. /** the normal of the vertex (defaut: 0,1,0) */
  112638. normal: Vector3;
  112639. /**
  112640. * Creates a PositionNormalVertex
  112641. * @param position the position of the vertex (defaut: 0,0,0)
  112642. * @param normal the normal of the vertex (defaut: 0,1,0)
  112643. */
  112644. constructor(
  112645. /** the position of the vertex (defaut: 0,0,0) */
  112646. position?: Vector3,
  112647. /** the normal of the vertex (defaut: 0,1,0) */
  112648. normal?: Vector3);
  112649. /**
  112650. * Clones the PositionNormalVertex
  112651. * @returns the cloned PositionNormalVertex
  112652. */
  112653. clone(): PositionNormalVertex;
  112654. }
  112655. /**
  112656. * Contains position, normal and uv vectors for a vertex
  112657. */
  112658. export class PositionNormalTextureVertex {
  112659. /** the position of the vertex (defaut: 0,0,0) */
  112660. position: Vector3;
  112661. /** the normal of the vertex (defaut: 0,1,0) */
  112662. normal: Vector3;
  112663. /** the uv of the vertex (default: 0,0) */
  112664. uv: Vector2;
  112665. /**
  112666. * Creates a PositionNormalTextureVertex
  112667. * @param position the position of the vertex (defaut: 0,0,0)
  112668. * @param normal the normal of the vertex (defaut: 0,1,0)
  112669. * @param uv the uv of the vertex (default: 0,0)
  112670. */
  112671. constructor(
  112672. /** the position of the vertex (defaut: 0,0,0) */
  112673. position?: Vector3,
  112674. /** the normal of the vertex (defaut: 0,1,0) */
  112675. normal?: Vector3,
  112676. /** the uv of the vertex (default: 0,0) */
  112677. uv?: Vector2);
  112678. /**
  112679. * Clones the PositionNormalTextureVertex
  112680. * @returns the cloned PositionNormalTextureVertex
  112681. */
  112682. clone(): PositionNormalTextureVertex;
  112683. }
  112684. }
  112685. declare module BABYLON {
  112686. /** @hidden */
  112687. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112688. private _genericAttributeLocation;
  112689. private _varyingLocationCount;
  112690. private _varyingLocationMap;
  112691. private _replacements;
  112692. private _textureCount;
  112693. private _uniforms;
  112694. lineProcessor(line: string): string;
  112695. attributeProcessor(attribute: string): string;
  112696. varyingProcessor(varying: string, isFragment: boolean): string;
  112697. uniformProcessor(uniform: string): string;
  112698. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112699. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112700. }
  112701. }
  112702. declare module BABYLON {
  112703. /**
  112704. * Container for accessors for natively-stored mesh data buffers.
  112705. */
  112706. class NativeDataBuffer extends DataBuffer {
  112707. /**
  112708. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112709. */
  112710. nativeIndexBuffer?: any;
  112711. /**
  112712. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112713. */
  112714. nativeVertexBuffer?: any;
  112715. }
  112716. /** @hidden */
  112717. class NativeTexture extends InternalTexture {
  112718. getInternalTexture(): InternalTexture;
  112719. getViewCount(): number;
  112720. }
  112721. /** @hidden */
  112722. export class NativeEngine extends Engine {
  112723. private readonly _native;
  112724. getHardwareScalingLevel(): number;
  112725. constructor();
  112726. /**
  112727. * Can be used to override the current requestAnimationFrame requester.
  112728. * @hidden
  112729. */
  112730. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112731. /**
  112732. * Override default engine behavior.
  112733. * @param color
  112734. * @param backBuffer
  112735. * @param depth
  112736. * @param stencil
  112737. */
  112738. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112739. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112740. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112741. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112742. recordVertexArrayObject(vertexBuffers: {
  112743. [key: string]: VertexBuffer;
  112744. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112745. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112746. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112747. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112748. /**
  112749. * Draw a list of indexed primitives
  112750. * @param fillMode defines the primitive to use
  112751. * @param indexStart defines the starting index
  112752. * @param indexCount defines the number of index to draw
  112753. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112754. */
  112755. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112756. /**
  112757. * Draw a list of unindexed primitives
  112758. * @param fillMode defines the primitive to use
  112759. * @param verticesStart defines the index of first vertex to draw
  112760. * @param verticesCount defines the count of vertices to draw
  112761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112762. */
  112763. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112764. createPipelineContext(): IPipelineContext;
  112765. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112766. /** @hidden */
  112767. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112768. /** @hidden */
  112769. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112770. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112771. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112772. protected _setProgram(program: WebGLProgram): void;
  112773. _releaseEffect(effect: Effect): void;
  112774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112775. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112776. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112777. bindSamplers(effect: Effect): void;
  112778. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112779. getRenderWidth(useScreen?: boolean): number;
  112780. getRenderHeight(useScreen?: boolean): number;
  112781. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112782. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112783. /**
  112784. * Set the z offset to apply to current rendering
  112785. * @param value defines the offset to apply
  112786. */
  112787. setZOffset(value: number): void;
  112788. /**
  112789. * Gets the current value of the zOffset
  112790. * @returns the current zOffset state
  112791. */
  112792. getZOffset(): number;
  112793. /**
  112794. * Enable or disable depth buffering
  112795. * @param enable defines the state to set
  112796. */
  112797. setDepthBuffer(enable: boolean): void;
  112798. /**
  112799. * Gets a boolean indicating if depth writing is enabled
  112800. * @returns the current depth writing state
  112801. */
  112802. getDepthWrite(): boolean;
  112803. /**
  112804. * Enable or disable depth writing
  112805. * @param enable defines the state to set
  112806. */
  112807. setDepthWrite(enable: boolean): void;
  112808. /**
  112809. * Enable or disable color writing
  112810. * @param enable defines the state to set
  112811. */
  112812. setColorWrite(enable: boolean): void;
  112813. /**
  112814. * Gets a boolean indicating if color writing is enabled
  112815. * @returns the current color writing state
  112816. */
  112817. getColorWrite(): boolean;
  112818. /**
  112819. * Sets alpha constants used by some alpha blending modes
  112820. * @param r defines the red component
  112821. * @param g defines the green component
  112822. * @param b defines the blue component
  112823. * @param a defines the alpha component
  112824. */
  112825. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112826. /**
  112827. * Sets the current alpha mode
  112828. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112829. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112830. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112831. */
  112832. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112833. /**
  112834. * Gets the current alpha mode
  112835. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112836. * @returns the current alpha mode
  112837. */
  112838. getAlphaMode(): number;
  112839. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112840. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112841. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112842. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112843. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112844. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112845. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112846. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112847. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112848. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112849. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112850. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112851. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112852. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112853. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112854. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112855. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112856. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112857. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112858. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112859. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112860. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112861. wipeCaches(bruteForce?: boolean): void;
  112862. _createTexture(): WebGLTexture;
  112863. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112864. /**
  112865. * Usually called from BABYLON.Texture.ts.
  112866. * Passed information to create a WebGLTexture
  112867. * @param urlArg defines a value which contains one of the following:
  112868. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112869. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112870. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112872. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112873. * @param scene needed for loading to the correct scene
  112874. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112875. * @param onLoad optional callback to be called upon successful completion
  112876. * @param onError optional callback to be called upon failure
  112877. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112878. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112879. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112880. * @param forcedExtension defines the extension to use to pick the right loader
  112881. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112882. */
  112883. 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;
  112884. /**
  112885. * Creates a cube texture
  112886. * @param rootUrl defines the url where the files to load is located
  112887. * @param scene defines the current scene
  112888. * @param files defines the list of files to load (1 per face)
  112889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112890. * @param onLoad defines an optional callback raised when the texture is loaded
  112891. * @param onError defines an optional callback raised if there is an issue to load the texture
  112892. * @param format defines the format of the data
  112893. * @param forcedExtension defines the extension to use to pick the right loader
  112894. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112897. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112898. * @returns the cube texture as an InternalTexture
  112899. */
  112900. 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;
  112901. private _getSamplingFilter;
  112902. private static _GetNativeTextureFormat;
  112903. createRenderTargetTexture(size: number | {
  112904. width: number;
  112905. height: number;
  112906. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  112907. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112909. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112910. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112911. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112912. /**
  112913. * Updates a dynamic vertex buffer.
  112914. * @param vertexBuffer the vertex buffer to update
  112915. * @param data the data used to update the vertex buffer
  112916. * @param byteOffset the byte offset of the data (optional)
  112917. * @param byteLength the byte length of the data (optional)
  112918. */
  112919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112920. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112921. private _updateAnisotropicLevel;
  112922. private _getAddressMode;
  112923. /** @hidden */
  112924. _bindTexture(channel: number, texture: InternalTexture): void;
  112925. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112926. releaseEffects(): void;
  112927. /** @hidden */
  112928. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112929. /** @hidden */
  112930. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112931. /** @hidden */
  112932. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112933. /** @hidden */
  112934. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. /**
  112939. * Gather the list of clipboard event types as constants.
  112940. */
  112941. export class ClipboardEventTypes {
  112942. /**
  112943. * The clipboard event is fired when a copy command is active (pressed).
  112944. */
  112945. static readonly COPY: number;
  112946. /**
  112947. * The clipboard event is fired when a cut command is active (pressed).
  112948. */
  112949. static readonly CUT: number;
  112950. /**
  112951. * The clipboard event is fired when a paste command is active (pressed).
  112952. */
  112953. static readonly PASTE: number;
  112954. }
  112955. /**
  112956. * This class is used to store clipboard related info for the onClipboardObservable event.
  112957. */
  112958. export class ClipboardInfo {
  112959. /**
  112960. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112961. */
  112962. type: number;
  112963. /**
  112964. * Defines the related dom event
  112965. */
  112966. event: ClipboardEvent;
  112967. /**
  112968. *Creates an instance of ClipboardInfo.
  112969. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112970. * @param event Defines the related dom event
  112971. */
  112972. constructor(
  112973. /**
  112974. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112975. */
  112976. type: number,
  112977. /**
  112978. * Defines the related dom event
  112979. */
  112980. event: ClipboardEvent);
  112981. /**
  112982. * Get the clipboard event's type from the keycode.
  112983. * @param keyCode Defines the keyCode for the current keyboard event.
  112984. * @return {number}
  112985. */
  112986. static GetTypeFromCharacter(keyCode: number): number;
  112987. }
  112988. }
  112989. declare module BABYLON {
  112990. /**
  112991. * Google Daydream controller
  112992. */
  112993. export class DaydreamController extends WebVRController {
  112994. /**
  112995. * Base Url for the controller model.
  112996. */
  112997. static MODEL_BASE_URL: string;
  112998. /**
  112999. * File name for the controller model.
  113000. */
  113001. static MODEL_FILENAME: string;
  113002. /**
  113003. * Gamepad Id prefix used to identify Daydream Controller.
  113004. */
  113005. static readonly GAMEPAD_ID_PREFIX: string;
  113006. /**
  113007. * Creates a new DaydreamController from a gamepad
  113008. * @param vrGamepad the gamepad that the controller should be created from
  113009. */
  113010. constructor(vrGamepad: any);
  113011. /**
  113012. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113013. * @param scene scene in which to add meshes
  113014. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113015. */
  113016. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113017. /**
  113018. * Called once for each button that changed state since the last frame
  113019. * @param buttonIdx Which button index changed
  113020. * @param state New state of the button
  113021. * @param changes Which properties on the state changed since last frame
  113022. */
  113023. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113024. }
  113025. }
  113026. declare module BABYLON {
  113027. /**
  113028. * Gear VR Controller
  113029. */
  113030. export class GearVRController extends WebVRController {
  113031. /**
  113032. * Base Url for the controller model.
  113033. */
  113034. static MODEL_BASE_URL: string;
  113035. /**
  113036. * File name for the controller model.
  113037. */
  113038. static MODEL_FILENAME: string;
  113039. /**
  113040. * Gamepad Id prefix used to identify this controller.
  113041. */
  113042. static readonly GAMEPAD_ID_PREFIX: string;
  113043. private readonly _buttonIndexToObservableNameMap;
  113044. /**
  113045. * Creates a new GearVRController from a gamepad
  113046. * @param vrGamepad the gamepad that the controller should be created from
  113047. */
  113048. constructor(vrGamepad: any);
  113049. /**
  113050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113051. * @param scene scene in which to add meshes
  113052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113053. */
  113054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113055. /**
  113056. * Called once for each button that changed state since the last frame
  113057. * @param buttonIdx Which button index changed
  113058. * @param state New state of the button
  113059. * @param changes Which properties on the state changed since last frame
  113060. */
  113061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113062. }
  113063. }
  113064. declare module BABYLON {
  113065. /**
  113066. * Class containing static functions to help procedurally build meshes
  113067. */
  113068. export class PolyhedronBuilder {
  113069. /**
  113070. * Creates a polyhedron mesh
  113071. * * 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
  113072. * * The parameter `size` (positive float, default 1) sets the polygon size
  113073. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113074. * * 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`
  113075. * * 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
  113076. * * 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)`)
  113077. * * 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
  113078. * * 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
  113079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113082. * @param name defines the name of the mesh
  113083. * @param options defines the options used to create the mesh
  113084. * @param scene defines the hosting scene
  113085. * @returns the polyhedron mesh
  113086. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113087. */
  113088. static CreatePolyhedron(name: string, options: {
  113089. type?: number;
  113090. size?: number;
  113091. sizeX?: number;
  113092. sizeY?: number;
  113093. sizeZ?: number;
  113094. custom?: any;
  113095. faceUV?: Vector4[];
  113096. faceColors?: Color4[];
  113097. flat?: boolean;
  113098. updatable?: boolean;
  113099. sideOrientation?: number;
  113100. frontUVs?: Vector4;
  113101. backUVs?: Vector4;
  113102. }, scene?: Nullable<Scene>): Mesh;
  113103. }
  113104. }
  113105. declare module BABYLON {
  113106. /**
  113107. * Gizmo that enables scaling a mesh along 3 axis
  113108. */
  113109. export class ScaleGizmo extends Gizmo {
  113110. /**
  113111. * Internal gizmo used for interactions on the x axis
  113112. */
  113113. xGizmo: AxisScaleGizmo;
  113114. /**
  113115. * Internal gizmo used for interactions on the y axis
  113116. */
  113117. yGizmo: AxisScaleGizmo;
  113118. /**
  113119. * Internal gizmo used for interactions on the z axis
  113120. */
  113121. zGizmo: AxisScaleGizmo;
  113122. /**
  113123. * Internal gizmo used to scale all axis equally
  113124. */
  113125. uniformScaleGizmo: AxisScaleGizmo;
  113126. private _meshAttached;
  113127. private _updateGizmoRotationToMatchAttachedMesh;
  113128. private _snapDistance;
  113129. private _scaleRatio;
  113130. private _uniformScalingMesh;
  113131. private _octahedron;
  113132. /** Fires an event when any of it's sub gizmos are dragged */
  113133. onDragStartObservable: Observable<unknown>;
  113134. /** Fires an event when any of it's sub gizmos are released from dragging */
  113135. onDragEndObservable: Observable<unknown>;
  113136. attachedMesh: Nullable<AbstractMesh>;
  113137. /**
  113138. * Creates a ScaleGizmo
  113139. * @param gizmoLayer The utility layer the gizmo will be added to
  113140. */
  113141. constructor(gizmoLayer?: UtilityLayerRenderer);
  113142. updateGizmoRotationToMatchAttachedMesh: boolean;
  113143. /**
  113144. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113145. */
  113146. snapDistance: number;
  113147. /**
  113148. * Ratio for the scale of the gizmo (Default: 1)
  113149. */
  113150. scaleRatio: number;
  113151. /**
  113152. * Disposes of the gizmo
  113153. */
  113154. dispose(): void;
  113155. }
  113156. }
  113157. declare module BABYLON {
  113158. /**
  113159. * Single axis scale gizmo
  113160. */
  113161. export class AxisScaleGizmo extends Gizmo {
  113162. /**
  113163. * Drag behavior responsible for the gizmos dragging interactions
  113164. */
  113165. dragBehavior: PointerDragBehavior;
  113166. private _pointerObserver;
  113167. /**
  113168. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113169. */
  113170. snapDistance: number;
  113171. /**
  113172. * Event that fires each time the gizmo snaps to a new location.
  113173. * * snapDistance is the the change in distance
  113174. */
  113175. onSnapObservable: Observable<{
  113176. snapDistance: number;
  113177. }>;
  113178. /**
  113179. * If the scaling operation should be done on all axis (default: false)
  113180. */
  113181. uniformScaling: boolean;
  113182. private _isEnabled;
  113183. private _parent;
  113184. private _arrow;
  113185. private _coloredMaterial;
  113186. private _hoverMaterial;
  113187. /**
  113188. * Creates an AxisScaleGizmo
  113189. * @param gizmoLayer The utility layer the gizmo will be added to
  113190. * @param dragAxis The axis which the gizmo will be able to scale on
  113191. * @param color The color of the gizmo
  113192. */
  113193. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113194. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113195. /**
  113196. * If the gizmo is enabled
  113197. */
  113198. isEnabled: boolean;
  113199. /**
  113200. * Disposes of the gizmo
  113201. */
  113202. dispose(): void;
  113203. /**
  113204. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113205. * @param mesh The mesh to replace the default mesh of the gizmo
  113206. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113207. */
  113208. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113209. }
  113210. }
  113211. declare module BABYLON {
  113212. /**
  113213. * Bounding box gizmo
  113214. */
  113215. export class BoundingBoxGizmo extends Gizmo {
  113216. private _lineBoundingBox;
  113217. private _rotateSpheresParent;
  113218. private _scaleBoxesParent;
  113219. private _boundingDimensions;
  113220. private _renderObserver;
  113221. private _pointerObserver;
  113222. private _scaleDragSpeed;
  113223. private _tmpQuaternion;
  113224. private _tmpVector;
  113225. private _tmpRotationMatrix;
  113226. /**
  113227. * 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)
  113228. */
  113229. ignoreChildren: boolean;
  113230. /**
  113231. * 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)
  113232. */
  113233. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113234. /**
  113235. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113236. */
  113237. rotationSphereSize: number;
  113238. /**
  113239. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113240. */
  113241. scaleBoxSize: number;
  113242. /**
  113243. * 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)
  113244. */
  113245. fixedDragMeshScreenSize: boolean;
  113246. /**
  113247. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113248. */
  113249. fixedDragMeshScreenSizeDistanceFactor: number;
  113250. /**
  113251. * Fired when a rotation sphere or scale box is dragged
  113252. */
  113253. onDragStartObservable: Observable<{}>;
  113254. /**
  113255. * Fired when a scale box is dragged
  113256. */
  113257. onScaleBoxDragObservable: Observable<{}>;
  113258. /**
  113259. * Fired when a scale box drag is ended
  113260. */
  113261. onScaleBoxDragEndObservable: Observable<{}>;
  113262. /**
  113263. * Fired when a rotation sphere is dragged
  113264. */
  113265. onRotationSphereDragObservable: Observable<{}>;
  113266. /**
  113267. * Fired when a rotation sphere drag is ended
  113268. */
  113269. onRotationSphereDragEndObservable: Observable<{}>;
  113270. /**
  113271. * 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)
  113272. */
  113273. scalePivot: Nullable<Vector3>;
  113274. /**
  113275. * Mesh used as a pivot to rotate the attached mesh
  113276. */
  113277. private _anchorMesh;
  113278. private _existingMeshScale;
  113279. private _dragMesh;
  113280. private pointerDragBehavior;
  113281. private coloredMaterial;
  113282. private hoverColoredMaterial;
  113283. /**
  113284. * Sets the color of the bounding box gizmo
  113285. * @param color the color to set
  113286. */
  113287. setColor(color: Color3): void;
  113288. /**
  113289. * Creates an BoundingBoxGizmo
  113290. * @param gizmoLayer The utility layer the gizmo will be added to
  113291. * @param color The color of the gizmo
  113292. */
  113293. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113294. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113295. private _selectNode;
  113296. /**
  113297. * Updates the bounding box information for the Gizmo
  113298. */
  113299. updateBoundingBox(): void;
  113300. private _updateRotationSpheres;
  113301. private _updateScaleBoxes;
  113302. /**
  113303. * Enables rotation on the specified axis and disables rotation on the others
  113304. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113305. */
  113306. setEnabledRotationAxis(axis: string): void;
  113307. /**
  113308. * Enables/disables scaling
  113309. * @param enable if scaling should be enabled
  113310. */
  113311. setEnabledScaling(enable: boolean): void;
  113312. private _updateDummy;
  113313. /**
  113314. * Enables a pointer drag behavior on the bounding box of the gizmo
  113315. */
  113316. enableDragBehavior(): void;
  113317. /**
  113318. * Disposes of the gizmo
  113319. */
  113320. dispose(): void;
  113321. /**
  113322. * 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)
  113323. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113324. * @returns the bounding box mesh with the passed in mesh as a child
  113325. */
  113326. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113327. /**
  113328. * CustomMeshes are not supported by this gizmo
  113329. * @param mesh The mesh to replace the default mesh of the gizmo
  113330. */
  113331. setCustomMesh(mesh: Mesh): void;
  113332. }
  113333. }
  113334. declare module BABYLON {
  113335. /**
  113336. * Single plane rotation gizmo
  113337. */
  113338. export class PlaneRotationGizmo extends Gizmo {
  113339. /**
  113340. * Drag behavior responsible for the gizmos dragging interactions
  113341. */
  113342. dragBehavior: PointerDragBehavior;
  113343. private _pointerObserver;
  113344. /**
  113345. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113346. */
  113347. snapDistance: number;
  113348. /**
  113349. * Event that fires each time the gizmo snaps to a new location.
  113350. * * snapDistance is the the change in distance
  113351. */
  113352. onSnapObservable: Observable<{
  113353. snapDistance: number;
  113354. }>;
  113355. private _isEnabled;
  113356. private _parent;
  113357. /**
  113358. * Creates a PlaneRotationGizmo
  113359. * @param gizmoLayer The utility layer the gizmo will be added to
  113360. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113361. * @param color The color of the gizmo
  113362. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113363. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113364. */
  113365. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113366. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113367. /**
  113368. * If the gizmo is enabled
  113369. */
  113370. isEnabled: boolean;
  113371. /**
  113372. * Disposes of the gizmo
  113373. */
  113374. dispose(): void;
  113375. }
  113376. }
  113377. declare module BABYLON {
  113378. /**
  113379. * Gizmo that enables rotating a mesh along 3 axis
  113380. */
  113381. export class RotationGizmo extends Gizmo {
  113382. /**
  113383. * Internal gizmo used for interactions on the x axis
  113384. */
  113385. xGizmo: PlaneRotationGizmo;
  113386. /**
  113387. * Internal gizmo used for interactions on the y axis
  113388. */
  113389. yGizmo: PlaneRotationGizmo;
  113390. /**
  113391. * Internal gizmo used for interactions on the z axis
  113392. */
  113393. zGizmo: PlaneRotationGizmo;
  113394. /** Fires an event when any of it's sub gizmos are dragged */
  113395. onDragStartObservable: Observable<unknown>;
  113396. /** Fires an event when any of it's sub gizmos are released from dragging */
  113397. onDragEndObservable: Observable<unknown>;
  113398. private _meshAttached;
  113399. attachedMesh: Nullable<AbstractMesh>;
  113400. /**
  113401. * Creates a RotationGizmo
  113402. * @param gizmoLayer The utility layer the gizmo will be added to
  113403. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113404. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113405. */
  113406. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113407. updateGizmoRotationToMatchAttachedMesh: boolean;
  113408. /**
  113409. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113410. */
  113411. snapDistance: number;
  113412. /**
  113413. * Ratio for the scale of the gizmo (Default: 1)
  113414. */
  113415. scaleRatio: number;
  113416. /**
  113417. * Disposes of the gizmo
  113418. */
  113419. dispose(): void;
  113420. /**
  113421. * CustomMeshes are not supported by this gizmo
  113422. * @param mesh The mesh to replace the default mesh of the gizmo
  113423. */
  113424. setCustomMesh(mesh: Mesh): void;
  113425. }
  113426. }
  113427. declare module BABYLON {
  113428. /**
  113429. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113430. */
  113431. export class GizmoManager implements IDisposable {
  113432. private scene;
  113433. /**
  113434. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113435. */
  113436. gizmos: {
  113437. positionGizmo: Nullable<PositionGizmo>;
  113438. rotationGizmo: Nullable<RotationGizmo>;
  113439. scaleGizmo: Nullable<ScaleGizmo>;
  113440. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113441. };
  113442. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113443. clearGizmoOnEmptyPointerEvent: boolean;
  113444. /** Fires an event when the manager is attached to a mesh */
  113445. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113446. private _gizmosEnabled;
  113447. private _pointerObserver;
  113448. private _attachedMesh;
  113449. private _boundingBoxColor;
  113450. private _defaultUtilityLayer;
  113451. private _defaultKeepDepthUtilityLayer;
  113452. /**
  113453. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113454. */
  113455. boundingBoxDragBehavior: SixDofDragBehavior;
  113456. /**
  113457. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113458. */
  113459. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113460. /**
  113461. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113462. */
  113463. usePointerToAttachGizmos: boolean;
  113464. /**
  113465. * Utility layer that the bounding box gizmo belongs to
  113466. */
  113467. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113468. /**
  113469. * Utility layer that all gizmos besides bounding box belong to
  113470. */
  113471. readonly utilityLayer: UtilityLayerRenderer;
  113472. /**
  113473. * Instatiates a gizmo manager
  113474. * @param scene the scene to overlay the gizmos on top of
  113475. */
  113476. constructor(scene: Scene);
  113477. /**
  113478. * Attaches a set of gizmos to the specified mesh
  113479. * @param mesh The mesh the gizmo's should be attached to
  113480. */
  113481. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113482. /**
  113483. * If the position gizmo is enabled
  113484. */
  113485. positionGizmoEnabled: boolean;
  113486. /**
  113487. * If the rotation gizmo is enabled
  113488. */
  113489. rotationGizmoEnabled: boolean;
  113490. /**
  113491. * If the scale gizmo is enabled
  113492. */
  113493. scaleGizmoEnabled: boolean;
  113494. /**
  113495. * If the boundingBox gizmo is enabled
  113496. */
  113497. boundingBoxGizmoEnabled: boolean;
  113498. /**
  113499. * Disposes of the gizmo manager
  113500. */
  113501. dispose(): void;
  113502. }
  113503. }
  113504. declare module BABYLON {
  113505. /**
  113506. * A directional light is defined by a direction (what a surprise!).
  113507. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113508. * 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.
  113509. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113510. */
  113511. export class DirectionalLight extends ShadowLight {
  113512. private _shadowFrustumSize;
  113513. /**
  113514. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113515. */
  113516. /**
  113517. * Specifies a fix frustum size for the shadow generation.
  113518. */
  113519. shadowFrustumSize: number;
  113520. private _shadowOrthoScale;
  113521. /**
  113522. * Gets the shadow projection scale against the optimal computed one.
  113523. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113524. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113525. */
  113526. /**
  113527. * Sets the shadow projection scale against the optimal computed one.
  113528. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113529. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113530. */
  113531. shadowOrthoScale: number;
  113532. /**
  113533. * Automatically compute the projection matrix to best fit (including all the casters)
  113534. * on each frame.
  113535. */
  113536. autoUpdateExtends: boolean;
  113537. private _orthoLeft;
  113538. private _orthoRight;
  113539. private _orthoTop;
  113540. private _orthoBottom;
  113541. /**
  113542. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113543. * The directional light is emitted from everywhere in the given direction.
  113544. * It can cast shadows.
  113545. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113546. * @param name The friendly name of the light
  113547. * @param direction The direction of the light
  113548. * @param scene The scene the light belongs to
  113549. */
  113550. constructor(name: string, direction: Vector3, scene: Scene);
  113551. /**
  113552. * Returns the string "DirectionalLight".
  113553. * @return The class name
  113554. */
  113555. getClassName(): string;
  113556. /**
  113557. * Returns the integer 1.
  113558. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113559. */
  113560. getTypeID(): number;
  113561. /**
  113562. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113563. * Returns the DirectionalLight Shadow projection matrix.
  113564. */
  113565. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113566. /**
  113567. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113568. * Returns the DirectionalLight Shadow projection matrix.
  113569. */
  113570. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113571. /**
  113572. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113573. * Returns the DirectionalLight Shadow projection matrix.
  113574. */
  113575. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113576. protected _buildUniformLayout(): void;
  113577. /**
  113578. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113579. * @param effect The effect to update
  113580. * @param lightIndex The index of the light in the effect to update
  113581. * @returns The directional light
  113582. */
  113583. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113584. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113585. /**
  113586. * Gets the minZ used for shadow according to both the scene and the light.
  113587. *
  113588. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113589. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113590. * @param activeCamera The camera we are returning the min for
  113591. * @returns the depth min z
  113592. */
  113593. getDepthMinZ(activeCamera: Camera): number;
  113594. /**
  113595. * Gets the maxZ used for shadow according to both the scene and the light.
  113596. *
  113597. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113598. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113599. * @param activeCamera The camera we are returning the max for
  113600. * @returns the depth max z
  113601. */
  113602. getDepthMaxZ(activeCamera: Camera): number;
  113603. /**
  113604. * Prepares the list of defines specific to the light type.
  113605. * @param defines the list of defines
  113606. * @param lightIndex defines the index of the light for the effect
  113607. */
  113608. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113609. }
  113610. }
  113611. declare module BABYLON {
  113612. /**
  113613. * Class containing static functions to help procedurally build meshes
  113614. */
  113615. export class HemisphereBuilder {
  113616. /**
  113617. * Creates a hemisphere mesh
  113618. * @param name defines the name of the mesh
  113619. * @param options defines the options used to create the mesh
  113620. * @param scene defines the hosting scene
  113621. * @returns the hemisphere mesh
  113622. */
  113623. static CreateHemisphere(name: string, options: {
  113624. segments?: number;
  113625. diameter?: number;
  113626. sideOrientation?: number;
  113627. }, scene: any): Mesh;
  113628. }
  113629. }
  113630. declare module BABYLON {
  113631. /**
  113632. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113633. * These values define a cone of light starting from the position, emitting toward the direction.
  113634. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113635. * and the exponent defines the speed of the decay of the light with distance (reach).
  113636. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113637. */
  113638. export class SpotLight extends ShadowLight {
  113639. private _angle;
  113640. private _innerAngle;
  113641. private _cosHalfAngle;
  113642. private _lightAngleScale;
  113643. private _lightAngleOffset;
  113644. /**
  113645. * Gets the cone angle of the spot light in Radians.
  113646. */
  113647. /**
  113648. * Sets the cone angle of the spot light in Radians.
  113649. */
  113650. angle: number;
  113651. /**
  113652. * Only used in gltf falloff mode, this defines the angle where
  113653. * the directional falloff will start before cutting at angle which could be seen
  113654. * as outer angle.
  113655. */
  113656. /**
  113657. * Only used in gltf falloff mode, this defines the angle where
  113658. * the directional falloff will start before cutting at angle which could be seen
  113659. * as outer angle.
  113660. */
  113661. innerAngle: number;
  113662. private _shadowAngleScale;
  113663. /**
  113664. * Allows scaling the angle of the light for shadow generation only.
  113665. */
  113666. /**
  113667. * Allows scaling the angle of the light for shadow generation only.
  113668. */
  113669. shadowAngleScale: number;
  113670. /**
  113671. * The light decay speed with the distance from the emission spot.
  113672. */
  113673. exponent: number;
  113674. private _projectionTextureMatrix;
  113675. /**
  113676. * Allows reading the projecton texture
  113677. */
  113678. readonly projectionTextureMatrix: Matrix;
  113679. protected _projectionTextureLightNear: number;
  113680. /**
  113681. * Gets the near clip of the Spotlight for texture projection.
  113682. */
  113683. /**
  113684. * Sets the near clip of the Spotlight for texture projection.
  113685. */
  113686. projectionTextureLightNear: number;
  113687. protected _projectionTextureLightFar: number;
  113688. /**
  113689. * Gets the far clip of the Spotlight for texture projection.
  113690. */
  113691. /**
  113692. * Sets the far clip of the Spotlight for texture projection.
  113693. */
  113694. projectionTextureLightFar: number;
  113695. protected _projectionTextureUpDirection: Vector3;
  113696. /**
  113697. * Gets the Up vector of the Spotlight for texture projection.
  113698. */
  113699. /**
  113700. * Sets the Up vector of the Spotlight for texture projection.
  113701. */
  113702. projectionTextureUpDirection: Vector3;
  113703. private _projectionTexture;
  113704. /**
  113705. * Gets the projection texture of the light.
  113706. */
  113707. /**
  113708. * Sets the projection texture of the light.
  113709. */
  113710. projectionTexture: Nullable<BaseTexture>;
  113711. private _projectionTextureViewLightDirty;
  113712. private _projectionTextureProjectionLightDirty;
  113713. private _projectionTextureDirty;
  113714. private _projectionTextureViewTargetVector;
  113715. private _projectionTextureViewLightMatrix;
  113716. private _projectionTextureProjectionLightMatrix;
  113717. private _projectionTextureScalingMatrix;
  113718. /**
  113719. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113720. * It can cast shadows.
  113721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113722. * @param name The light friendly name
  113723. * @param position The position of the spot light in the scene
  113724. * @param direction The direction of the light in the scene
  113725. * @param angle The cone angle of the light in Radians
  113726. * @param exponent The light decay speed with the distance from the emission spot
  113727. * @param scene The scene the lights belongs to
  113728. */
  113729. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113730. /**
  113731. * Returns the string "SpotLight".
  113732. * @returns the class name
  113733. */
  113734. getClassName(): string;
  113735. /**
  113736. * Returns the integer 2.
  113737. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113738. */
  113739. getTypeID(): number;
  113740. /**
  113741. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113742. */
  113743. protected _setDirection(value: Vector3): void;
  113744. /**
  113745. * Overrides the position setter to recompute the projection texture view light Matrix.
  113746. */
  113747. protected _setPosition(value: Vector3): void;
  113748. /**
  113749. * 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.
  113750. * Returns the SpotLight.
  113751. */
  113752. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113753. protected _computeProjectionTextureViewLightMatrix(): void;
  113754. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113755. /**
  113756. * Main function for light texture projection matrix computing.
  113757. */
  113758. protected _computeProjectionTextureMatrix(): void;
  113759. protected _buildUniformLayout(): void;
  113760. private _computeAngleValues;
  113761. /**
  113762. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113763. * @param effect The effect to update
  113764. * @param lightIndex The index of the light in the effect to update
  113765. * @returns The spot light
  113766. */
  113767. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113768. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113769. /**
  113770. * Disposes the light and the associated resources.
  113771. */
  113772. dispose(): void;
  113773. /**
  113774. * Prepares the list of defines specific to the light type.
  113775. * @param defines the list of defines
  113776. * @param lightIndex defines the index of the light for the effect
  113777. */
  113778. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113779. }
  113780. }
  113781. declare module BABYLON {
  113782. /**
  113783. * Gizmo that enables viewing a light
  113784. */
  113785. export class LightGizmo extends Gizmo {
  113786. private _lightMesh;
  113787. private _material;
  113788. private cachedPosition;
  113789. private cachedForward;
  113790. /**
  113791. * Creates a LightGizmo
  113792. * @param gizmoLayer The utility layer the gizmo will be added to
  113793. */
  113794. constructor(gizmoLayer?: UtilityLayerRenderer);
  113795. private _light;
  113796. /**
  113797. * The light that the gizmo is attached to
  113798. */
  113799. light: Nullable<Light>;
  113800. /**
  113801. * Gets the material used to render the light gizmo
  113802. */
  113803. readonly material: StandardMaterial;
  113804. /**
  113805. * @hidden
  113806. * Updates the gizmo to match the attached mesh's position/rotation
  113807. */
  113808. protected _update(): void;
  113809. private static _Scale;
  113810. /**
  113811. * Creates the lines for a light mesh
  113812. */
  113813. private static _createLightLines;
  113814. /**
  113815. * Disposes of the light gizmo
  113816. */
  113817. dispose(): void;
  113818. private static _CreateHemisphericLightMesh;
  113819. private static _CreatePointLightMesh;
  113820. private static _CreateSpotLightMesh;
  113821. private static _CreateDirectionalLightMesh;
  113822. }
  113823. }
  113824. declare module BABYLON {
  113825. /** @hidden */
  113826. export var backgroundFragmentDeclaration: {
  113827. name: string;
  113828. shader: string;
  113829. };
  113830. }
  113831. declare module BABYLON {
  113832. /** @hidden */
  113833. export var backgroundUboDeclaration: {
  113834. name: string;
  113835. shader: string;
  113836. };
  113837. }
  113838. declare module BABYLON {
  113839. /** @hidden */
  113840. export var backgroundPixelShader: {
  113841. name: string;
  113842. shader: string;
  113843. };
  113844. }
  113845. declare module BABYLON {
  113846. /** @hidden */
  113847. export var backgroundVertexDeclaration: {
  113848. name: string;
  113849. shader: string;
  113850. };
  113851. }
  113852. declare module BABYLON {
  113853. /** @hidden */
  113854. export var backgroundVertexShader: {
  113855. name: string;
  113856. shader: string;
  113857. };
  113858. }
  113859. declare module BABYLON {
  113860. /**
  113861. * Background material used to create an efficient environement around your scene.
  113862. */
  113863. export class BackgroundMaterial extends PushMaterial {
  113864. /**
  113865. * Standard reflectance value at parallel view angle.
  113866. */
  113867. static StandardReflectance0: number;
  113868. /**
  113869. * Standard reflectance value at grazing angle.
  113870. */
  113871. static StandardReflectance90: number;
  113872. protected _primaryColor: Color3;
  113873. /**
  113874. * Key light Color (multiply against the environement texture)
  113875. */
  113876. primaryColor: Color3;
  113877. protected __perceptualColor: Nullable<Color3>;
  113878. /**
  113879. * Experimental Internal Use Only.
  113880. *
  113881. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113882. * This acts as a helper to set the primary color to a more "human friendly" value.
  113883. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113884. * output color as close as possible from the chosen value.
  113885. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113886. * part of lighting setup.)
  113887. */
  113888. _perceptualColor: Nullable<Color3>;
  113889. protected _primaryColorShadowLevel: float;
  113890. /**
  113891. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113892. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113893. */
  113894. primaryColorShadowLevel: float;
  113895. protected _primaryColorHighlightLevel: float;
  113896. /**
  113897. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113898. * The primary color is used at the level chosen to define what the white area would look.
  113899. */
  113900. primaryColorHighlightLevel: float;
  113901. protected _reflectionTexture: Nullable<BaseTexture>;
  113902. /**
  113903. * Reflection Texture used in the material.
  113904. * Should be author in a specific way for the best result (refer to the documentation).
  113905. */
  113906. reflectionTexture: Nullable<BaseTexture>;
  113907. protected _reflectionBlur: float;
  113908. /**
  113909. * Reflection Texture level of blur.
  113910. *
  113911. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113912. * texture twice.
  113913. */
  113914. reflectionBlur: float;
  113915. protected _diffuseTexture: Nullable<BaseTexture>;
  113916. /**
  113917. * Diffuse Texture used in the material.
  113918. * Should be author in a specific way for the best result (refer to the documentation).
  113919. */
  113920. diffuseTexture: Nullable<BaseTexture>;
  113921. protected _shadowLights: Nullable<IShadowLight[]>;
  113922. /**
  113923. * Specify the list of lights casting shadow on the material.
  113924. * All scene shadow lights will be included if null.
  113925. */
  113926. shadowLights: Nullable<IShadowLight[]>;
  113927. protected _shadowLevel: float;
  113928. /**
  113929. * Helps adjusting the shadow to a softer level if required.
  113930. * 0 means black shadows and 1 means no shadows.
  113931. */
  113932. shadowLevel: float;
  113933. protected _sceneCenter: Vector3;
  113934. /**
  113935. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113936. * It is usually zero but might be interesting to modify according to your setup.
  113937. */
  113938. sceneCenter: Vector3;
  113939. protected _opacityFresnel: boolean;
  113940. /**
  113941. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113942. * This helps ensuring a nice transition when the camera goes under the ground.
  113943. */
  113944. opacityFresnel: boolean;
  113945. protected _reflectionFresnel: boolean;
  113946. /**
  113947. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113948. * This helps adding a mirror texture on the ground.
  113949. */
  113950. reflectionFresnel: boolean;
  113951. protected _reflectionFalloffDistance: number;
  113952. /**
  113953. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113954. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113955. */
  113956. reflectionFalloffDistance: number;
  113957. protected _reflectionAmount: number;
  113958. /**
  113959. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113960. */
  113961. reflectionAmount: number;
  113962. protected _reflectionReflectance0: number;
  113963. /**
  113964. * This specifies the weight of the reflection at grazing angle.
  113965. */
  113966. reflectionReflectance0: number;
  113967. protected _reflectionReflectance90: number;
  113968. /**
  113969. * This specifies the weight of the reflection at a perpendicular point of view.
  113970. */
  113971. reflectionReflectance90: number;
  113972. /**
  113973. * Sets the reflection reflectance fresnel values according to the default standard
  113974. * empirically know to work well :-)
  113975. */
  113976. reflectionStandardFresnelWeight: number;
  113977. protected _useRGBColor: boolean;
  113978. /**
  113979. * Helps to directly use the maps channels instead of their level.
  113980. */
  113981. useRGBColor: boolean;
  113982. protected _enableNoise: boolean;
  113983. /**
  113984. * This helps reducing the banding effect that could occur on the background.
  113985. */
  113986. enableNoise: boolean;
  113987. /**
  113988. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113989. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113990. * Recommended to be keep at 1.0 except for special cases.
  113991. */
  113992. fovMultiplier: number;
  113993. private _fovMultiplier;
  113994. /**
  113995. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113996. */
  113997. useEquirectangularFOV: boolean;
  113998. private _maxSimultaneousLights;
  113999. /**
  114000. * Number of Simultaneous lights allowed on the material.
  114001. */
  114002. maxSimultaneousLights: int;
  114003. /**
  114004. * Default configuration related to image processing available in the Background Material.
  114005. */
  114006. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114007. /**
  114008. * Keep track of the image processing observer to allow dispose and replace.
  114009. */
  114010. private _imageProcessingObserver;
  114011. /**
  114012. * Attaches a new image processing configuration to the PBR Material.
  114013. * @param configuration (if null the scene configuration will be use)
  114014. */
  114015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114016. /**
  114017. * Gets the image processing configuration used either in this material.
  114018. */
  114019. /**
  114020. * Sets the Default image processing configuration used either in the this material.
  114021. *
  114022. * If sets to null, the scene one is in use.
  114023. */
  114024. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114025. /**
  114026. * Gets wether the color curves effect is enabled.
  114027. */
  114028. /**
  114029. * Sets wether the color curves effect is enabled.
  114030. */
  114031. cameraColorCurvesEnabled: boolean;
  114032. /**
  114033. * Gets wether the color grading effect is enabled.
  114034. */
  114035. /**
  114036. * Gets wether the color grading effect is enabled.
  114037. */
  114038. cameraColorGradingEnabled: boolean;
  114039. /**
  114040. * Gets wether tonemapping is enabled or not.
  114041. */
  114042. /**
  114043. * Sets wether tonemapping is enabled or not
  114044. */
  114045. cameraToneMappingEnabled: boolean;
  114046. /**
  114047. * The camera exposure used on this material.
  114048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114049. * This corresponds to a photographic exposure.
  114050. */
  114051. /**
  114052. * The camera exposure used on this material.
  114053. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114054. * This corresponds to a photographic exposure.
  114055. */
  114056. cameraExposure: float;
  114057. /**
  114058. * Gets The camera contrast used on this material.
  114059. */
  114060. /**
  114061. * Sets The camera contrast used on this material.
  114062. */
  114063. cameraContrast: float;
  114064. /**
  114065. * Gets the Color Grading 2D Lookup Texture.
  114066. */
  114067. /**
  114068. * Sets the Color Grading 2D Lookup Texture.
  114069. */
  114070. cameraColorGradingTexture: Nullable<BaseTexture>;
  114071. /**
  114072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114074. * 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;
  114075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114076. */
  114077. /**
  114078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114080. * 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;
  114081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114082. */
  114083. cameraColorCurves: Nullable<ColorCurves>;
  114084. /**
  114085. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114086. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114087. */
  114088. switchToBGR: boolean;
  114089. private _renderTargets;
  114090. private _reflectionControls;
  114091. private _white;
  114092. private _primaryShadowColor;
  114093. private _primaryHighlightColor;
  114094. /**
  114095. * Instantiates a Background Material in the given scene
  114096. * @param name The friendly name of the material
  114097. * @param scene The scene to add the material to
  114098. */
  114099. constructor(name: string, scene: Scene);
  114100. /**
  114101. * Gets a boolean indicating that current material needs to register RTT
  114102. */
  114103. readonly hasRenderTargetTextures: boolean;
  114104. /**
  114105. * The entire material has been created in order to prevent overdraw.
  114106. * @returns false
  114107. */
  114108. needAlphaTesting(): boolean;
  114109. /**
  114110. * The entire material has been created in order to prevent overdraw.
  114111. * @returns true if blending is enable
  114112. */
  114113. needAlphaBlending(): boolean;
  114114. /**
  114115. * Checks wether the material is ready to be rendered for a given mesh.
  114116. * @param mesh The mesh to render
  114117. * @param subMesh The submesh to check against
  114118. * @param useInstances Specify wether or not the material is used with instances
  114119. * @returns true if all the dependencies are ready (Textures, Effects...)
  114120. */
  114121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114122. /**
  114123. * Compute the primary color according to the chosen perceptual color.
  114124. */
  114125. private _computePrimaryColorFromPerceptualColor;
  114126. /**
  114127. * Compute the highlights and shadow colors according to their chosen levels.
  114128. */
  114129. private _computePrimaryColors;
  114130. /**
  114131. * Build the uniform buffer used in the material.
  114132. */
  114133. buildUniformLayout(): void;
  114134. /**
  114135. * Unbind the material.
  114136. */
  114137. unbind(): void;
  114138. /**
  114139. * Bind only the world matrix to the material.
  114140. * @param world The world matrix to bind.
  114141. */
  114142. bindOnlyWorldMatrix(world: Matrix): void;
  114143. /**
  114144. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114145. * @param world The world matrix to bind.
  114146. * @param subMesh The submesh to bind for.
  114147. */
  114148. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114149. /**
  114150. * Checks to see if a texture is used in the material.
  114151. * @param texture - Base texture to use.
  114152. * @returns - Boolean specifying if a texture is used in the material.
  114153. */
  114154. hasTexture(texture: BaseTexture): boolean;
  114155. /**
  114156. * Dispose the material.
  114157. * @param forceDisposeEffect Force disposal of the associated effect.
  114158. * @param forceDisposeTextures Force disposal of the associated textures.
  114159. */
  114160. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114161. /**
  114162. * Clones the material.
  114163. * @param name The cloned name.
  114164. * @returns The cloned material.
  114165. */
  114166. clone(name: string): BackgroundMaterial;
  114167. /**
  114168. * Serializes the current material to its JSON representation.
  114169. * @returns The JSON representation.
  114170. */
  114171. serialize(): any;
  114172. /**
  114173. * Gets the class name of the material
  114174. * @returns "BackgroundMaterial"
  114175. */
  114176. getClassName(): string;
  114177. /**
  114178. * Parse a JSON input to create back a background material.
  114179. * @param source The JSON data to parse
  114180. * @param scene The scene to create the parsed material in
  114181. * @param rootUrl The root url of the assets the material depends upon
  114182. * @returns the instantiated BackgroundMaterial.
  114183. */
  114184. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. /**
  114189. * Represents the different options available during the creation of
  114190. * a Environment helper.
  114191. *
  114192. * This can control the default ground, skybox and image processing setup of your scene.
  114193. */
  114194. export interface IEnvironmentHelperOptions {
  114195. /**
  114196. * Specifies wether or not to create a ground.
  114197. * True by default.
  114198. */
  114199. createGround: boolean;
  114200. /**
  114201. * Specifies the ground size.
  114202. * 15 by default.
  114203. */
  114204. groundSize: number;
  114205. /**
  114206. * The texture used on the ground for the main color.
  114207. * Comes from the BabylonJS CDN by default.
  114208. *
  114209. * Remarks: Can be either a texture or a url.
  114210. */
  114211. groundTexture: string | BaseTexture;
  114212. /**
  114213. * The color mixed in the ground texture by default.
  114214. * BabylonJS clearColor by default.
  114215. */
  114216. groundColor: Color3;
  114217. /**
  114218. * Specifies the ground opacity.
  114219. * 1 by default.
  114220. */
  114221. groundOpacity: number;
  114222. /**
  114223. * Enables the ground to receive shadows.
  114224. * True by default.
  114225. */
  114226. enableGroundShadow: boolean;
  114227. /**
  114228. * Helps preventing the shadow to be fully black on the ground.
  114229. * 0.5 by default.
  114230. */
  114231. groundShadowLevel: number;
  114232. /**
  114233. * Creates a mirror texture attach to the ground.
  114234. * false by default.
  114235. */
  114236. enableGroundMirror: boolean;
  114237. /**
  114238. * Specifies the ground mirror size ratio.
  114239. * 0.3 by default as the default kernel is 64.
  114240. */
  114241. groundMirrorSizeRatio: number;
  114242. /**
  114243. * Specifies the ground mirror blur kernel size.
  114244. * 64 by default.
  114245. */
  114246. groundMirrorBlurKernel: number;
  114247. /**
  114248. * Specifies the ground mirror visibility amount.
  114249. * 1 by default
  114250. */
  114251. groundMirrorAmount: number;
  114252. /**
  114253. * Specifies the ground mirror reflectance weight.
  114254. * This uses the standard weight of the background material to setup the fresnel effect
  114255. * of the mirror.
  114256. * 1 by default.
  114257. */
  114258. groundMirrorFresnelWeight: number;
  114259. /**
  114260. * Specifies the ground mirror Falloff distance.
  114261. * This can helps reducing the size of the reflection.
  114262. * 0 by Default.
  114263. */
  114264. groundMirrorFallOffDistance: number;
  114265. /**
  114266. * Specifies the ground mirror texture type.
  114267. * Unsigned Int by Default.
  114268. */
  114269. groundMirrorTextureType: number;
  114270. /**
  114271. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114272. * the shown objects.
  114273. */
  114274. groundYBias: number;
  114275. /**
  114276. * Specifies wether or not to create a skybox.
  114277. * True by default.
  114278. */
  114279. createSkybox: boolean;
  114280. /**
  114281. * Specifies the skybox size.
  114282. * 20 by default.
  114283. */
  114284. skyboxSize: number;
  114285. /**
  114286. * The texture used on the skybox for the main color.
  114287. * Comes from the BabylonJS CDN by default.
  114288. *
  114289. * Remarks: Can be either a texture or a url.
  114290. */
  114291. skyboxTexture: string | BaseTexture;
  114292. /**
  114293. * The color mixed in the skybox texture by default.
  114294. * BabylonJS clearColor by default.
  114295. */
  114296. skyboxColor: Color3;
  114297. /**
  114298. * The background rotation around the Y axis of the scene.
  114299. * This helps aligning the key lights of your scene with the background.
  114300. * 0 by default.
  114301. */
  114302. backgroundYRotation: number;
  114303. /**
  114304. * Compute automatically the size of the elements to best fit with the scene.
  114305. */
  114306. sizeAuto: boolean;
  114307. /**
  114308. * Default position of the rootMesh if autoSize is not true.
  114309. */
  114310. rootPosition: Vector3;
  114311. /**
  114312. * Sets up the image processing in the scene.
  114313. * true by default.
  114314. */
  114315. setupImageProcessing: boolean;
  114316. /**
  114317. * The texture used as your environment texture in the scene.
  114318. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114319. *
  114320. * Remarks: Can be either a texture or a url.
  114321. */
  114322. environmentTexture: string | BaseTexture;
  114323. /**
  114324. * The value of the exposure to apply to the scene.
  114325. * 0.6 by default if setupImageProcessing is true.
  114326. */
  114327. cameraExposure: number;
  114328. /**
  114329. * The value of the contrast to apply to the scene.
  114330. * 1.6 by default if setupImageProcessing is true.
  114331. */
  114332. cameraContrast: number;
  114333. /**
  114334. * Specifies wether or not tonemapping should be enabled in the scene.
  114335. * true by default if setupImageProcessing is true.
  114336. */
  114337. toneMappingEnabled: boolean;
  114338. }
  114339. /**
  114340. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114341. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114342. * It also helps with the default setup of your imageProcessing configuration.
  114343. */
  114344. export class EnvironmentHelper {
  114345. /**
  114346. * Default ground texture URL.
  114347. */
  114348. private static _groundTextureCDNUrl;
  114349. /**
  114350. * Default skybox texture URL.
  114351. */
  114352. private static _skyboxTextureCDNUrl;
  114353. /**
  114354. * Default environment texture URL.
  114355. */
  114356. private static _environmentTextureCDNUrl;
  114357. /**
  114358. * Creates the default options for the helper.
  114359. */
  114360. private static _getDefaultOptions;
  114361. private _rootMesh;
  114362. /**
  114363. * Gets the root mesh created by the helper.
  114364. */
  114365. readonly rootMesh: Mesh;
  114366. private _skybox;
  114367. /**
  114368. * Gets the skybox created by the helper.
  114369. */
  114370. readonly skybox: Nullable<Mesh>;
  114371. private _skyboxTexture;
  114372. /**
  114373. * Gets the skybox texture created by the helper.
  114374. */
  114375. readonly skyboxTexture: Nullable<BaseTexture>;
  114376. private _skyboxMaterial;
  114377. /**
  114378. * Gets the skybox material created by the helper.
  114379. */
  114380. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114381. private _ground;
  114382. /**
  114383. * Gets the ground mesh created by the helper.
  114384. */
  114385. readonly ground: Nullable<Mesh>;
  114386. private _groundTexture;
  114387. /**
  114388. * Gets the ground texture created by the helper.
  114389. */
  114390. readonly groundTexture: Nullable<BaseTexture>;
  114391. private _groundMirror;
  114392. /**
  114393. * Gets the ground mirror created by the helper.
  114394. */
  114395. readonly groundMirror: Nullable<MirrorTexture>;
  114396. /**
  114397. * Gets the ground mirror render list to helps pushing the meshes
  114398. * you wish in the ground reflection.
  114399. */
  114400. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114401. private _groundMaterial;
  114402. /**
  114403. * Gets the ground material created by the helper.
  114404. */
  114405. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114406. /**
  114407. * Stores the creation options.
  114408. */
  114409. private readonly _scene;
  114410. private _options;
  114411. /**
  114412. * This observable will be notified with any error during the creation of the environment,
  114413. * mainly texture creation errors.
  114414. */
  114415. onErrorObservable: Observable<{
  114416. message?: string;
  114417. exception?: any;
  114418. }>;
  114419. /**
  114420. * constructor
  114421. * @param options Defines the options we want to customize the helper
  114422. * @param scene The scene to add the material to
  114423. */
  114424. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114425. /**
  114426. * Updates the background according to the new options
  114427. * @param options
  114428. */
  114429. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114430. /**
  114431. * Sets the primary color of all the available elements.
  114432. * @param color the main color to affect to the ground and the background
  114433. */
  114434. setMainColor(color: Color3): void;
  114435. /**
  114436. * Setup the image processing according to the specified options.
  114437. */
  114438. private _setupImageProcessing;
  114439. /**
  114440. * Setup the environment texture according to the specified options.
  114441. */
  114442. private _setupEnvironmentTexture;
  114443. /**
  114444. * Setup the background according to the specified options.
  114445. */
  114446. private _setupBackground;
  114447. /**
  114448. * Get the scene sizes according to the setup.
  114449. */
  114450. private _getSceneSize;
  114451. /**
  114452. * Setup the ground according to the specified options.
  114453. */
  114454. private _setupGround;
  114455. /**
  114456. * Setup the ground material according to the specified options.
  114457. */
  114458. private _setupGroundMaterial;
  114459. /**
  114460. * Setup the ground diffuse texture according to the specified options.
  114461. */
  114462. private _setupGroundDiffuseTexture;
  114463. /**
  114464. * Setup the ground mirror texture according to the specified options.
  114465. */
  114466. private _setupGroundMirrorTexture;
  114467. /**
  114468. * Setup the ground to receive the mirror texture.
  114469. */
  114470. private _setupMirrorInGroundMaterial;
  114471. /**
  114472. * Setup the skybox according to the specified options.
  114473. */
  114474. private _setupSkybox;
  114475. /**
  114476. * Setup the skybox material according to the specified options.
  114477. */
  114478. private _setupSkyboxMaterial;
  114479. /**
  114480. * Setup the skybox reflection texture according to the specified options.
  114481. */
  114482. private _setupSkyboxReflectionTexture;
  114483. private _errorHandler;
  114484. /**
  114485. * Dispose all the elements created by the Helper.
  114486. */
  114487. dispose(): void;
  114488. }
  114489. }
  114490. declare module BABYLON {
  114491. /**
  114492. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114493. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114494. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114495. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114496. */
  114497. export class PhotoDome extends TransformNode {
  114498. /**
  114499. * Define the image as a Monoscopic panoramic 360 image.
  114500. */
  114501. static readonly MODE_MONOSCOPIC: number;
  114502. /**
  114503. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114504. */
  114505. static readonly MODE_TOPBOTTOM: number;
  114506. /**
  114507. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114508. */
  114509. static readonly MODE_SIDEBYSIDE: number;
  114510. private _useDirectMapping;
  114511. /**
  114512. * The texture being displayed on the sphere
  114513. */
  114514. protected _photoTexture: Texture;
  114515. /**
  114516. * Gets or sets the texture being displayed on the sphere
  114517. */
  114518. photoTexture: Texture;
  114519. /**
  114520. * Observable raised when an error occured while loading the 360 image
  114521. */
  114522. onLoadErrorObservable: Observable<string>;
  114523. /**
  114524. * The skybox material
  114525. */
  114526. protected _material: BackgroundMaterial;
  114527. /**
  114528. * The surface used for the skybox
  114529. */
  114530. protected _mesh: Mesh;
  114531. /**
  114532. * Gets the mesh used for the skybox.
  114533. */
  114534. readonly mesh: Mesh;
  114535. /**
  114536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114537. * Also see the options.resolution property.
  114538. */
  114539. fovMultiplier: number;
  114540. private _imageMode;
  114541. /**
  114542. * Gets or set the current video mode for the video. It can be:
  114543. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114544. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114545. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114546. */
  114547. imageMode: number;
  114548. /**
  114549. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114550. * @param name Element's name, child elements will append suffixes for their own names.
  114551. * @param urlsOfPhoto defines the url of the photo to display
  114552. * @param options defines an object containing optional or exposed sub element properties
  114553. * @param onError defines a callback called when an error occured while loading the texture
  114554. */
  114555. constructor(name: string, urlOfPhoto: string, options: {
  114556. resolution?: number;
  114557. size?: number;
  114558. useDirectMapping?: boolean;
  114559. faceForward?: boolean;
  114560. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114561. private _onBeforeCameraRenderObserver;
  114562. private _changeImageMode;
  114563. /**
  114564. * Releases resources associated with this node.
  114565. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114566. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114567. */
  114568. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114569. }
  114570. }
  114571. declare module BABYLON {
  114572. /**
  114573. * Class used to host RGBD texture specific utilities
  114574. */
  114575. export class RGBDTextureTools {
  114576. /**
  114577. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114578. * @param texture the texture to expand.
  114579. */
  114580. static ExpandRGBDTexture(texture: Texture): void;
  114581. }
  114582. }
  114583. declare module BABYLON {
  114584. /**
  114585. * Class used to host texture specific utilities
  114586. */
  114587. export class BRDFTextureTools {
  114588. /**
  114589. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114590. * @param scene defines the hosting scene
  114591. * @returns the environment BRDF texture
  114592. */
  114593. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114594. private static _environmentBRDFBase64Texture;
  114595. }
  114596. }
  114597. declare module BABYLON {
  114598. /**
  114599. * @hidden
  114600. */
  114601. export interface IMaterialClearCoatDefines {
  114602. CLEARCOAT: boolean;
  114603. CLEARCOAT_DEFAULTIOR: boolean;
  114604. CLEARCOAT_TEXTURE: boolean;
  114605. CLEARCOAT_TEXTUREDIRECTUV: number;
  114606. CLEARCOAT_BUMP: boolean;
  114607. CLEARCOAT_BUMPDIRECTUV: number;
  114608. CLEARCOAT_TINT: boolean;
  114609. CLEARCOAT_TINT_TEXTURE: boolean;
  114610. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114611. /** @hidden */
  114612. _areTexturesDirty: boolean;
  114613. }
  114614. /**
  114615. * Define the code related to the clear coat parameters of the pbr material.
  114616. */
  114617. export class PBRClearCoatConfiguration {
  114618. /**
  114619. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114620. * The default fits with a polyurethane material.
  114621. */
  114622. private static readonly _DefaultIndexOfRefraction;
  114623. private _isEnabled;
  114624. /**
  114625. * Defines if the clear coat is enabled in the material.
  114626. */
  114627. isEnabled: boolean;
  114628. /**
  114629. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114630. */
  114631. intensity: number;
  114632. /**
  114633. * Defines the clear coat layer roughness.
  114634. */
  114635. roughness: number;
  114636. private _indexOfRefraction;
  114637. /**
  114638. * Defines the index of refraction of the clear coat.
  114639. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114640. * The default fits with a polyurethane material.
  114641. * Changing the default value is more performance intensive.
  114642. */
  114643. indexOfRefraction: number;
  114644. private _texture;
  114645. /**
  114646. * Stores the clear coat values in a texture.
  114647. */
  114648. texture: Nullable<BaseTexture>;
  114649. private _bumpTexture;
  114650. /**
  114651. * Define the clear coat specific bump texture.
  114652. */
  114653. bumpTexture: Nullable<BaseTexture>;
  114654. private _isTintEnabled;
  114655. /**
  114656. * Defines if the clear coat tint is enabled in the material.
  114657. */
  114658. isTintEnabled: boolean;
  114659. /**
  114660. * Defines the clear coat tint of the material.
  114661. * This is only use if tint is enabled
  114662. */
  114663. tintColor: Color3;
  114664. /**
  114665. * Defines the distance at which the tint color should be found in the
  114666. * clear coat media.
  114667. * This is only use if tint is enabled
  114668. */
  114669. tintColorAtDistance: number;
  114670. /**
  114671. * Defines the clear coat layer thickness.
  114672. * This is only use if tint is enabled
  114673. */
  114674. tintThickness: number;
  114675. private _tintTexture;
  114676. /**
  114677. * Stores the clear tint values in a texture.
  114678. * rgb is tint
  114679. * a is a thickness factor
  114680. */
  114681. tintTexture: Nullable<BaseTexture>;
  114682. /** @hidden */
  114683. private _internalMarkAllSubMeshesAsTexturesDirty;
  114684. /** @hidden */
  114685. _markAllSubMeshesAsTexturesDirty(): void;
  114686. /**
  114687. * Instantiate a new istance of clear coat configuration.
  114688. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114689. */
  114690. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114691. /**
  114692. * Gets wehter the submesh is ready to be used or not.
  114693. * @param defines the list of "defines" to update.
  114694. * @param scene defines the scene the material belongs to.
  114695. * @param engine defines the engine the material belongs to.
  114696. * @param disableBumpMap defines wether the material disables bump or not.
  114697. * @returns - boolean indicating that the submesh is ready or not.
  114698. */
  114699. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114700. /**
  114701. * Checks to see if a texture is used in the material.
  114702. * @param defines the list of "defines" to update.
  114703. * @param scene defines the scene to the material belongs to.
  114704. */
  114705. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114706. /**
  114707. * Binds the material data.
  114708. * @param uniformBuffer defines the Uniform buffer to fill in.
  114709. * @param scene defines the scene the material belongs to.
  114710. * @param engine defines the engine the material belongs to.
  114711. * @param disableBumpMap defines wether the material disables bump or not.
  114712. * @param isFrozen defines wether the material is frozen or not.
  114713. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114714. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114715. */
  114716. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114717. /**
  114718. * Checks to see if a texture is used in the material.
  114719. * @param texture - Base texture to use.
  114720. * @returns - Boolean specifying if a texture is used in the material.
  114721. */
  114722. hasTexture(texture: BaseTexture): boolean;
  114723. /**
  114724. * Returns an array of the actively used textures.
  114725. * @param activeTextures Array of BaseTextures
  114726. */
  114727. getActiveTextures(activeTextures: BaseTexture[]): void;
  114728. /**
  114729. * Returns the animatable textures.
  114730. * @param animatables Array of animatable textures.
  114731. */
  114732. getAnimatables(animatables: IAnimatable[]): void;
  114733. /**
  114734. * Disposes the resources of the material.
  114735. * @param forceDisposeTextures - Forces the disposal of all textures.
  114736. */
  114737. dispose(forceDisposeTextures?: boolean): void;
  114738. /**
  114739. * Get the current class name of the texture useful for serialization or dynamic coding.
  114740. * @returns "PBRClearCoatConfiguration"
  114741. */
  114742. getClassName(): string;
  114743. /**
  114744. * Add fallbacks to the effect fallbacks list.
  114745. * @param defines defines the Base texture to use.
  114746. * @param fallbacks defines the current fallback list.
  114747. * @param currentRank defines the current fallback rank.
  114748. * @returns the new fallback rank.
  114749. */
  114750. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114751. /**
  114752. * Add the required uniforms to the current list.
  114753. * @param uniforms defines the current uniform list.
  114754. */
  114755. static AddUniforms(uniforms: string[]): void;
  114756. /**
  114757. * Add the required samplers to the current list.
  114758. * @param samplers defines the current sampler list.
  114759. */
  114760. static AddSamplers(samplers: string[]): void;
  114761. /**
  114762. * Add the required uniforms to the current buffer.
  114763. * @param uniformBuffer defines the current uniform buffer.
  114764. */
  114765. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114766. /**
  114767. * Makes a duplicate of the current configuration into another one.
  114768. * @param clearCoatConfiguration define the config where to copy the info
  114769. */
  114770. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114771. /**
  114772. * Serializes this clear coat configuration.
  114773. * @returns - An object with the serialized config.
  114774. */
  114775. serialize(): any;
  114776. /**
  114777. * Parses a anisotropy Configuration from a serialized object.
  114778. * @param source - Serialized object.
  114779. * @param scene Defines the scene we are parsing for
  114780. * @param rootUrl Defines the rootUrl to load from
  114781. */
  114782. parse(source: any, scene: Scene, rootUrl: string): void;
  114783. }
  114784. }
  114785. declare module BABYLON {
  114786. /**
  114787. * @hidden
  114788. */
  114789. export interface IMaterialAnisotropicDefines {
  114790. ANISOTROPIC: boolean;
  114791. ANISOTROPIC_TEXTURE: boolean;
  114792. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114793. MAINUV1: boolean;
  114794. _areTexturesDirty: boolean;
  114795. _needUVs: boolean;
  114796. }
  114797. /**
  114798. * Define the code related to the anisotropic parameters of the pbr material.
  114799. */
  114800. export class PBRAnisotropicConfiguration {
  114801. private _isEnabled;
  114802. /**
  114803. * Defines if the anisotropy is enabled in the material.
  114804. */
  114805. isEnabled: boolean;
  114806. /**
  114807. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114808. */
  114809. intensity: number;
  114810. /**
  114811. * Defines if the effect is along the tangents, bitangents or in between.
  114812. * By default, the effect is "strectching" the highlights along the tangents.
  114813. */
  114814. direction: Vector2;
  114815. private _texture;
  114816. /**
  114817. * Stores the anisotropy values in a texture.
  114818. * rg is direction (like normal from -1 to 1)
  114819. * b is a intensity
  114820. */
  114821. texture: Nullable<BaseTexture>;
  114822. /** @hidden */
  114823. private _internalMarkAllSubMeshesAsTexturesDirty;
  114824. /** @hidden */
  114825. _markAllSubMeshesAsTexturesDirty(): void;
  114826. /**
  114827. * Instantiate a new istance of anisotropy configuration.
  114828. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114829. */
  114830. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114831. /**
  114832. * Specifies that the submesh is ready to be used.
  114833. * @param defines the list of "defines" to update.
  114834. * @param scene defines the scene the material belongs to.
  114835. * @returns - boolean indicating that the submesh is ready or not.
  114836. */
  114837. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114838. /**
  114839. * Checks to see if a texture is used in the material.
  114840. * @param defines the list of "defines" to update.
  114841. * @param mesh the mesh we are preparing the defines for.
  114842. * @param scene defines the scene the material belongs to.
  114843. */
  114844. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114845. /**
  114846. * Binds the material data.
  114847. * @param uniformBuffer defines the Uniform buffer to fill in.
  114848. * @param scene defines the scene the material belongs to.
  114849. * @param isFrozen defines wether the material is frozen or not.
  114850. */
  114851. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114852. /**
  114853. * Checks to see if a texture is used in the material.
  114854. * @param texture - Base texture to use.
  114855. * @returns - Boolean specifying if a texture is used in the material.
  114856. */
  114857. hasTexture(texture: BaseTexture): boolean;
  114858. /**
  114859. * Returns an array of the actively used textures.
  114860. * @param activeTextures Array of BaseTextures
  114861. */
  114862. getActiveTextures(activeTextures: BaseTexture[]): void;
  114863. /**
  114864. * Returns the animatable textures.
  114865. * @param animatables Array of animatable textures.
  114866. */
  114867. getAnimatables(animatables: IAnimatable[]): void;
  114868. /**
  114869. * Disposes the resources of the material.
  114870. * @param forceDisposeTextures - Forces the disposal of all textures.
  114871. */
  114872. dispose(forceDisposeTextures?: boolean): void;
  114873. /**
  114874. * Get the current class name of the texture useful for serialization or dynamic coding.
  114875. * @returns "PBRAnisotropicConfiguration"
  114876. */
  114877. getClassName(): string;
  114878. /**
  114879. * Add fallbacks to the effect fallbacks list.
  114880. * @param defines defines the Base texture to use.
  114881. * @param fallbacks defines the current fallback list.
  114882. * @param currentRank defines the current fallback rank.
  114883. * @returns the new fallback rank.
  114884. */
  114885. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114886. /**
  114887. * Add the required uniforms to the current list.
  114888. * @param uniforms defines the current uniform list.
  114889. */
  114890. static AddUniforms(uniforms: string[]): void;
  114891. /**
  114892. * Add the required uniforms to the current buffer.
  114893. * @param uniformBuffer defines the current uniform buffer.
  114894. */
  114895. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114896. /**
  114897. * Add the required samplers to the current list.
  114898. * @param samplers defines the current sampler list.
  114899. */
  114900. static AddSamplers(samplers: string[]): void;
  114901. /**
  114902. * Makes a duplicate of the current configuration into another one.
  114903. * @param anisotropicConfiguration define the config where to copy the info
  114904. */
  114905. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114906. /**
  114907. * Serializes this anisotropy configuration.
  114908. * @returns - An object with the serialized config.
  114909. */
  114910. serialize(): any;
  114911. /**
  114912. * Parses a anisotropy Configuration from a serialized object.
  114913. * @param source - Serialized object.
  114914. * @param scene Defines the scene we are parsing for
  114915. * @param rootUrl Defines the rootUrl to load from
  114916. */
  114917. parse(source: any, scene: Scene, rootUrl: string): void;
  114918. }
  114919. }
  114920. declare module BABYLON {
  114921. /**
  114922. * @hidden
  114923. */
  114924. export interface IMaterialBRDFDefines {
  114925. BRDF_V_HEIGHT_CORRELATED: boolean;
  114926. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114927. SPHERICAL_HARMONICS: boolean;
  114928. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114929. /** @hidden */
  114930. _areMiscDirty: boolean;
  114931. }
  114932. /**
  114933. * Define the code related to the BRDF parameters of the pbr material.
  114934. */
  114935. export class PBRBRDFConfiguration {
  114936. /**
  114937. * Default value used for the energy conservation.
  114938. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114939. */
  114940. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114941. /**
  114942. * Default value used for the Smith Visibility Height Correlated mode.
  114943. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114944. */
  114945. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114946. /**
  114947. * Default value used for the IBL diffuse part.
  114948. * This can help switching back to the polynomials mode globally which is a tiny bit
  114949. * less GPU intensive at the drawback of a lower quality.
  114950. */
  114951. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114952. /**
  114953. * Default value used for activating energy conservation for the specular workflow.
  114954. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114955. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114956. */
  114957. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114958. private _useEnergyConservation;
  114959. /**
  114960. * Defines if the material uses energy conservation.
  114961. */
  114962. useEnergyConservation: boolean;
  114963. private _useSmithVisibilityHeightCorrelated;
  114964. /**
  114965. * LEGACY Mode set to false
  114966. * Defines if the material uses height smith correlated visibility term.
  114967. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114968. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114969. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114970. * Not relying on height correlated will also disable energy conservation.
  114971. */
  114972. useSmithVisibilityHeightCorrelated: boolean;
  114973. private _useSphericalHarmonics;
  114974. /**
  114975. * LEGACY Mode set to false
  114976. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114977. * diffuse part of the IBL.
  114978. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114979. * to the ground truth.
  114980. */
  114981. useSphericalHarmonics: boolean;
  114982. private _useSpecularGlossinessInputEnergyConservation;
  114983. /**
  114984. * Defines if the material uses energy conservation, when the specular workflow is active.
  114985. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114986. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114987. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114988. */
  114989. useSpecularGlossinessInputEnergyConservation: boolean;
  114990. /** @hidden */
  114991. private _internalMarkAllSubMeshesAsMiscDirty;
  114992. /** @hidden */
  114993. _markAllSubMeshesAsMiscDirty(): void;
  114994. /**
  114995. * Instantiate a new istance of clear coat configuration.
  114996. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114997. */
  114998. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114999. /**
  115000. * Checks to see if a texture is used in the material.
  115001. * @param defines the list of "defines" to update.
  115002. */
  115003. prepareDefines(defines: IMaterialBRDFDefines): void;
  115004. /**
  115005. * Get the current class name of the texture useful for serialization or dynamic coding.
  115006. * @returns "PBRClearCoatConfiguration"
  115007. */
  115008. getClassName(): string;
  115009. /**
  115010. * Makes a duplicate of the current configuration into another one.
  115011. * @param brdfConfiguration define the config where to copy the info
  115012. */
  115013. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115014. /**
  115015. * Serializes this BRDF configuration.
  115016. * @returns - An object with the serialized config.
  115017. */
  115018. serialize(): any;
  115019. /**
  115020. * Parses a anisotropy Configuration from a serialized object.
  115021. * @param source - Serialized object.
  115022. * @param scene Defines the scene we are parsing for
  115023. * @param rootUrl Defines the rootUrl to load from
  115024. */
  115025. parse(source: any, scene: Scene, rootUrl: string): void;
  115026. }
  115027. }
  115028. declare module BABYLON {
  115029. /**
  115030. * @hidden
  115031. */
  115032. export interface IMaterialSheenDefines {
  115033. SHEEN: boolean;
  115034. SHEEN_TEXTURE: boolean;
  115035. SHEEN_TEXTUREDIRECTUV: number;
  115036. SHEEN_LINKWITHALBEDO: boolean;
  115037. /** @hidden */
  115038. _areTexturesDirty: boolean;
  115039. }
  115040. /**
  115041. * Define the code related to the Sheen parameters of the pbr material.
  115042. */
  115043. export class PBRSheenConfiguration {
  115044. private _isEnabled;
  115045. /**
  115046. * Defines if the material uses sheen.
  115047. */
  115048. isEnabled: boolean;
  115049. private _linkSheenWithAlbedo;
  115050. /**
  115051. * Defines if the sheen is linked to the sheen color.
  115052. */
  115053. linkSheenWithAlbedo: boolean;
  115054. /**
  115055. * Defines the sheen intensity.
  115056. */
  115057. intensity: number;
  115058. /**
  115059. * Defines the sheen color.
  115060. */
  115061. color: Color3;
  115062. private _texture;
  115063. /**
  115064. * Stores the sheen tint values in a texture.
  115065. * rgb is tint
  115066. * a is a intensity
  115067. */
  115068. texture: Nullable<BaseTexture>;
  115069. /** @hidden */
  115070. private _internalMarkAllSubMeshesAsTexturesDirty;
  115071. /** @hidden */
  115072. _markAllSubMeshesAsTexturesDirty(): void;
  115073. /**
  115074. * Instantiate a new istance of clear coat configuration.
  115075. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115076. */
  115077. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115078. /**
  115079. * Specifies that the submesh is ready to be used.
  115080. * @param defines the list of "defines" to update.
  115081. * @param scene defines the scene the material belongs to.
  115082. * @returns - boolean indicating that the submesh is ready or not.
  115083. */
  115084. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115085. /**
  115086. * Checks to see if a texture is used in the material.
  115087. * @param defines the list of "defines" to update.
  115088. * @param scene defines the scene the material belongs to.
  115089. */
  115090. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115091. /**
  115092. * Binds the material data.
  115093. * @param uniformBuffer defines the Uniform buffer to fill in.
  115094. * @param scene defines the scene the material belongs to.
  115095. * @param isFrozen defines wether the material is frozen or not.
  115096. */
  115097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115098. /**
  115099. * Checks to see if a texture is used in the material.
  115100. * @param texture - Base texture to use.
  115101. * @returns - Boolean specifying if a texture is used in the material.
  115102. */
  115103. hasTexture(texture: BaseTexture): boolean;
  115104. /**
  115105. * Returns an array of the actively used textures.
  115106. * @param activeTextures Array of BaseTextures
  115107. */
  115108. getActiveTextures(activeTextures: BaseTexture[]): void;
  115109. /**
  115110. * Returns the animatable textures.
  115111. * @param animatables Array of animatable textures.
  115112. */
  115113. getAnimatables(animatables: IAnimatable[]): void;
  115114. /**
  115115. * Disposes the resources of the material.
  115116. * @param forceDisposeTextures - Forces the disposal of all textures.
  115117. */
  115118. dispose(forceDisposeTextures?: boolean): void;
  115119. /**
  115120. * Get the current class name of the texture useful for serialization or dynamic coding.
  115121. * @returns "PBRSheenConfiguration"
  115122. */
  115123. getClassName(): string;
  115124. /**
  115125. * Add fallbacks to the effect fallbacks list.
  115126. * @param defines defines the Base texture to use.
  115127. * @param fallbacks defines the current fallback list.
  115128. * @param currentRank defines the current fallback rank.
  115129. * @returns the new fallback rank.
  115130. */
  115131. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115132. /**
  115133. * Add the required uniforms to the current list.
  115134. * @param uniforms defines the current uniform list.
  115135. */
  115136. static AddUniforms(uniforms: string[]): void;
  115137. /**
  115138. * Add the required uniforms to the current buffer.
  115139. * @param uniformBuffer defines the current uniform buffer.
  115140. */
  115141. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115142. /**
  115143. * Add the required samplers to the current list.
  115144. * @param samplers defines the current sampler list.
  115145. */
  115146. static AddSamplers(samplers: string[]): void;
  115147. /**
  115148. * Makes a duplicate of the current configuration into another one.
  115149. * @param sheenConfiguration define the config where to copy the info
  115150. */
  115151. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115152. /**
  115153. * Serializes this BRDF configuration.
  115154. * @returns - An object with the serialized config.
  115155. */
  115156. serialize(): any;
  115157. /**
  115158. * Parses a anisotropy Configuration from a serialized object.
  115159. * @param source - Serialized object.
  115160. * @param scene Defines the scene we are parsing for
  115161. * @param rootUrl Defines the rootUrl to load from
  115162. */
  115163. parse(source: any, scene: Scene, rootUrl: string): void;
  115164. }
  115165. }
  115166. declare module BABYLON {
  115167. /**
  115168. * @hidden
  115169. */
  115170. export interface IMaterialSubSurfaceDefines {
  115171. SUBSURFACE: boolean;
  115172. SS_REFRACTION: boolean;
  115173. SS_TRANSLUCENCY: boolean;
  115174. SS_SCATERRING: boolean;
  115175. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115176. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115177. SS_REFRACTIONMAP_3D: boolean;
  115178. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115179. SS_LODINREFRACTIONALPHA: boolean;
  115180. SS_GAMMAREFRACTION: boolean;
  115181. SS_RGBDREFRACTION: boolean;
  115182. SS_LINEARSPECULARREFRACTION: boolean;
  115183. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115184. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115185. /** @hidden */
  115186. _areTexturesDirty: boolean;
  115187. }
  115188. /**
  115189. * Define the code related to the sub surface parameters of the pbr material.
  115190. */
  115191. export class PBRSubSurfaceConfiguration {
  115192. private _isRefractionEnabled;
  115193. /**
  115194. * Defines if the refraction is enabled in the material.
  115195. */
  115196. isRefractionEnabled: boolean;
  115197. private _isTranslucencyEnabled;
  115198. /**
  115199. * Defines if the translucency is enabled in the material.
  115200. */
  115201. isTranslucencyEnabled: boolean;
  115202. private _isScatteringEnabled;
  115203. /**
  115204. * Defines the refraction intensity of the material.
  115205. * The refraction when enabled replaces the Diffuse part of the material.
  115206. * The intensity helps transitionning between diffuse and refraction.
  115207. */
  115208. refractionIntensity: number;
  115209. /**
  115210. * Defines the translucency intensity of the material.
  115211. * When translucency has been enabled, this defines how much of the "translucency"
  115212. * is addded to the diffuse part of the material.
  115213. */
  115214. translucencyIntensity: number;
  115215. /**
  115216. * Defines the scattering intensity of the material.
  115217. * When scattering has been enabled, this defines how much of the "scattered light"
  115218. * is addded to the diffuse part of the material.
  115219. */
  115220. scatteringIntensity: number;
  115221. private _thicknessTexture;
  115222. /**
  115223. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115224. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115225. * 0 would mean minimumThickness
  115226. * 1 would mean maximumThickness
  115227. * The other channels might be use as a mask to vary the different effects intensity.
  115228. */
  115229. thicknessTexture: Nullable<BaseTexture>;
  115230. private _refractionTexture;
  115231. /**
  115232. * Defines the texture to use for refraction.
  115233. */
  115234. refractionTexture: Nullable<BaseTexture>;
  115235. private _indexOfRefraction;
  115236. /**
  115237. * Defines the index of refraction used in the material.
  115238. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115239. */
  115240. indexOfRefraction: number;
  115241. private _invertRefractionY;
  115242. /**
  115243. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115244. */
  115245. invertRefractionY: boolean;
  115246. private _linkRefractionWithTransparency;
  115247. /**
  115248. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115249. * Materials half opaque for instance using refraction could benefit from this control.
  115250. */
  115251. linkRefractionWithTransparency: boolean;
  115252. /**
  115253. * Defines the minimum thickness stored in the thickness map.
  115254. * If no thickness map is defined, this value will be used to simulate thickness.
  115255. */
  115256. minimumThickness: number;
  115257. /**
  115258. * Defines the maximum thickness stored in the thickness map.
  115259. */
  115260. maximumThickness: number;
  115261. /**
  115262. * Defines the volume tint of the material.
  115263. * This is used for both translucency and scattering.
  115264. */
  115265. tintColor: Color3;
  115266. /**
  115267. * Defines the distance at which the tint color should be found in the media.
  115268. * This is used for refraction only.
  115269. */
  115270. tintColorAtDistance: number;
  115271. /**
  115272. * Defines how far each channel transmit through the media.
  115273. * It is defined as a color to simplify it selection.
  115274. */
  115275. diffusionDistance: Color3;
  115276. private _useMaskFromThicknessTexture;
  115277. /**
  115278. * Stores the intensity of the different subsurface effects in the thickness texture.
  115279. * * the green channel is the translucency intensity.
  115280. * * the blue channel is the scattering intensity.
  115281. * * the alpha channel is the refraction intensity.
  115282. */
  115283. useMaskFromThicknessTexture: boolean;
  115284. /** @hidden */
  115285. private _internalMarkAllSubMeshesAsTexturesDirty;
  115286. /** @hidden */
  115287. _markAllSubMeshesAsTexturesDirty(): void;
  115288. /**
  115289. * Instantiate a new istance of sub surface configuration.
  115290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115291. */
  115292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115293. /**
  115294. * Gets wehter the submesh is ready to be used or not.
  115295. * @param defines the list of "defines" to update.
  115296. * @param scene defines the scene the material belongs to.
  115297. * @returns - boolean indicating that the submesh is ready or not.
  115298. */
  115299. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115300. /**
  115301. * Checks to see if a texture is used in the material.
  115302. * @param defines the list of "defines" to update.
  115303. * @param scene defines the scene to the material belongs to.
  115304. */
  115305. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115306. /**
  115307. * Binds the material data.
  115308. * @param uniformBuffer defines the Uniform buffer to fill in.
  115309. * @param scene defines the scene the material belongs to.
  115310. * @param engine defines the engine the material belongs to.
  115311. * @param isFrozen defines wether the material is frozen or not.
  115312. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115313. */
  115314. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115315. /**
  115316. * Unbinds the material from the mesh.
  115317. * @param activeEffect defines the effect that should be unbound from.
  115318. * @returns true if unbound, otherwise false
  115319. */
  115320. unbind(activeEffect: Effect): boolean;
  115321. /**
  115322. * Returns the texture used for refraction or null if none is used.
  115323. * @param scene defines the scene the material belongs to.
  115324. * @returns - Refraction texture if present. If no refraction texture and refraction
  115325. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115326. */
  115327. private _getRefractionTexture;
  115328. /**
  115329. * Returns true if alpha blending should be disabled.
  115330. */
  115331. readonly disableAlphaBlending: boolean;
  115332. /**
  115333. * Fills the list of render target textures.
  115334. * @param renderTargets the list of render targets to update
  115335. */
  115336. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115337. /**
  115338. * Checks to see if a texture is used in the material.
  115339. * @param texture - Base texture to use.
  115340. * @returns - Boolean specifying if a texture is used in the material.
  115341. */
  115342. hasTexture(texture: BaseTexture): boolean;
  115343. /**
  115344. * Gets a boolean indicating that current material needs to register RTT
  115345. * @returns true if this uses a render target otherwise false.
  115346. */
  115347. hasRenderTargetTextures(): boolean;
  115348. /**
  115349. * Returns an array of the actively used textures.
  115350. * @param activeTextures Array of BaseTextures
  115351. */
  115352. getActiveTextures(activeTextures: BaseTexture[]): void;
  115353. /**
  115354. * Returns the animatable textures.
  115355. * @param animatables Array of animatable textures.
  115356. */
  115357. getAnimatables(animatables: IAnimatable[]): void;
  115358. /**
  115359. * Disposes the resources of the material.
  115360. * @param forceDisposeTextures - Forces the disposal of all textures.
  115361. */
  115362. dispose(forceDisposeTextures?: boolean): void;
  115363. /**
  115364. * Get the current class name of the texture useful for serialization or dynamic coding.
  115365. * @returns "PBRSubSurfaceConfiguration"
  115366. */
  115367. getClassName(): string;
  115368. /**
  115369. * Add fallbacks to the effect fallbacks list.
  115370. * @param defines defines the Base texture to use.
  115371. * @param fallbacks defines the current fallback list.
  115372. * @param currentRank defines the current fallback rank.
  115373. * @returns the new fallback rank.
  115374. */
  115375. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115376. /**
  115377. * Add the required uniforms to the current list.
  115378. * @param uniforms defines the current uniform list.
  115379. */
  115380. static AddUniforms(uniforms: string[]): void;
  115381. /**
  115382. * Add the required samplers to the current list.
  115383. * @param samplers defines the current sampler list.
  115384. */
  115385. static AddSamplers(samplers: string[]): void;
  115386. /**
  115387. * Add the required uniforms to the current buffer.
  115388. * @param uniformBuffer defines the current uniform buffer.
  115389. */
  115390. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115391. /**
  115392. * Makes a duplicate of the current configuration into another one.
  115393. * @param configuration define the config where to copy the info
  115394. */
  115395. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115396. /**
  115397. * Serializes this Sub Surface configuration.
  115398. * @returns - An object with the serialized config.
  115399. */
  115400. serialize(): any;
  115401. /**
  115402. * Parses a anisotropy Configuration from a serialized object.
  115403. * @param source - Serialized object.
  115404. * @param scene Defines the scene we are parsing for
  115405. * @param rootUrl Defines the rootUrl to load from
  115406. */
  115407. parse(source: any, scene: Scene, rootUrl: string): void;
  115408. }
  115409. }
  115410. declare module BABYLON {
  115411. /** @hidden */
  115412. export var pbrFragmentDeclaration: {
  115413. name: string;
  115414. shader: string;
  115415. };
  115416. }
  115417. declare module BABYLON {
  115418. /** @hidden */
  115419. export var pbrUboDeclaration: {
  115420. name: string;
  115421. shader: string;
  115422. };
  115423. }
  115424. declare module BABYLON {
  115425. /** @hidden */
  115426. export var pbrFragmentExtraDeclaration: {
  115427. name: string;
  115428. shader: string;
  115429. };
  115430. }
  115431. declare module BABYLON {
  115432. /** @hidden */
  115433. export var pbrFragmentSamplersDeclaration: {
  115434. name: string;
  115435. shader: string;
  115436. };
  115437. }
  115438. declare module BABYLON {
  115439. /** @hidden */
  115440. export var pbrHelperFunctions: {
  115441. name: string;
  115442. shader: string;
  115443. };
  115444. }
  115445. declare module BABYLON {
  115446. /** @hidden */
  115447. export var harmonicsFunctions: {
  115448. name: string;
  115449. shader: string;
  115450. };
  115451. }
  115452. declare module BABYLON {
  115453. /** @hidden */
  115454. export var pbrDirectLightingSetupFunctions: {
  115455. name: string;
  115456. shader: string;
  115457. };
  115458. }
  115459. declare module BABYLON {
  115460. /** @hidden */
  115461. export var pbrDirectLightingFalloffFunctions: {
  115462. name: string;
  115463. shader: string;
  115464. };
  115465. }
  115466. declare module BABYLON {
  115467. /** @hidden */
  115468. export var pbrBRDFFunctions: {
  115469. name: string;
  115470. shader: string;
  115471. };
  115472. }
  115473. declare module BABYLON {
  115474. /** @hidden */
  115475. export var pbrDirectLightingFunctions: {
  115476. name: string;
  115477. shader: string;
  115478. };
  115479. }
  115480. declare module BABYLON {
  115481. /** @hidden */
  115482. export var pbrIBLFunctions: {
  115483. name: string;
  115484. shader: string;
  115485. };
  115486. }
  115487. declare module BABYLON {
  115488. /** @hidden */
  115489. export var pbrDebug: {
  115490. name: string;
  115491. shader: string;
  115492. };
  115493. }
  115494. declare module BABYLON {
  115495. /** @hidden */
  115496. export var pbrPixelShader: {
  115497. name: string;
  115498. shader: string;
  115499. };
  115500. }
  115501. declare module BABYLON {
  115502. /** @hidden */
  115503. export var pbrVertexDeclaration: {
  115504. name: string;
  115505. shader: string;
  115506. };
  115507. }
  115508. declare module BABYLON {
  115509. /** @hidden */
  115510. export var pbrVertexShader: {
  115511. name: string;
  115512. shader: string;
  115513. };
  115514. }
  115515. declare module BABYLON {
  115516. /**
  115517. * Manages the defines for the PBR Material.
  115518. * @hidden
  115519. */
  115520. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115521. PBR: boolean;
  115522. MAINUV1: boolean;
  115523. MAINUV2: boolean;
  115524. UV1: boolean;
  115525. UV2: boolean;
  115526. ALBEDO: boolean;
  115527. ALBEDODIRECTUV: number;
  115528. VERTEXCOLOR: boolean;
  115529. AMBIENT: boolean;
  115530. AMBIENTDIRECTUV: number;
  115531. AMBIENTINGRAYSCALE: boolean;
  115532. OPACITY: boolean;
  115533. VERTEXALPHA: boolean;
  115534. OPACITYDIRECTUV: number;
  115535. OPACITYRGB: boolean;
  115536. ALPHATEST: boolean;
  115537. DEPTHPREPASS: boolean;
  115538. ALPHABLEND: boolean;
  115539. ALPHAFROMALBEDO: boolean;
  115540. ALPHATESTVALUE: string;
  115541. SPECULAROVERALPHA: boolean;
  115542. RADIANCEOVERALPHA: boolean;
  115543. ALPHAFRESNEL: boolean;
  115544. LINEARALPHAFRESNEL: boolean;
  115545. PREMULTIPLYALPHA: boolean;
  115546. EMISSIVE: boolean;
  115547. EMISSIVEDIRECTUV: number;
  115548. REFLECTIVITY: boolean;
  115549. REFLECTIVITYDIRECTUV: number;
  115550. SPECULARTERM: boolean;
  115551. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115552. MICROSURFACEAUTOMATIC: boolean;
  115553. LODBASEDMICROSFURACE: boolean;
  115554. MICROSURFACEMAP: boolean;
  115555. MICROSURFACEMAPDIRECTUV: number;
  115556. METALLICWORKFLOW: boolean;
  115557. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115558. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115559. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115560. AOSTOREINMETALMAPRED: boolean;
  115561. METALLICF0FACTORFROMMETALLICMAP: boolean;
  115562. ENVIRONMENTBRDF: boolean;
  115563. ENVIRONMENTBRDF_RGBD: boolean;
  115564. NORMAL: boolean;
  115565. TANGENT: boolean;
  115566. BUMP: boolean;
  115567. BUMPDIRECTUV: number;
  115568. OBJECTSPACE_NORMALMAP: boolean;
  115569. PARALLAX: boolean;
  115570. PARALLAXOCCLUSION: boolean;
  115571. NORMALXYSCALE: boolean;
  115572. LIGHTMAP: boolean;
  115573. LIGHTMAPDIRECTUV: number;
  115574. USELIGHTMAPASSHADOWMAP: boolean;
  115575. GAMMALIGHTMAP: boolean;
  115576. RGBDLIGHTMAP: boolean;
  115577. REFLECTION: boolean;
  115578. REFLECTIONMAP_3D: boolean;
  115579. REFLECTIONMAP_SPHERICAL: boolean;
  115580. REFLECTIONMAP_PLANAR: boolean;
  115581. REFLECTIONMAP_CUBIC: boolean;
  115582. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115583. REFLECTIONMAP_PROJECTION: boolean;
  115584. REFLECTIONMAP_SKYBOX: boolean;
  115585. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115586. REFLECTIONMAP_EXPLICIT: boolean;
  115587. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115588. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115589. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115590. INVERTCUBICMAP: boolean;
  115591. USESPHERICALFROMREFLECTIONMAP: boolean;
  115592. USEIRRADIANCEMAP: boolean;
  115593. SPHERICAL_HARMONICS: boolean;
  115594. USESPHERICALINVERTEX: boolean;
  115595. REFLECTIONMAP_OPPOSITEZ: boolean;
  115596. LODINREFLECTIONALPHA: boolean;
  115597. GAMMAREFLECTION: boolean;
  115598. RGBDREFLECTION: boolean;
  115599. LINEARSPECULARREFLECTION: boolean;
  115600. RADIANCEOCCLUSION: boolean;
  115601. HORIZONOCCLUSION: boolean;
  115602. INSTANCES: boolean;
  115603. NUM_BONE_INFLUENCERS: number;
  115604. BonesPerMesh: number;
  115605. BONETEXTURE: boolean;
  115606. NONUNIFORMSCALING: boolean;
  115607. MORPHTARGETS: boolean;
  115608. MORPHTARGETS_NORMAL: boolean;
  115609. MORPHTARGETS_TANGENT: boolean;
  115610. MORPHTARGETS_UV: boolean;
  115611. NUM_MORPH_INFLUENCERS: number;
  115612. IMAGEPROCESSING: boolean;
  115613. VIGNETTE: boolean;
  115614. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115615. VIGNETTEBLENDMODEOPAQUE: boolean;
  115616. TONEMAPPING: boolean;
  115617. TONEMAPPING_ACES: boolean;
  115618. CONTRAST: boolean;
  115619. COLORCURVES: boolean;
  115620. COLORGRADING: boolean;
  115621. COLORGRADING3D: boolean;
  115622. SAMPLER3DGREENDEPTH: boolean;
  115623. SAMPLER3DBGRMAP: boolean;
  115624. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115625. EXPOSURE: boolean;
  115626. MULTIVIEW: boolean;
  115627. USEPHYSICALLIGHTFALLOFF: boolean;
  115628. USEGLTFLIGHTFALLOFF: boolean;
  115629. TWOSIDEDLIGHTING: boolean;
  115630. SHADOWFLOAT: boolean;
  115631. CLIPPLANE: boolean;
  115632. CLIPPLANE2: boolean;
  115633. CLIPPLANE3: boolean;
  115634. CLIPPLANE4: boolean;
  115635. POINTSIZE: boolean;
  115636. FOG: boolean;
  115637. LOGARITHMICDEPTH: boolean;
  115638. FORCENORMALFORWARD: boolean;
  115639. SPECULARAA: boolean;
  115640. CLEARCOAT: boolean;
  115641. CLEARCOAT_DEFAULTIOR: boolean;
  115642. CLEARCOAT_TEXTURE: boolean;
  115643. CLEARCOAT_TEXTUREDIRECTUV: number;
  115644. CLEARCOAT_BUMP: boolean;
  115645. CLEARCOAT_BUMPDIRECTUV: number;
  115646. CLEARCOAT_TINT: boolean;
  115647. CLEARCOAT_TINT_TEXTURE: boolean;
  115648. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115649. ANISOTROPIC: boolean;
  115650. ANISOTROPIC_TEXTURE: boolean;
  115651. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115652. BRDF_V_HEIGHT_CORRELATED: boolean;
  115653. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115654. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115655. SHEEN: boolean;
  115656. SHEEN_TEXTURE: boolean;
  115657. SHEEN_TEXTUREDIRECTUV: number;
  115658. SHEEN_LINKWITHALBEDO: boolean;
  115659. SUBSURFACE: boolean;
  115660. SS_REFRACTION: boolean;
  115661. SS_TRANSLUCENCY: boolean;
  115662. SS_SCATERRING: boolean;
  115663. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115664. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115665. SS_REFRACTIONMAP_3D: boolean;
  115666. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115667. SS_LODINREFRACTIONALPHA: boolean;
  115668. SS_GAMMAREFRACTION: boolean;
  115669. SS_RGBDREFRACTION: boolean;
  115670. SS_LINEARSPECULARREFRACTION: boolean;
  115671. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115672. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115673. UNLIT: boolean;
  115674. DEBUGMODE: number;
  115675. /**
  115676. * Initializes the PBR Material defines.
  115677. */
  115678. constructor();
  115679. /**
  115680. * Resets the PBR Material defines.
  115681. */
  115682. reset(): void;
  115683. }
  115684. /**
  115685. * The Physically based material base class of BJS.
  115686. *
  115687. * This offers the main features of a standard PBR material.
  115688. * For more information, please refer to the documentation :
  115689. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115690. */
  115691. export abstract class PBRBaseMaterial extends PushMaterial {
  115692. /**
  115693. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115694. */
  115695. static readonly PBRMATERIAL_OPAQUE: number;
  115696. /**
  115697. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115698. */
  115699. static readonly PBRMATERIAL_ALPHATEST: number;
  115700. /**
  115701. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115702. */
  115703. static readonly PBRMATERIAL_ALPHABLEND: number;
  115704. /**
  115705. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115706. * They are also discarded below the alpha cutoff threshold to improve performances.
  115707. */
  115708. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115709. /**
  115710. * Defines the default value of how much AO map is occluding the analytical lights
  115711. * (point spot...).
  115712. */
  115713. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115714. /**
  115715. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115716. */
  115717. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115718. /**
  115719. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115720. * to enhance interoperability with other engines.
  115721. */
  115722. static readonly LIGHTFALLOFF_GLTF: number;
  115723. /**
  115724. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115725. * to enhance interoperability with other materials.
  115726. */
  115727. static readonly LIGHTFALLOFF_STANDARD: number;
  115728. /**
  115729. * Intensity of the direct lights e.g. the four lights available in your scene.
  115730. * This impacts both the direct diffuse and specular highlights.
  115731. */
  115732. protected _directIntensity: number;
  115733. /**
  115734. * Intensity of the emissive part of the material.
  115735. * This helps controlling the emissive effect without modifying the emissive color.
  115736. */
  115737. protected _emissiveIntensity: number;
  115738. /**
  115739. * Intensity of the environment e.g. how much the environment will light the object
  115740. * either through harmonics for rough material or through the refelction for shiny ones.
  115741. */
  115742. protected _environmentIntensity: number;
  115743. /**
  115744. * This is a special control allowing the reduction of the specular highlights coming from the
  115745. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115746. */
  115747. protected _specularIntensity: number;
  115748. /**
  115749. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115750. */
  115751. private _lightingInfos;
  115752. /**
  115753. * Debug Control allowing disabling the bump map on this material.
  115754. */
  115755. protected _disableBumpMap: boolean;
  115756. /**
  115757. * AKA Diffuse Texture in standard nomenclature.
  115758. */
  115759. protected _albedoTexture: Nullable<BaseTexture>;
  115760. /**
  115761. * AKA Occlusion Texture in other nomenclature.
  115762. */
  115763. protected _ambientTexture: Nullable<BaseTexture>;
  115764. /**
  115765. * AKA Occlusion Texture Intensity in other nomenclature.
  115766. */
  115767. protected _ambientTextureStrength: number;
  115768. /**
  115769. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115770. * 1 means it completely occludes it
  115771. * 0 mean it has no impact
  115772. */
  115773. protected _ambientTextureImpactOnAnalyticalLights: number;
  115774. /**
  115775. * Stores the alpha values in a texture.
  115776. */
  115777. protected _opacityTexture: Nullable<BaseTexture>;
  115778. /**
  115779. * Stores the reflection values in a texture.
  115780. */
  115781. protected _reflectionTexture: Nullable<BaseTexture>;
  115782. /**
  115783. * Stores the emissive values in a texture.
  115784. */
  115785. protected _emissiveTexture: Nullable<BaseTexture>;
  115786. /**
  115787. * AKA Specular texture in other nomenclature.
  115788. */
  115789. protected _reflectivityTexture: Nullable<BaseTexture>;
  115790. /**
  115791. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115792. */
  115793. protected _metallicTexture: Nullable<BaseTexture>;
  115794. /**
  115795. * Specifies the metallic scalar of the metallic/roughness workflow.
  115796. * Can also be used to scale the metalness values of the metallic texture.
  115797. */
  115798. protected _metallic: Nullable<number>;
  115799. /**
  115800. * Specifies the roughness scalar of the metallic/roughness workflow.
  115801. * Can also be used to scale the roughness values of the metallic texture.
  115802. */
  115803. protected _roughness: Nullable<number>;
  115804. /**
  115805. * Specifies the an F0 factor to help configuring the material F0.
  115806. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  115807. * to 0.5 the previously hard coded value stays the same.
  115808. * Can also be used to scale the F0 values of the metallic texture.
  115809. */
  115810. protected _metallicF0Factor: number;
  115811. /**
  115812. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  115813. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  115814. * your expectation as it multiplies with the texture data.
  115815. */
  115816. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  115817. /**
  115818. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115819. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115820. */
  115821. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115822. /**
  115823. * Stores surface normal data used to displace a mesh in a texture.
  115824. */
  115825. protected _bumpTexture: Nullable<BaseTexture>;
  115826. /**
  115827. * Stores the pre-calculated light information of a mesh in a texture.
  115828. */
  115829. protected _lightmapTexture: Nullable<BaseTexture>;
  115830. /**
  115831. * The color of a material in ambient lighting.
  115832. */
  115833. protected _ambientColor: Color3;
  115834. /**
  115835. * AKA Diffuse Color in other nomenclature.
  115836. */
  115837. protected _albedoColor: Color3;
  115838. /**
  115839. * AKA Specular Color in other nomenclature.
  115840. */
  115841. protected _reflectivityColor: Color3;
  115842. /**
  115843. * The color applied when light is reflected from a material.
  115844. */
  115845. protected _reflectionColor: Color3;
  115846. /**
  115847. * The color applied when light is emitted from a material.
  115848. */
  115849. protected _emissiveColor: Color3;
  115850. /**
  115851. * AKA Glossiness in other nomenclature.
  115852. */
  115853. protected _microSurface: number;
  115854. /**
  115855. * Specifies that the material will use the light map as a show map.
  115856. */
  115857. protected _useLightmapAsShadowmap: boolean;
  115858. /**
  115859. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115860. * makes the reflect vector face the model (under horizon).
  115861. */
  115862. protected _useHorizonOcclusion: boolean;
  115863. /**
  115864. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115865. * too much the area relying on ambient texture to define their ambient occlusion.
  115866. */
  115867. protected _useRadianceOcclusion: boolean;
  115868. /**
  115869. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115870. */
  115871. protected _useAlphaFromAlbedoTexture: boolean;
  115872. /**
  115873. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115874. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115875. */
  115876. protected _useSpecularOverAlpha: boolean;
  115877. /**
  115878. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115879. */
  115880. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115881. /**
  115882. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115883. */
  115884. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115885. /**
  115886. * Specifies if the metallic texture contains the roughness information in its green channel.
  115887. */
  115888. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115889. /**
  115890. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115891. */
  115892. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115893. /**
  115894. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115895. */
  115896. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115897. /**
  115898. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115899. */
  115900. protected _useAmbientInGrayScale: boolean;
  115901. /**
  115902. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115903. * The material will try to infer what glossiness each pixel should be.
  115904. */
  115905. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115906. /**
  115907. * Defines the falloff type used in this material.
  115908. * It by default is Physical.
  115909. */
  115910. protected _lightFalloff: number;
  115911. /**
  115912. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115913. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115914. */
  115915. protected _useRadianceOverAlpha: boolean;
  115916. /**
  115917. * Allows using an object space normal map (instead of tangent space).
  115918. */
  115919. protected _useObjectSpaceNormalMap: boolean;
  115920. /**
  115921. * Allows using the bump map in parallax mode.
  115922. */
  115923. protected _useParallax: boolean;
  115924. /**
  115925. * Allows using the bump map in parallax occlusion mode.
  115926. */
  115927. protected _useParallaxOcclusion: boolean;
  115928. /**
  115929. * Controls the scale bias of the parallax mode.
  115930. */
  115931. protected _parallaxScaleBias: number;
  115932. /**
  115933. * If sets to true, disables all the lights affecting the material.
  115934. */
  115935. protected _disableLighting: boolean;
  115936. /**
  115937. * Number of Simultaneous lights allowed on the material.
  115938. */
  115939. protected _maxSimultaneousLights: number;
  115940. /**
  115941. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115942. */
  115943. protected _invertNormalMapX: boolean;
  115944. /**
  115945. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115946. */
  115947. protected _invertNormalMapY: boolean;
  115948. /**
  115949. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115950. */
  115951. protected _twoSidedLighting: boolean;
  115952. /**
  115953. * Defines the alpha limits in alpha test mode.
  115954. */
  115955. protected _alphaCutOff: number;
  115956. /**
  115957. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115958. */
  115959. protected _forceAlphaTest: boolean;
  115960. /**
  115961. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115962. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115963. */
  115964. protected _useAlphaFresnel: boolean;
  115965. /**
  115966. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115967. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115968. */
  115969. protected _useLinearAlphaFresnel: boolean;
  115970. /**
  115971. * The transparency mode of the material.
  115972. */
  115973. protected _transparencyMode: Nullable<number>;
  115974. /**
  115975. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115976. * from cos thetav and roughness:
  115977. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115978. */
  115979. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115980. /**
  115981. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115982. */
  115983. protected _forceIrradianceInFragment: boolean;
  115984. /**
  115985. * Force normal to face away from face.
  115986. */
  115987. protected _forceNormalForward: boolean;
  115988. /**
  115989. * Enables specular anti aliasing in the PBR shader.
  115990. * It will both interacts on the Geometry for analytical and IBL lighting.
  115991. * It also prefilter the roughness map based on the bump values.
  115992. */
  115993. protected _enableSpecularAntiAliasing: boolean;
  115994. /**
  115995. * Default configuration related to image processing available in the PBR Material.
  115996. */
  115997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115998. /**
  115999. * Keep track of the image processing observer to allow dispose and replace.
  116000. */
  116001. private _imageProcessingObserver;
  116002. /**
  116003. * Attaches a new image processing configuration to the PBR Material.
  116004. * @param configuration
  116005. */
  116006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116007. /**
  116008. * Stores the available render targets.
  116009. */
  116010. private _renderTargets;
  116011. /**
  116012. * Sets the global ambient color for the material used in lighting calculations.
  116013. */
  116014. private _globalAmbientColor;
  116015. /**
  116016. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116017. */
  116018. private _useLogarithmicDepth;
  116019. /**
  116020. * If set to true, no lighting calculations will be applied.
  116021. */
  116022. private _unlit;
  116023. private _debugMode;
  116024. /**
  116025. * @hidden
  116026. * This is reserved for the inspector.
  116027. * Defines the material debug mode.
  116028. * It helps seeing only some components of the material while troubleshooting.
  116029. */
  116030. debugMode: number;
  116031. /**
  116032. * @hidden
  116033. * This is reserved for the inspector.
  116034. * Specify from where on screen the debug mode should start.
  116035. * The value goes from -1 (full screen) to 1 (not visible)
  116036. * It helps with side by side comparison against the final render
  116037. * This defaults to -1
  116038. */
  116039. private debugLimit;
  116040. /**
  116041. * @hidden
  116042. * This is reserved for the inspector.
  116043. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116044. * You can use the factor to better multiply the final value.
  116045. */
  116046. private debugFactor;
  116047. /**
  116048. * Defines the clear coat layer parameters for the material.
  116049. */
  116050. readonly clearCoat: PBRClearCoatConfiguration;
  116051. /**
  116052. * Defines the anisotropic parameters for the material.
  116053. */
  116054. readonly anisotropy: PBRAnisotropicConfiguration;
  116055. /**
  116056. * Defines the BRDF parameters for the material.
  116057. */
  116058. readonly brdf: PBRBRDFConfiguration;
  116059. /**
  116060. * Defines the Sheen parameters for the material.
  116061. */
  116062. readonly sheen: PBRSheenConfiguration;
  116063. /**
  116064. * Defines the SubSurface parameters for the material.
  116065. */
  116066. readonly subSurface: PBRSubSurfaceConfiguration;
  116067. /**
  116068. * Custom callback helping to override the default shader used in the material.
  116069. */
  116070. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116071. protected _rebuildInParallel: boolean;
  116072. /**
  116073. * Instantiates a new PBRMaterial instance.
  116074. *
  116075. * @param name The material name
  116076. * @param scene The scene the material will be use in.
  116077. */
  116078. constructor(name: string, scene: Scene);
  116079. /**
  116080. * Gets a boolean indicating that current material needs to register RTT
  116081. */
  116082. readonly hasRenderTargetTextures: boolean;
  116083. /**
  116084. * Gets the name of the material class.
  116085. */
  116086. getClassName(): string;
  116087. /**
  116088. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116089. */
  116090. /**
  116091. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116092. */
  116093. useLogarithmicDepth: boolean;
  116094. /**
  116095. * Gets the current transparency mode.
  116096. */
  116097. /**
  116098. * Sets the transparency mode of the material.
  116099. *
  116100. * | Value | Type | Description |
  116101. * | ----- | ----------------------------------- | ----------- |
  116102. * | 0 | OPAQUE | |
  116103. * | 1 | ALPHATEST | |
  116104. * | 2 | ALPHABLEND | |
  116105. * | 3 | ALPHATESTANDBLEND | |
  116106. *
  116107. */
  116108. transparencyMode: Nullable<number>;
  116109. /**
  116110. * Returns true if alpha blending should be disabled.
  116111. */
  116112. private readonly _disableAlphaBlending;
  116113. /**
  116114. * Specifies whether or not this material should be rendered in alpha blend mode.
  116115. */
  116116. needAlphaBlending(): boolean;
  116117. /**
  116118. * Specifies if the mesh will require alpha blending.
  116119. * @param mesh - BJS mesh.
  116120. */
  116121. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116122. /**
  116123. * Specifies whether or not this material should be rendered in alpha test mode.
  116124. */
  116125. needAlphaTesting(): boolean;
  116126. /**
  116127. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116128. */
  116129. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116130. /**
  116131. * Gets the texture used for the alpha test.
  116132. */
  116133. getAlphaTestTexture(): Nullable<BaseTexture>;
  116134. /**
  116135. * Specifies that the submesh is ready to be used.
  116136. * @param mesh - BJS mesh.
  116137. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116138. * @param useInstances - Specifies that instances should be used.
  116139. * @returns - boolean indicating that the submesh is ready or not.
  116140. */
  116141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116142. /**
  116143. * Specifies if the material uses metallic roughness workflow.
  116144. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116145. */
  116146. isMetallicWorkflow(): boolean;
  116147. private _prepareEffect;
  116148. private _prepareDefines;
  116149. /**
  116150. * Force shader compilation
  116151. */
  116152. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116153. /**
  116154. * Initializes the uniform buffer layout for the shader.
  116155. */
  116156. buildUniformLayout(): void;
  116157. /**
  116158. * Unbinds the material from the mesh
  116159. */
  116160. unbind(): void;
  116161. /**
  116162. * Binds the submesh data.
  116163. * @param world - The world matrix.
  116164. * @param mesh - The BJS mesh.
  116165. * @param subMesh - A submesh of the BJS mesh.
  116166. */
  116167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116168. /**
  116169. * Returns the animatable textures.
  116170. * @returns - Array of animatable textures.
  116171. */
  116172. getAnimatables(): IAnimatable[];
  116173. /**
  116174. * Returns the texture used for reflections.
  116175. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116176. */
  116177. private _getReflectionTexture;
  116178. /**
  116179. * Returns an array of the actively used textures.
  116180. * @returns - Array of BaseTextures
  116181. */
  116182. getActiveTextures(): BaseTexture[];
  116183. /**
  116184. * Checks to see if a texture is used in the material.
  116185. * @param texture - Base texture to use.
  116186. * @returns - Boolean specifying if a texture is used in the material.
  116187. */
  116188. hasTexture(texture: BaseTexture): boolean;
  116189. /**
  116190. * Disposes the resources of the material.
  116191. * @param forceDisposeEffect - Forces the disposal of effects.
  116192. * @param forceDisposeTextures - Forces the disposal of all textures.
  116193. */
  116194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116195. }
  116196. }
  116197. declare module BABYLON {
  116198. /**
  116199. * The Physically based material of BJS.
  116200. *
  116201. * This offers the main features of a standard PBR material.
  116202. * For more information, please refer to the documentation :
  116203. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116204. */
  116205. export class PBRMaterial extends PBRBaseMaterial {
  116206. /**
  116207. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116208. */
  116209. static readonly PBRMATERIAL_OPAQUE: number;
  116210. /**
  116211. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116212. */
  116213. static readonly PBRMATERIAL_ALPHATEST: number;
  116214. /**
  116215. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116216. */
  116217. static readonly PBRMATERIAL_ALPHABLEND: number;
  116218. /**
  116219. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116220. * They are also discarded below the alpha cutoff threshold to improve performances.
  116221. */
  116222. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116223. /**
  116224. * Defines the default value of how much AO map is occluding the analytical lights
  116225. * (point spot...).
  116226. */
  116227. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116228. /**
  116229. * Intensity of the direct lights e.g. the four lights available in your scene.
  116230. * This impacts both the direct diffuse and specular highlights.
  116231. */
  116232. directIntensity: number;
  116233. /**
  116234. * Intensity of the emissive part of the material.
  116235. * This helps controlling the emissive effect without modifying the emissive color.
  116236. */
  116237. emissiveIntensity: number;
  116238. /**
  116239. * Intensity of the environment e.g. how much the environment will light the object
  116240. * either through harmonics for rough material or through the refelction for shiny ones.
  116241. */
  116242. environmentIntensity: number;
  116243. /**
  116244. * This is a special control allowing the reduction of the specular highlights coming from the
  116245. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116246. */
  116247. specularIntensity: number;
  116248. /**
  116249. * Debug Control allowing disabling the bump map on this material.
  116250. */
  116251. disableBumpMap: boolean;
  116252. /**
  116253. * AKA Diffuse Texture in standard nomenclature.
  116254. */
  116255. albedoTexture: BaseTexture;
  116256. /**
  116257. * AKA Occlusion Texture in other nomenclature.
  116258. */
  116259. ambientTexture: BaseTexture;
  116260. /**
  116261. * AKA Occlusion Texture Intensity in other nomenclature.
  116262. */
  116263. ambientTextureStrength: number;
  116264. /**
  116265. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116266. * 1 means it completely occludes it
  116267. * 0 mean it has no impact
  116268. */
  116269. ambientTextureImpactOnAnalyticalLights: number;
  116270. /**
  116271. * Stores the alpha values in a texture.
  116272. */
  116273. opacityTexture: BaseTexture;
  116274. /**
  116275. * Stores the reflection values in a texture.
  116276. */
  116277. reflectionTexture: Nullable<BaseTexture>;
  116278. /**
  116279. * Stores the emissive values in a texture.
  116280. */
  116281. emissiveTexture: BaseTexture;
  116282. /**
  116283. * AKA Specular texture in other nomenclature.
  116284. */
  116285. reflectivityTexture: BaseTexture;
  116286. /**
  116287. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116288. */
  116289. metallicTexture: BaseTexture;
  116290. /**
  116291. * Specifies the metallic scalar of the metallic/roughness workflow.
  116292. * Can also be used to scale the metalness values of the metallic texture.
  116293. */
  116294. metallic: Nullable<number>;
  116295. /**
  116296. * Specifies the roughness scalar of the metallic/roughness workflow.
  116297. * Can also be used to scale the roughness values of the metallic texture.
  116298. */
  116299. roughness: Nullable<number>;
  116300. /**
  116301. * Specifies the an F0 factor to help configuring the material F0.
  116302. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116303. * to 0.5 the previously hard coded value stays the same.
  116304. * Can also be used to scale the F0 values of the metallic texture.
  116305. */
  116306. metallicF0Factor: number;
  116307. /**
  116308. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116309. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116310. * your expectation as it multiplies with the texture data.
  116311. */
  116312. useMetallicF0FactorFromMetallicTexture: boolean;
  116313. /**
  116314. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116315. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116316. */
  116317. microSurfaceTexture: BaseTexture;
  116318. /**
  116319. * Stores surface normal data used to displace a mesh in a texture.
  116320. */
  116321. bumpTexture: BaseTexture;
  116322. /**
  116323. * Stores the pre-calculated light information of a mesh in a texture.
  116324. */
  116325. lightmapTexture: BaseTexture;
  116326. /**
  116327. * Stores the refracted light information in a texture.
  116328. */
  116329. refractionTexture: Nullable<BaseTexture>;
  116330. /**
  116331. * The color of a material in ambient lighting.
  116332. */
  116333. ambientColor: Color3;
  116334. /**
  116335. * AKA Diffuse Color in other nomenclature.
  116336. */
  116337. albedoColor: Color3;
  116338. /**
  116339. * AKA Specular Color in other nomenclature.
  116340. */
  116341. reflectivityColor: Color3;
  116342. /**
  116343. * The color reflected from the material.
  116344. */
  116345. reflectionColor: Color3;
  116346. /**
  116347. * The color emitted from the material.
  116348. */
  116349. emissiveColor: Color3;
  116350. /**
  116351. * AKA Glossiness in other nomenclature.
  116352. */
  116353. microSurface: number;
  116354. /**
  116355. * source material index of refraction (IOR)' / 'destination material IOR.
  116356. */
  116357. indexOfRefraction: number;
  116358. /**
  116359. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116360. */
  116361. invertRefractionY: boolean;
  116362. /**
  116363. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116364. * Materials half opaque for instance using refraction could benefit from this control.
  116365. */
  116366. linkRefractionWithTransparency: boolean;
  116367. /**
  116368. * If true, the light map contains occlusion information instead of lighting info.
  116369. */
  116370. useLightmapAsShadowmap: boolean;
  116371. /**
  116372. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116373. */
  116374. useAlphaFromAlbedoTexture: boolean;
  116375. /**
  116376. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116377. */
  116378. forceAlphaTest: boolean;
  116379. /**
  116380. * Defines the alpha limits in alpha test mode.
  116381. */
  116382. alphaCutOff: number;
  116383. /**
  116384. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116385. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116386. */
  116387. useSpecularOverAlpha: boolean;
  116388. /**
  116389. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116390. */
  116391. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116392. /**
  116393. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116394. */
  116395. useRoughnessFromMetallicTextureAlpha: boolean;
  116396. /**
  116397. * Specifies if the metallic texture contains the roughness information in its green channel.
  116398. */
  116399. useRoughnessFromMetallicTextureGreen: boolean;
  116400. /**
  116401. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116402. */
  116403. useMetallnessFromMetallicTextureBlue: boolean;
  116404. /**
  116405. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116406. */
  116407. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116408. /**
  116409. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116410. */
  116411. useAmbientInGrayScale: boolean;
  116412. /**
  116413. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116414. * The material will try to infer what glossiness each pixel should be.
  116415. */
  116416. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116417. /**
  116418. * BJS is using an harcoded light falloff based on a manually sets up range.
  116419. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116420. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116421. */
  116422. /**
  116423. * BJS is using an harcoded light falloff based on a manually sets up range.
  116424. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116425. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116426. */
  116427. usePhysicalLightFalloff: boolean;
  116428. /**
  116429. * In order to support the falloff compatibility with gltf, a special mode has been added
  116430. * to reproduce the gltf light falloff.
  116431. */
  116432. /**
  116433. * In order to support the falloff compatibility with gltf, a special mode has been added
  116434. * to reproduce the gltf light falloff.
  116435. */
  116436. useGLTFLightFalloff: boolean;
  116437. /**
  116438. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116439. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116440. */
  116441. useRadianceOverAlpha: boolean;
  116442. /**
  116443. * Allows using an object space normal map (instead of tangent space).
  116444. */
  116445. useObjectSpaceNormalMap: boolean;
  116446. /**
  116447. * Allows using the bump map in parallax mode.
  116448. */
  116449. useParallax: boolean;
  116450. /**
  116451. * Allows using the bump map in parallax occlusion mode.
  116452. */
  116453. useParallaxOcclusion: boolean;
  116454. /**
  116455. * Controls the scale bias of the parallax mode.
  116456. */
  116457. parallaxScaleBias: number;
  116458. /**
  116459. * If sets to true, disables all the lights affecting the material.
  116460. */
  116461. disableLighting: boolean;
  116462. /**
  116463. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116464. */
  116465. forceIrradianceInFragment: boolean;
  116466. /**
  116467. * Number of Simultaneous lights allowed on the material.
  116468. */
  116469. maxSimultaneousLights: number;
  116470. /**
  116471. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116472. */
  116473. invertNormalMapX: boolean;
  116474. /**
  116475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116476. */
  116477. invertNormalMapY: boolean;
  116478. /**
  116479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116480. */
  116481. twoSidedLighting: boolean;
  116482. /**
  116483. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116484. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116485. */
  116486. useAlphaFresnel: boolean;
  116487. /**
  116488. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116489. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116490. */
  116491. useLinearAlphaFresnel: boolean;
  116492. /**
  116493. * Let user defines the brdf lookup texture used for IBL.
  116494. * A default 8bit version is embedded but you could point at :
  116495. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116496. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116497. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116498. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116499. */
  116500. environmentBRDFTexture: Nullable<BaseTexture>;
  116501. /**
  116502. * Force normal to face away from face.
  116503. */
  116504. forceNormalForward: boolean;
  116505. /**
  116506. * Enables specular anti aliasing in the PBR shader.
  116507. * It will both interacts on the Geometry for analytical and IBL lighting.
  116508. * It also prefilter the roughness map based on the bump values.
  116509. */
  116510. enableSpecularAntiAliasing: boolean;
  116511. /**
  116512. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116513. * makes the reflect vector face the model (under horizon).
  116514. */
  116515. useHorizonOcclusion: boolean;
  116516. /**
  116517. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116518. * too much the area relying on ambient texture to define their ambient occlusion.
  116519. */
  116520. useRadianceOcclusion: boolean;
  116521. /**
  116522. * If set to true, no lighting calculations will be applied.
  116523. */
  116524. unlit: boolean;
  116525. /**
  116526. * Gets the image processing configuration used either in this material.
  116527. */
  116528. /**
  116529. * Sets the Default image processing configuration used either in the this material.
  116530. *
  116531. * If sets to null, the scene one is in use.
  116532. */
  116533. imageProcessingConfiguration: ImageProcessingConfiguration;
  116534. /**
  116535. * Gets wether the color curves effect is enabled.
  116536. */
  116537. /**
  116538. * Sets wether the color curves effect is enabled.
  116539. */
  116540. cameraColorCurvesEnabled: boolean;
  116541. /**
  116542. * Gets wether the color grading effect is enabled.
  116543. */
  116544. /**
  116545. * Gets wether the color grading effect is enabled.
  116546. */
  116547. cameraColorGradingEnabled: boolean;
  116548. /**
  116549. * Gets wether tonemapping is enabled or not.
  116550. */
  116551. /**
  116552. * Sets wether tonemapping is enabled or not
  116553. */
  116554. cameraToneMappingEnabled: boolean;
  116555. /**
  116556. * The camera exposure used on this material.
  116557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116558. * This corresponds to a photographic exposure.
  116559. */
  116560. /**
  116561. * The camera exposure used on this material.
  116562. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116563. * This corresponds to a photographic exposure.
  116564. */
  116565. cameraExposure: number;
  116566. /**
  116567. * Gets The camera contrast used on this material.
  116568. */
  116569. /**
  116570. * Sets The camera contrast used on this material.
  116571. */
  116572. cameraContrast: number;
  116573. /**
  116574. * Gets the Color Grading 2D Lookup Texture.
  116575. */
  116576. /**
  116577. * Sets the Color Grading 2D Lookup Texture.
  116578. */
  116579. cameraColorGradingTexture: Nullable<BaseTexture>;
  116580. /**
  116581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116583. * 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;
  116584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116585. */
  116586. /**
  116587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116589. * 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;
  116590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116591. */
  116592. cameraColorCurves: Nullable<ColorCurves>;
  116593. /**
  116594. * Instantiates a new PBRMaterial instance.
  116595. *
  116596. * @param name The material name
  116597. * @param scene The scene the material will be use in.
  116598. */
  116599. constructor(name: string, scene: Scene);
  116600. /**
  116601. * Returns the name of this material class.
  116602. */
  116603. getClassName(): string;
  116604. /**
  116605. * Makes a duplicate of the current material.
  116606. * @param name - name to use for the new material.
  116607. */
  116608. clone(name: string): PBRMaterial;
  116609. /**
  116610. * Serializes this PBR Material.
  116611. * @returns - An object with the serialized material.
  116612. */
  116613. serialize(): any;
  116614. /**
  116615. * Parses a PBR Material from a serialized object.
  116616. * @param source - Serialized object.
  116617. * @param scene - BJS scene instance.
  116618. * @param rootUrl - url for the scene object
  116619. * @returns - PBRMaterial
  116620. */
  116621. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116622. }
  116623. }
  116624. declare module BABYLON {
  116625. /**
  116626. * Direct draw surface info
  116627. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116628. */
  116629. export interface DDSInfo {
  116630. /**
  116631. * Width of the texture
  116632. */
  116633. width: number;
  116634. /**
  116635. * Width of the texture
  116636. */
  116637. height: number;
  116638. /**
  116639. * Number of Mipmaps for the texture
  116640. * @see https://en.wikipedia.org/wiki/Mipmap
  116641. */
  116642. mipmapCount: number;
  116643. /**
  116644. * If the textures format is a known fourCC format
  116645. * @see https://www.fourcc.org/
  116646. */
  116647. isFourCC: boolean;
  116648. /**
  116649. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116650. */
  116651. isRGB: boolean;
  116652. /**
  116653. * If the texture is a lumincance format
  116654. */
  116655. isLuminance: boolean;
  116656. /**
  116657. * If this is a cube texture
  116658. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116659. */
  116660. isCube: boolean;
  116661. /**
  116662. * If the texture is a compressed format eg. FOURCC_DXT1
  116663. */
  116664. isCompressed: boolean;
  116665. /**
  116666. * The dxgiFormat of the texture
  116667. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116668. */
  116669. dxgiFormat: number;
  116670. /**
  116671. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116672. */
  116673. textureType: number;
  116674. /**
  116675. * Sphericle polynomial created for the dds texture
  116676. */
  116677. sphericalPolynomial?: SphericalPolynomial;
  116678. }
  116679. /**
  116680. * Class used to provide DDS decompression tools
  116681. */
  116682. export class DDSTools {
  116683. /**
  116684. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116685. */
  116686. static StoreLODInAlphaChannel: boolean;
  116687. /**
  116688. * Gets DDS information from an array buffer
  116689. * @param arrayBuffer defines the array buffer to read data from
  116690. * @returns the DDS information
  116691. */
  116692. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116693. private static _FloatView;
  116694. private static _Int32View;
  116695. private static _ToHalfFloat;
  116696. private static _FromHalfFloat;
  116697. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116698. private static _GetHalfFloatRGBAArrayBuffer;
  116699. private static _GetFloatRGBAArrayBuffer;
  116700. private static _GetFloatAsUIntRGBAArrayBuffer;
  116701. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116702. private static _GetRGBAArrayBuffer;
  116703. private static _ExtractLongWordOrder;
  116704. private static _GetRGBArrayBuffer;
  116705. private static _GetLuminanceArrayBuffer;
  116706. /**
  116707. * Uploads DDS Levels to a Babylon Texture
  116708. * @hidden
  116709. */
  116710. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116711. }
  116712. interface ThinEngine {
  116713. /**
  116714. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116715. * @param rootUrl defines the url where the file to load is located
  116716. * @param scene defines the current scene
  116717. * @param lodScale defines scale to apply to the mip map selection
  116718. * @param lodOffset defines offset to apply to the mip map selection
  116719. * @param onLoad defines an optional callback raised when the texture is loaded
  116720. * @param onError defines an optional callback raised if there is an issue to load the texture
  116721. * @param format defines the format of the data
  116722. * @param forcedExtension defines the extension to use to pick the right loader
  116723. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116724. * @returns the cube texture as an InternalTexture
  116725. */
  116726. 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;
  116727. }
  116728. }
  116729. declare module BABYLON {
  116730. /**
  116731. * Implementation of the DDS Texture Loader.
  116732. * @hidden
  116733. */
  116734. export class _DDSTextureLoader implements IInternalTextureLoader {
  116735. /**
  116736. * Defines wether the loader supports cascade loading the different faces.
  116737. */
  116738. readonly supportCascades: boolean;
  116739. /**
  116740. * This returns if the loader support the current file information.
  116741. * @param extension defines the file extension of the file being loaded
  116742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116743. * @param fallback defines the fallback internal texture if any
  116744. * @param isBase64 defines whether the texture is encoded as a base64
  116745. * @param isBuffer defines whether the texture data are stored as a buffer
  116746. * @returns true if the loader can load the specified file
  116747. */
  116748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116749. /**
  116750. * Transform the url before loading if required.
  116751. * @param rootUrl the url of the texture
  116752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116753. * @returns the transformed texture
  116754. */
  116755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116756. /**
  116757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116758. * @param rootUrl the url of the texture
  116759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116760. * @returns the fallback texture
  116761. */
  116762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116763. /**
  116764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116765. * @param data contains the texture data
  116766. * @param texture defines the BabylonJS internal texture
  116767. * @param createPolynomials will be true if polynomials have been requested
  116768. * @param onLoad defines the callback to trigger once the texture is ready
  116769. * @param onError defines the callback to trigger in case of error
  116770. */
  116771. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116772. /**
  116773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116774. * @param data contains the texture data
  116775. * @param texture defines the BabylonJS internal texture
  116776. * @param callback defines the method to call once ready to upload
  116777. */
  116778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116779. }
  116780. }
  116781. declare module BABYLON {
  116782. /**
  116783. * Implementation of the ENV Texture Loader.
  116784. * @hidden
  116785. */
  116786. export class _ENVTextureLoader implements IInternalTextureLoader {
  116787. /**
  116788. * Defines wether the loader supports cascade loading the different faces.
  116789. */
  116790. readonly supportCascades: boolean;
  116791. /**
  116792. * This returns if the loader support the current file information.
  116793. * @param extension defines the file extension of the file being loaded
  116794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116795. * @param fallback defines the fallback internal texture if any
  116796. * @param isBase64 defines whether the texture is encoded as a base64
  116797. * @param isBuffer defines whether the texture data are stored as a buffer
  116798. * @returns true if the loader can load the specified file
  116799. */
  116800. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116801. /**
  116802. * Transform the url before loading if required.
  116803. * @param rootUrl the url of the texture
  116804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116805. * @returns the transformed texture
  116806. */
  116807. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116808. /**
  116809. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116810. * @param rootUrl the url of the texture
  116811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116812. * @returns the fallback texture
  116813. */
  116814. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116815. /**
  116816. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116817. * @param data contains the texture data
  116818. * @param texture defines the BabylonJS internal texture
  116819. * @param createPolynomials will be true if polynomials have been requested
  116820. * @param onLoad defines the callback to trigger once the texture is ready
  116821. * @param onError defines the callback to trigger in case of error
  116822. */
  116823. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116824. /**
  116825. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116826. * @param data contains the texture data
  116827. * @param texture defines the BabylonJS internal texture
  116828. * @param callback defines the method to call once ready to upload
  116829. */
  116830. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116831. }
  116832. }
  116833. declare module BABYLON {
  116834. /**
  116835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116837. */
  116838. export class KhronosTextureContainer {
  116839. /** contents of the KTX container file */
  116840. arrayBuffer: any;
  116841. private static HEADER_LEN;
  116842. private static COMPRESSED_2D;
  116843. private static COMPRESSED_3D;
  116844. private static TEX_2D;
  116845. private static TEX_3D;
  116846. /**
  116847. * Gets the openGL type
  116848. */
  116849. glType: number;
  116850. /**
  116851. * Gets the openGL type size
  116852. */
  116853. glTypeSize: number;
  116854. /**
  116855. * Gets the openGL format
  116856. */
  116857. glFormat: number;
  116858. /**
  116859. * Gets the openGL internal format
  116860. */
  116861. glInternalFormat: number;
  116862. /**
  116863. * Gets the base internal format
  116864. */
  116865. glBaseInternalFormat: number;
  116866. /**
  116867. * Gets image width in pixel
  116868. */
  116869. pixelWidth: number;
  116870. /**
  116871. * Gets image height in pixel
  116872. */
  116873. pixelHeight: number;
  116874. /**
  116875. * Gets image depth in pixels
  116876. */
  116877. pixelDepth: number;
  116878. /**
  116879. * Gets the number of array elements
  116880. */
  116881. numberOfArrayElements: number;
  116882. /**
  116883. * Gets the number of faces
  116884. */
  116885. numberOfFaces: number;
  116886. /**
  116887. * Gets the number of mipmap levels
  116888. */
  116889. numberOfMipmapLevels: number;
  116890. /**
  116891. * Gets the bytes of key value data
  116892. */
  116893. bytesOfKeyValueData: number;
  116894. /**
  116895. * Gets the load type
  116896. */
  116897. loadType: number;
  116898. /**
  116899. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116900. */
  116901. isInvalid: boolean;
  116902. /**
  116903. * Creates a new KhronosTextureContainer
  116904. * @param arrayBuffer contents of the KTX container file
  116905. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116906. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116907. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116908. */
  116909. constructor(
  116910. /** contents of the KTX container file */
  116911. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116912. /**
  116913. * Uploads KTX content to a Babylon Texture.
  116914. * It is assumed that the texture has already been created & is currently bound
  116915. * @hidden
  116916. */
  116917. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116918. private _upload2DCompressedLevels;
  116919. }
  116920. }
  116921. declare module BABYLON {
  116922. /**
  116923. * Implementation of the KTX Texture Loader.
  116924. * @hidden
  116925. */
  116926. export class _KTXTextureLoader implements IInternalTextureLoader {
  116927. /**
  116928. * Defines wether the loader supports cascade loading the different faces.
  116929. */
  116930. readonly supportCascades: boolean;
  116931. /**
  116932. * This returns if the loader support the current file information.
  116933. * @param extension defines the file extension of the file being loaded
  116934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116935. * @param fallback defines the fallback internal texture if any
  116936. * @param isBase64 defines whether the texture is encoded as a base64
  116937. * @param isBuffer defines whether the texture data are stored as a buffer
  116938. * @returns true if the loader can load the specified file
  116939. */
  116940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116941. /**
  116942. * Transform the url before loading if required.
  116943. * @param rootUrl the url of the texture
  116944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116945. * @returns the transformed texture
  116946. */
  116947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116948. /**
  116949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116950. * @param rootUrl the url of the texture
  116951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116952. * @returns the fallback texture
  116953. */
  116954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116955. /**
  116956. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116957. * @param data contains the texture data
  116958. * @param texture defines the BabylonJS internal texture
  116959. * @param createPolynomials will be true if polynomials have been requested
  116960. * @param onLoad defines the callback to trigger once the texture is ready
  116961. * @param onError defines the callback to trigger in case of error
  116962. */
  116963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116964. /**
  116965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116966. * @param data contains the texture data
  116967. * @param texture defines the BabylonJS internal texture
  116968. * @param callback defines the method to call once ready to upload
  116969. */
  116970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116971. }
  116972. }
  116973. declare module BABYLON {
  116974. /**
  116975. * Options for the default xr helper
  116976. */
  116977. export class WebXRDefaultExperienceOptions {
  116978. /**
  116979. * Floor meshes that should be used for teleporting
  116980. */
  116981. floorMeshes: Array<AbstractMesh>;
  116982. /**
  116983. * Enable or disable default UI to enter XR
  116984. */
  116985. disableDefaultUI: boolean;
  116986. }
  116987. /**
  116988. * Default experience which provides a similar setup to the previous webVRExperience
  116989. */
  116990. export class WebXRDefaultExperience {
  116991. /**
  116992. * Base experience
  116993. */
  116994. baseExperience: WebXRExperienceHelper;
  116995. /**
  116996. * Input experience extension
  116997. */
  116998. input: WebXRInput;
  116999. /**
  117000. * Loads the controller models
  117001. */
  117002. controllerModelLoader: WebXRControllerModelLoader;
  117003. /**
  117004. * Enables laser pointer and selection
  117005. */
  117006. pointerSelection: WebXRControllerPointerSelection;
  117007. /**
  117008. * Enables teleportation
  117009. */
  117010. teleportation: WebXRControllerTeleportation;
  117011. /**
  117012. * Enables ui for enetering/exiting xr
  117013. */
  117014. enterExitUI: WebXREnterExitUI;
  117015. /**
  117016. * Default target xr should render to
  117017. */
  117018. renderTarget: WebXRRenderTarget;
  117019. /**
  117020. * Creates the default xr experience
  117021. * @param scene scene
  117022. * @param options options for basic configuration
  117023. * @returns resulting WebXRDefaultExperience
  117024. */
  117025. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117026. private constructor();
  117027. /**
  117028. * DIsposes of the experience helper
  117029. */
  117030. dispose(): void;
  117031. }
  117032. }
  117033. declare module BABYLON {
  117034. /** @hidden */
  117035. export var _forceSceneHelpersToBundle: boolean;
  117036. interface Scene {
  117037. /**
  117038. * Creates a default light for the scene.
  117039. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117040. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117041. */
  117042. createDefaultLight(replace?: boolean): void;
  117043. /**
  117044. * Creates a default camera for the scene.
  117045. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117046. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117047. * @param replace has default false, when true replaces the active camera in the scene
  117048. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117049. */
  117050. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117051. /**
  117052. * Creates a default camera and a default light.
  117053. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117054. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117055. * @param replace has the default false, when true replaces the active camera/light in the scene
  117056. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117057. */
  117058. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117059. /**
  117060. * Creates a new sky box
  117061. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117062. * @param environmentTexture defines the texture to use as environment texture
  117063. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117064. * @param scale defines the overall scale of the skybox
  117065. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117066. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117067. * @returns a new mesh holding the sky box
  117068. */
  117069. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117070. /**
  117071. * Creates a new environment
  117072. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117073. * @param options defines the options you can use to configure the environment
  117074. * @returns the new EnvironmentHelper
  117075. */
  117076. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117077. /**
  117078. * Creates a new VREXperienceHelper
  117079. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117080. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117081. * @returns a new VREXperienceHelper
  117082. */
  117083. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117084. /**
  117085. * Creates a new WebXRDefaultExperience
  117086. * @see http://doc.babylonjs.com/how_to/webxr
  117087. * @param options experience options
  117088. * @returns a promise for a new WebXRDefaultExperience
  117089. */
  117090. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117091. }
  117092. }
  117093. declare module BABYLON {
  117094. /**
  117095. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117096. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117097. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117098. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117099. */
  117100. export class VideoDome extends TransformNode {
  117101. /**
  117102. * Define the video source as a Monoscopic panoramic 360 video.
  117103. */
  117104. static readonly MODE_MONOSCOPIC: number;
  117105. /**
  117106. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117107. */
  117108. static readonly MODE_TOPBOTTOM: number;
  117109. /**
  117110. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117111. */
  117112. static readonly MODE_SIDEBYSIDE: number;
  117113. private _halfDome;
  117114. private _useDirectMapping;
  117115. /**
  117116. * The video texture being displayed on the sphere
  117117. */
  117118. protected _videoTexture: VideoTexture;
  117119. /**
  117120. * Gets the video texture being displayed on the sphere
  117121. */
  117122. readonly videoTexture: VideoTexture;
  117123. /**
  117124. * The skybox material
  117125. */
  117126. protected _material: BackgroundMaterial;
  117127. /**
  117128. * The surface used for the skybox
  117129. */
  117130. protected _mesh: Mesh;
  117131. /**
  117132. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117133. */
  117134. private _halfDomeMask;
  117135. /**
  117136. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117137. * Also see the options.resolution property.
  117138. */
  117139. fovMultiplier: number;
  117140. private _videoMode;
  117141. /**
  117142. * Gets or set the current video mode for the video. It can be:
  117143. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117144. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117145. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117146. */
  117147. videoMode: number;
  117148. /**
  117149. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117150. *
  117151. */
  117152. /**
  117153. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117154. */
  117155. halfDome: boolean;
  117156. /**
  117157. * Oberserver used in Stereoscopic VR Mode.
  117158. */
  117159. private _onBeforeCameraRenderObserver;
  117160. /**
  117161. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117162. * @param name Element's name, child elements will append suffixes for their own names.
  117163. * @param urlsOrVideo defines the url(s) or the video element to use
  117164. * @param options An object containing optional or exposed sub element properties
  117165. */
  117166. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117167. resolution?: number;
  117168. clickToPlay?: boolean;
  117169. autoPlay?: boolean;
  117170. loop?: boolean;
  117171. size?: number;
  117172. poster?: string;
  117173. faceForward?: boolean;
  117174. useDirectMapping?: boolean;
  117175. halfDomeMode?: boolean;
  117176. }, scene: Scene);
  117177. private _changeVideoMode;
  117178. /**
  117179. * Releases resources associated with this node.
  117180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117182. */
  117183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117184. }
  117185. }
  117186. declare module BABYLON {
  117187. /**
  117188. * This class can be used to get instrumentation data from a Babylon engine
  117189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117190. */
  117191. export class EngineInstrumentation implements IDisposable {
  117192. /**
  117193. * Define the instrumented engine.
  117194. */
  117195. engine: Engine;
  117196. private _captureGPUFrameTime;
  117197. private _gpuFrameTimeToken;
  117198. private _gpuFrameTime;
  117199. private _captureShaderCompilationTime;
  117200. private _shaderCompilationTime;
  117201. private _onBeginFrameObserver;
  117202. private _onEndFrameObserver;
  117203. private _onBeforeShaderCompilationObserver;
  117204. private _onAfterShaderCompilationObserver;
  117205. /**
  117206. * Gets the perf counter used for GPU frame time
  117207. */
  117208. readonly gpuFrameTimeCounter: PerfCounter;
  117209. /**
  117210. * Gets the GPU frame time capture status
  117211. */
  117212. /**
  117213. * Enable or disable the GPU frame time capture
  117214. */
  117215. captureGPUFrameTime: boolean;
  117216. /**
  117217. * Gets the perf counter used for shader compilation time
  117218. */
  117219. readonly shaderCompilationTimeCounter: PerfCounter;
  117220. /**
  117221. * Gets the shader compilation time capture status
  117222. */
  117223. /**
  117224. * Enable or disable the shader compilation time capture
  117225. */
  117226. captureShaderCompilationTime: boolean;
  117227. /**
  117228. * Instantiates a new engine instrumentation.
  117229. * This class can be used to get instrumentation data from a Babylon engine
  117230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117231. * @param engine Defines the engine to instrument
  117232. */
  117233. constructor(
  117234. /**
  117235. * Define the instrumented engine.
  117236. */
  117237. engine: Engine);
  117238. /**
  117239. * Dispose and release associated resources.
  117240. */
  117241. dispose(): void;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * This class can be used to get instrumentation data from a Babylon engine
  117247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117248. */
  117249. export class SceneInstrumentation implements IDisposable {
  117250. /**
  117251. * Defines the scene to instrument
  117252. */
  117253. scene: Scene;
  117254. private _captureActiveMeshesEvaluationTime;
  117255. private _activeMeshesEvaluationTime;
  117256. private _captureRenderTargetsRenderTime;
  117257. private _renderTargetsRenderTime;
  117258. private _captureFrameTime;
  117259. private _frameTime;
  117260. private _captureRenderTime;
  117261. private _renderTime;
  117262. private _captureInterFrameTime;
  117263. private _interFrameTime;
  117264. private _captureParticlesRenderTime;
  117265. private _particlesRenderTime;
  117266. private _captureSpritesRenderTime;
  117267. private _spritesRenderTime;
  117268. private _capturePhysicsTime;
  117269. private _physicsTime;
  117270. private _captureAnimationsTime;
  117271. private _animationsTime;
  117272. private _captureCameraRenderTime;
  117273. private _cameraRenderTime;
  117274. private _onBeforeActiveMeshesEvaluationObserver;
  117275. private _onAfterActiveMeshesEvaluationObserver;
  117276. private _onBeforeRenderTargetsRenderObserver;
  117277. private _onAfterRenderTargetsRenderObserver;
  117278. private _onAfterRenderObserver;
  117279. private _onBeforeDrawPhaseObserver;
  117280. private _onAfterDrawPhaseObserver;
  117281. private _onBeforeAnimationsObserver;
  117282. private _onBeforeParticlesRenderingObserver;
  117283. private _onAfterParticlesRenderingObserver;
  117284. private _onBeforeSpritesRenderingObserver;
  117285. private _onAfterSpritesRenderingObserver;
  117286. private _onBeforePhysicsObserver;
  117287. private _onAfterPhysicsObserver;
  117288. private _onAfterAnimationsObserver;
  117289. private _onBeforeCameraRenderObserver;
  117290. private _onAfterCameraRenderObserver;
  117291. /**
  117292. * Gets the perf counter used for active meshes evaluation time
  117293. */
  117294. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117295. /**
  117296. * Gets the active meshes evaluation time capture status
  117297. */
  117298. /**
  117299. * Enable or disable the active meshes evaluation time capture
  117300. */
  117301. captureActiveMeshesEvaluationTime: boolean;
  117302. /**
  117303. * Gets the perf counter used for render targets render time
  117304. */
  117305. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117306. /**
  117307. * Gets the render targets render time capture status
  117308. */
  117309. /**
  117310. * Enable or disable the render targets render time capture
  117311. */
  117312. captureRenderTargetsRenderTime: boolean;
  117313. /**
  117314. * Gets the perf counter used for particles render time
  117315. */
  117316. readonly particlesRenderTimeCounter: PerfCounter;
  117317. /**
  117318. * Gets the particles render time capture status
  117319. */
  117320. /**
  117321. * Enable or disable the particles render time capture
  117322. */
  117323. captureParticlesRenderTime: boolean;
  117324. /**
  117325. * Gets the perf counter used for sprites render time
  117326. */
  117327. readonly spritesRenderTimeCounter: PerfCounter;
  117328. /**
  117329. * Gets the sprites render time capture status
  117330. */
  117331. /**
  117332. * Enable or disable the sprites render time capture
  117333. */
  117334. captureSpritesRenderTime: boolean;
  117335. /**
  117336. * Gets the perf counter used for physics time
  117337. */
  117338. readonly physicsTimeCounter: PerfCounter;
  117339. /**
  117340. * Gets the physics time capture status
  117341. */
  117342. /**
  117343. * Enable or disable the physics time capture
  117344. */
  117345. capturePhysicsTime: boolean;
  117346. /**
  117347. * Gets the perf counter used for animations time
  117348. */
  117349. readonly animationsTimeCounter: PerfCounter;
  117350. /**
  117351. * Gets the animations time capture status
  117352. */
  117353. /**
  117354. * Enable or disable the animations time capture
  117355. */
  117356. captureAnimationsTime: boolean;
  117357. /**
  117358. * Gets the perf counter used for frame time capture
  117359. */
  117360. readonly frameTimeCounter: PerfCounter;
  117361. /**
  117362. * Gets the frame time capture status
  117363. */
  117364. /**
  117365. * Enable or disable the frame time capture
  117366. */
  117367. captureFrameTime: boolean;
  117368. /**
  117369. * Gets the perf counter used for inter-frames time capture
  117370. */
  117371. readonly interFrameTimeCounter: PerfCounter;
  117372. /**
  117373. * Gets the inter-frames time capture status
  117374. */
  117375. /**
  117376. * Enable or disable the inter-frames time capture
  117377. */
  117378. captureInterFrameTime: boolean;
  117379. /**
  117380. * Gets the perf counter used for render time capture
  117381. */
  117382. readonly renderTimeCounter: PerfCounter;
  117383. /**
  117384. * Gets the render time capture status
  117385. */
  117386. /**
  117387. * Enable or disable the render time capture
  117388. */
  117389. captureRenderTime: boolean;
  117390. /**
  117391. * Gets the perf counter used for camera render time capture
  117392. */
  117393. readonly cameraRenderTimeCounter: PerfCounter;
  117394. /**
  117395. * Gets the camera render time capture status
  117396. */
  117397. /**
  117398. * Enable or disable the camera render time capture
  117399. */
  117400. captureCameraRenderTime: boolean;
  117401. /**
  117402. * Gets the perf counter used for draw calls
  117403. */
  117404. readonly drawCallsCounter: PerfCounter;
  117405. /**
  117406. * Instantiates a new scene instrumentation.
  117407. * This class can be used to get instrumentation data from a Babylon engine
  117408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117409. * @param scene Defines the scene to instrument
  117410. */
  117411. constructor(
  117412. /**
  117413. * Defines the scene to instrument
  117414. */
  117415. scene: Scene);
  117416. /**
  117417. * Dispose and release associated resources.
  117418. */
  117419. dispose(): void;
  117420. }
  117421. }
  117422. declare module BABYLON {
  117423. /** @hidden */
  117424. export var glowMapGenerationPixelShader: {
  117425. name: string;
  117426. shader: string;
  117427. };
  117428. }
  117429. declare module BABYLON {
  117430. /** @hidden */
  117431. export var glowMapGenerationVertexShader: {
  117432. name: string;
  117433. shader: string;
  117434. };
  117435. }
  117436. declare module BABYLON {
  117437. /**
  117438. * Effect layer options. This helps customizing the behaviour
  117439. * of the effect layer.
  117440. */
  117441. export interface IEffectLayerOptions {
  117442. /**
  117443. * Multiplication factor apply to the canvas size to compute the render target size
  117444. * used to generated the objects (the smaller the faster).
  117445. */
  117446. mainTextureRatio: number;
  117447. /**
  117448. * Enforces a fixed size texture to ensure effect stability across devices.
  117449. */
  117450. mainTextureFixedSize?: number;
  117451. /**
  117452. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117453. */
  117454. alphaBlendingMode: number;
  117455. /**
  117456. * The camera attached to the layer.
  117457. */
  117458. camera: Nullable<Camera>;
  117459. /**
  117460. * The rendering group to draw the layer in.
  117461. */
  117462. renderingGroupId: number;
  117463. }
  117464. /**
  117465. * The effect layer Helps adding post process effect blended with the main pass.
  117466. *
  117467. * This can be for instance use to generate glow or higlight effects on the scene.
  117468. *
  117469. * The effect layer class can not be used directly and is intented to inherited from to be
  117470. * customized per effects.
  117471. */
  117472. export abstract class EffectLayer {
  117473. private _vertexBuffers;
  117474. private _indexBuffer;
  117475. private _cachedDefines;
  117476. private _effectLayerMapGenerationEffect;
  117477. private _effectLayerOptions;
  117478. private _mergeEffect;
  117479. protected _scene: Scene;
  117480. protected _engine: Engine;
  117481. protected _maxSize: number;
  117482. protected _mainTextureDesiredSize: ISize;
  117483. protected _mainTexture: RenderTargetTexture;
  117484. protected _shouldRender: boolean;
  117485. protected _postProcesses: PostProcess[];
  117486. protected _textures: BaseTexture[];
  117487. protected _emissiveTextureAndColor: {
  117488. texture: Nullable<BaseTexture>;
  117489. color: Color4;
  117490. };
  117491. /**
  117492. * The name of the layer
  117493. */
  117494. name: string;
  117495. /**
  117496. * The clear color of the texture used to generate the glow map.
  117497. */
  117498. neutralColor: Color4;
  117499. /**
  117500. * Specifies wether the highlight layer is enabled or not.
  117501. */
  117502. isEnabled: boolean;
  117503. /**
  117504. * Gets the camera attached to the layer.
  117505. */
  117506. readonly camera: Nullable<Camera>;
  117507. /**
  117508. * Gets the rendering group id the layer should render in.
  117509. */
  117510. renderingGroupId: number;
  117511. /**
  117512. * An event triggered when the effect layer has been disposed.
  117513. */
  117514. onDisposeObservable: Observable<EffectLayer>;
  117515. /**
  117516. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117517. */
  117518. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117519. /**
  117520. * An event triggered when the generated texture is being merged in the scene.
  117521. */
  117522. onBeforeComposeObservable: Observable<EffectLayer>;
  117523. /**
  117524. * An event triggered when the mesh is rendered into the effect render target.
  117525. */
  117526. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117527. /**
  117528. * An event triggered after the mesh has been rendered into the effect render target.
  117529. */
  117530. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117531. /**
  117532. * An event triggered when the generated texture has been merged in the scene.
  117533. */
  117534. onAfterComposeObservable: Observable<EffectLayer>;
  117535. /**
  117536. * An event triggered when the efffect layer changes its size.
  117537. */
  117538. onSizeChangedObservable: Observable<EffectLayer>;
  117539. /** @hidden */
  117540. static _SceneComponentInitialization: (scene: Scene) => void;
  117541. /**
  117542. * Instantiates a new effect Layer and references it in the scene.
  117543. * @param name The name of the layer
  117544. * @param scene The scene to use the layer in
  117545. */
  117546. constructor(
  117547. /** The Friendly of the effect in the scene */
  117548. name: string, scene: Scene);
  117549. /**
  117550. * Get the effect name of the layer.
  117551. * @return The effect name
  117552. */
  117553. abstract getEffectName(): string;
  117554. /**
  117555. * Checks for the readiness of the element composing the layer.
  117556. * @param subMesh the mesh to check for
  117557. * @param useInstances specify wether or not to use instances to render the mesh
  117558. * @return true if ready otherwise, false
  117559. */
  117560. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117561. /**
  117562. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117563. * @returns true if the effect requires stencil during the main canvas render pass.
  117564. */
  117565. abstract needStencil(): boolean;
  117566. /**
  117567. * Create the merge effect. This is the shader use to blit the information back
  117568. * to the main canvas at the end of the scene rendering.
  117569. * @returns The effect containing the shader used to merge the effect on the main canvas
  117570. */
  117571. protected abstract _createMergeEffect(): Effect;
  117572. /**
  117573. * Creates the render target textures and post processes used in the effect layer.
  117574. */
  117575. protected abstract _createTextureAndPostProcesses(): void;
  117576. /**
  117577. * Implementation specific of rendering the generating effect on the main canvas.
  117578. * @param effect The effect used to render through
  117579. */
  117580. protected abstract _internalRender(effect: Effect): void;
  117581. /**
  117582. * Sets the required values for both the emissive texture and and the main color.
  117583. */
  117584. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117585. /**
  117586. * Free any resources and references associated to a mesh.
  117587. * Internal use
  117588. * @param mesh The mesh to free.
  117589. */
  117590. abstract _disposeMesh(mesh: Mesh): void;
  117591. /**
  117592. * Serializes this layer (Glow or Highlight for example)
  117593. * @returns a serialized layer object
  117594. */
  117595. abstract serialize?(): any;
  117596. /**
  117597. * Initializes the effect layer with the required options.
  117598. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117599. */
  117600. protected _init(options: Partial<IEffectLayerOptions>): void;
  117601. /**
  117602. * Generates the index buffer of the full screen quad blending to the main canvas.
  117603. */
  117604. private _generateIndexBuffer;
  117605. /**
  117606. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117607. */
  117608. private _generateVertexBuffer;
  117609. /**
  117610. * Sets the main texture desired size which is the closest power of two
  117611. * of the engine canvas size.
  117612. */
  117613. private _setMainTextureSize;
  117614. /**
  117615. * Creates the main texture for the effect layer.
  117616. */
  117617. protected _createMainTexture(): void;
  117618. /**
  117619. * Adds specific effects defines.
  117620. * @param defines The defines to add specifics to.
  117621. */
  117622. protected _addCustomEffectDefines(defines: string[]): void;
  117623. /**
  117624. * Checks for the readiness of the element composing the layer.
  117625. * @param subMesh the mesh to check for
  117626. * @param useInstances specify wether or not to use instances to render the mesh
  117627. * @param emissiveTexture the associated emissive texture used to generate the glow
  117628. * @return true if ready otherwise, false
  117629. */
  117630. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117631. /**
  117632. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117633. */
  117634. render(): void;
  117635. /**
  117636. * Determine if a given mesh will be used in the current effect.
  117637. * @param mesh mesh to test
  117638. * @returns true if the mesh will be used
  117639. */
  117640. hasMesh(mesh: AbstractMesh): boolean;
  117641. /**
  117642. * Returns true if the layer contains information to display, otherwise false.
  117643. * @returns true if the glow layer should be rendered
  117644. */
  117645. shouldRender(): boolean;
  117646. /**
  117647. * Returns true if the mesh should render, otherwise false.
  117648. * @param mesh The mesh to render
  117649. * @returns true if it should render otherwise false
  117650. */
  117651. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117652. /**
  117653. * Returns true if the mesh can be rendered, otherwise false.
  117654. * @param mesh The mesh to render
  117655. * @param material The material used on the mesh
  117656. * @returns true if it can be rendered otherwise false
  117657. */
  117658. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117659. /**
  117660. * Returns true if the mesh should render, otherwise false.
  117661. * @param mesh The mesh to render
  117662. * @returns true if it should render otherwise false
  117663. */
  117664. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117665. /**
  117666. * Renders the submesh passed in parameter to the generation map.
  117667. */
  117668. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117669. /**
  117670. * Defines wether the current material of the mesh should be use to render the effect.
  117671. * @param mesh defines the current mesh to render
  117672. */
  117673. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  117674. /**
  117675. * Rebuild the required buffers.
  117676. * @hidden Internal use only.
  117677. */
  117678. _rebuild(): void;
  117679. /**
  117680. * Dispose only the render target textures and post process.
  117681. */
  117682. private _disposeTextureAndPostProcesses;
  117683. /**
  117684. * Dispose the highlight layer and free resources.
  117685. */
  117686. dispose(): void;
  117687. /**
  117688. * Gets the class name of the effect layer
  117689. * @returns the string with the class name of the effect layer
  117690. */
  117691. getClassName(): string;
  117692. /**
  117693. * Creates an effect layer from parsed effect layer data
  117694. * @param parsedEffectLayer defines effect layer data
  117695. * @param scene defines the current scene
  117696. * @param rootUrl defines the root URL containing the effect layer information
  117697. * @returns a parsed effect Layer
  117698. */
  117699. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117700. }
  117701. }
  117702. declare module BABYLON {
  117703. interface AbstractScene {
  117704. /**
  117705. * The list of effect layers (highlights/glow) added to the scene
  117706. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117707. * @see http://doc.babylonjs.com/how_to/glow_layer
  117708. */
  117709. effectLayers: Array<EffectLayer>;
  117710. /**
  117711. * Removes the given effect layer from this scene.
  117712. * @param toRemove defines the effect layer to remove
  117713. * @returns the index of the removed effect layer
  117714. */
  117715. removeEffectLayer(toRemove: EffectLayer): number;
  117716. /**
  117717. * Adds the given effect layer to this scene
  117718. * @param newEffectLayer defines the effect layer to add
  117719. */
  117720. addEffectLayer(newEffectLayer: EffectLayer): void;
  117721. }
  117722. /**
  117723. * Defines the layer scene component responsible to manage any effect layers
  117724. * in a given scene.
  117725. */
  117726. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117727. /**
  117728. * The component name helpfull to identify the component in the list of scene components.
  117729. */
  117730. readonly name: string;
  117731. /**
  117732. * The scene the component belongs to.
  117733. */
  117734. scene: Scene;
  117735. private _engine;
  117736. private _renderEffects;
  117737. private _needStencil;
  117738. private _previousStencilState;
  117739. /**
  117740. * Creates a new instance of the component for the given scene
  117741. * @param scene Defines the scene to register the component in
  117742. */
  117743. constructor(scene: Scene);
  117744. /**
  117745. * Registers the component in a given scene
  117746. */
  117747. register(): void;
  117748. /**
  117749. * Rebuilds the elements related to this component in case of
  117750. * context lost for instance.
  117751. */
  117752. rebuild(): void;
  117753. /**
  117754. * Serializes the component data to the specified json object
  117755. * @param serializationObject The object to serialize to
  117756. */
  117757. serialize(serializationObject: any): void;
  117758. /**
  117759. * Adds all the elements from the container to the scene
  117760. * @param container the container holding the elements
  117761. */
  117762. addFromContainer(container: AbstractScene): void;
  117763. /**
  117764. * Removes all the elements in the container from the scene
  117765. * @param container contains the elements to remove
  117766. * @param dispose if the removed element should be disposed (default: false)
  117767. */
  117768. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117769. /**
  117770. * Disposes the component and the associated ressources.
  117771. */
  117772. dispose(): void;
  117773. private _isReadyForMesh;
  117774. private _renderMainTexture;
  117775. private _setStencil;
  117776. private _setStencilBack;
  117777. private _draw;
  117778. private _drawCamera;
  117779. private _drawRenderingGroup;
  117780. }
  117781. }
  117782. declare module BABYLON {
  117783. /** @hidden */
  117784. export var glowMapMergePixelShader: {
  117785. name: string;
  117786. shader: string;
  117787. };
  117788. }
  117789. declare module BABYLON {
  117790. /** @hidden */
  117791. export var glowMapMergeVertexShader: {
  117792. name: string;
  117793. shader: string;
  117794. };
  117795. }
  117796. declare module BABYLON {
  117797. interface AbstractScene {
  117798. /**
  117799. * Return a the first highlight layer of the scene with a given name.
  117800. * @param name The name of the highlight layer to look for.
  117801. * @return The highlight layer if found otherwise null.
  117802. */
  117803. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117804. }
  117805. /**
  117806. * Glow layer options. This helps customizing the behaviour
  117807. * of the glow layer.
  117808. */
  117809. export interface IGlowLayerOptions {
  117810. /**
  117811. * Multiplication factor apply to the canvas size to compute the render target size
  117812. * used to generated the glowing objects (the smaller the faster).
  117813. */
  117814. mainTextureRatio: number;
  117815. /**
  117816. * Enforces a fixed size texture to ensure resize independant blur.
  117817. */
  117818. mainTextureFixedSize?: number;
  117819. /**
  117820. * How big is the kernel of the blur texture.
  117821. */
  117822. blurKernelSize: number;
  117823. /**
  117824. * The camera attached to the layer.
  117825. */
  117826. camera: Nullable<Camera>;
  117827. /**
  117828. * Enable MSAA by chosing the number of samples.
  117829. */
  117830. mainTextureSamples?: number;
  117831. /**
  117832. * The rendering group to draw the layer in.
  117833. */
  117834. renderingGroupId: number;
  117835. }
  117836. /**
  117837. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117838. *
  117839. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  117840. *
  117841. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117842. */
  117843. export class GlowLayer extends EffectLayer {
  117844. /**
  117845. * Effect Name of the layer.
  117846. */
  117847. static readonly EffectName: string;
  117848. /**
  117849. * The default blur kernel size used for the glow.
  117850. */
  117851. static DefaultBlurKernelSize: number;
  117852. /**
  117853. * The default texture size ratio used for the glow.
  117854. */
  117855. static DefaultTextureRatio: number;
  117856. /**
  117857. * Sets the kernel size of the blur.
  117858. */
  117859. /**
  117860. * Gets the kernel size of the blur.
  117861. */
  117862. blurKernelSize: number;
  117863. /**
  117864. * Sets the glow intensity.
  117865. */
  117866. /**
  117867. * Gets the glow intensity.
  117868. */
  117869. intensity: number;
  117870. private _options;
  117871. private _intensity;
  117872. private _horizontalBlurPostprocess1;
  117873. private _verticalBlurPostprocess1;
  117874. private _horizontalBlurPostprocess2;
  117875. private _verticalBlurPostprocess2;
  117876. private _blurTexture1;
  117877. private _blurTexture2;
  117878. private _postProcesses1;
  117879. private _postProcesses2;
  117880. private _includedOnlyMeshes;
  117881. private _excludedMeshes;
  117882. private _meshesUsingTheirOwnMaterials;
  117883. /**
  117884. * Callback used to let the user override the color selection on a per mesh basis
  117885. */
  117886. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117887. /**
  117888. * Callback used to let the user override the texture selection on a per mesh basis
  117889. */
  117890. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117891. /**
  117892. * Instantiates a new glow Layer and references it to the scene.
  117893. * @param name The name of the layer
  117894. * @param scene The scene to use the layer in
  117895. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117896. */
  117897. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117898. /**
  117899. * Get the effect name of the layer.
  117900. * @return The effect name
  117901. */
  117902. getEffectName(): string;
  117903. /**
  117904. * Create the merge effect. This is the shader use to blit the information back
  117905. * to the main canvas at the end of the scene rendering.
  117906. */
  117907. protected _createMergeEffect(): Effect;
  117908. /**
  117909. * Creates the render target textures and post processes used in the glow layer.
  117910. */
  117911. protected _createTextureAndPostProcesses(): void;
  117912. /**
  117913. * Checks for the readiness of the element composing the layer.
  117914. * @param subMesh the mesh to check for
  117915. * @param useInstances specify wether or not to use instances to render the mesh
  117916. * @param emissiveTexture the associated emissive texture used to generate the glow
  117917. * @return true if ready otherwise, false
  117918. */
  117919. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117920. /**
  117921. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117922. */
  117923. needStencil(): boolean;
  117924. /**
  117925. * Returns true if the mesh can be rendered, otherwise false.
  117926. * @param mesh The mesh to render
  117927. * @param material The material used on the mesh
  117928. * @returns true if it can be rendered otherwise false
  117929. */
  117930. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117931. /**
  117932. * Implementation specific of rendering the generating effect on the main canvas.
  117933. * @param effect The effect used to render through
  117934. */
  117935. protected _internalRender(effect: Effect): void;
  117936. /**
  117937. * Sets the required values for both the emissive texture and and the main color.
  117938. */
  117939. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117940. /**
  117941. * Returns true if the mesh should render, otherwise false.
  117942. * @param mesh The mesh to render
  117943. * @returns true if it should render otherwise false
  117944. */
  117945. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117946. /**
  117947. * Adds specific effects defines.
  117948. * @param defines The defines to add specifics to.
  117949. */
  117950. protected _addCustomEffectDefines(defines: string[]): void;
  117951. /**
  117952. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117953. * @param mesh The mesh to exclude from the glow layer
  117954. */
  117955. addExcludedMesh(mesh: Mesh): void;
  117956. /**
  117957. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117958. * @param mesh The mesh to remove
  117959. */
  117960. removeExcludedMesh(mesh: Mesh): void;
  117961. /**
  117962. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117963. * @param mesh The mesh to include in the glow layer
  117964. */
  117965. addIncludedOnlyMesh(mesh: Mesh): void;
  117966. /**
  117967. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117968. * @param mesh The mesh to remove
  117969. */
  117970. removeIncludedOnlyMesh(mesh: Mesh): void;
  117971. /**
  117972. * Determine if a given mesh will be used in the glow layer
  117973. * @param mesh The mesh to test
  117974. * @returns true if the mesh will be highlighted by the current glow layer
  117975. */
  117976. hasMesh(mesh: AbstractMesh): boolean;
  117977. /**
  117978. * Defines wether the current material of the mesh should be use to render the effect.
  117979. * @param mesh defines the current mesh to render
  117980. */
  117981. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  117982. /**
  117983. * Add a mesh to be rendered through its own material and not with emissive only.
  117984. * @param mesh The mesh for which we need to use its material
  117985. */
  117986. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  117987. /**
  117988. * Remove a mesh from being rendered through its own material and not with emissive only.
  117989. * @param mesh The mesh for which we need to not use its material
  117990. */
  117991. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  117992. /**
  117993. * Free any resources and references associated to a mesh.
  117994. * Internal use
  117995. * @param mesh The mesh to free.
  117996. * @hidden
  117997. */
  117998. _disposeMesh(mesh: Mesh): void;
  117999. /**
  118000. * Gets the class name of the effect layer
  118001. * @returns the string with the class name of the effect layer
  118002. */
  118003. getClassName(): string;
  118004. /**
  118005. * Serializes this glow layer
  118006. * @returns a serialized glow layer object
  118007. */
  118008. serialize(): any;
  118009. /**
  118010. * Creates a Glow Layer from parsed glow layer data
  118011. * @param parsedGlowLayer defines glow layer data
  118012. * @param scene defines the current scene
  118013. * @param rootUrl defines the root URL containing the glow layer information
  118014. * @returns a parsed Glow Layer
  118015. */
  118016. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118017. }
  118018. }
  118019. declare module BABYLON {
  118020. /** @hidden */
  118021. export var glowBlurPostProcessPixelShader: {
  118022. name: string;
  118023. shader: string;
  118024. };
  118025. }
  118026. declare module BABYLON {
  118027. interface AbstractScene {
  118028. /**
  118029. * Return a the first highlight layer of the scene with a given name.
  118030. * @param name The name of the highlight layer to look for.
  118031. * @return The highlight layer if found otherwise null.
  118032. */
  118033. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118034. }
  118035. /**
  118036. * Highlight layer options. This helps customizing the behaviour
  118037. * of the highlight layer.
  118038. */
  118039. export interface IHighlightLayerOptions {
  118040. /**
  118041. * Multiplication factor apply to the canvas size to compute the render target size
  118042. * used to generated the glowing objects (the smaller the faster).
  118043. */
  118044. mainTextureRatio: number;
  118045. /**
  118046. * Enforces a fixed size texture to ensure resize independant blur.
  118047. */
  118048. mainTextureFixedSize?: number;
  118049. /**
  118050. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118051. * of the picture to blur (the smaller the faster).
  118052. */
  118053. blurTextureSizeRatio: number;
  118054. /**
  118055. * How big in texel of the blur texture is the vertical blur.
  118056. */
  118057. blurVerticalSize: number;
  118058. /**
  118059. * How big in texel of the blur texture is the horizontal blur.
  118060. */
  118061. blurHorizontalSize: number;
  118062. /**
  118063. * Alpha blending mode used to apply the blur. Default is combine.
  118064. */
  118065. alphaBlendingMode: number;
  118066. /**
  118067. * The camera attached to the layer.
  118068. */
  118069. camera: Nullable<Camera>;
  118070. /**
  118071. * Should we display highlight as a solid stroke?
  118072. */
  118073. isStroke?: boolean;
  118074. /**
  118075. * The rendering group to draw the layer in.
  118076. */
  118077. renderingGroupId: number;
  118078. }
  118079. /**
  118080. * The highlight layer Helps adding a glow effect around a mesh.
  118081. *
  118082. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118083. * glowy meshes to your scene.
  118084. *
  118085. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118086. */
  118087. export class HighlightLayer extends EffectLayer {
  118088. name: string;
  118089. /**
  118090. * Effect Name of the highlight layer.
  118091. */
  118092. static readonly EffectName: string;
  118093. /**
  118094. * The neutral color used during the preparation of the glow effect.
  118095. * This is black by default as the blend operation is a blend operation.
  118096. */
  118097. static NeutralColor: Color4;
  118098. /**
  118099. * Stencil value used for glowing meshes.
  118100. */
  118101. static GlowingMeshStencilReference: number;
  118102. /**
  118103. * Stencil value used for the other meshes in the scene.
  118104. */
  118105. static NormalMeshStencilReference: number;
  118106. /**
  118107. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118108. */
  118109. innerGlow: boolean;
  118110. /**
  118111. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118112. */
  118113. outerGlow: boolean;
  118114. /**
  118115. * Specifies the horizontal size of the blur.
  118116. */
  118117. /**
  118118. * Gets the horizontal size of the blur.
  118119. */
  118120. blurHorizontalSize: number;
  118121. /**
  118122. * Specifies the vertical size of the blur.
  118123. */
  118124. /**
  118125. * Gets the vertical size of the blur.
  118126. */
  118127. blurVerticalSize: number;
  118128. /**
  118129. * An event triggered when the highlight layer is being blurred.
  118130. */
  118131. onBeforeBlurObservable: Observable<HighlightLayer>;
  118132. /**
  118133. * An event triggered when the highlight layer has been blurred.
  118134. */
  118135. onAfterBlurObservable: Observable<HighlightLayer>;
  118136. private _instanceGlowingMeshStencilReference;
  118137. private _options;
  118138. private _downSamplePostprocess;
  118139. private _horizontalBlurPostprocess;
  118140. private _verticalBlurPostprocess;
  118141. private _blurTexture;
  118142. private _meshes;
  118143. private _excludedMeshes;
  118144. /**
  118145. * Instantiates a new highlight Layer and references it to the scene..
  118146. * @param name The name of the layer
  118147. * @param scene The scene to use the layer in
  118148. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118149. */
  118150. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118151. /**
  118152. * Get the effect name of the layer.
  118153. * @return The effect name
  118154. */
  118155. getEffectName(): string;
  118156. /**
  118157. * Create the merge effect. This is the shader use to blit the information back
  118158. * to the main canvas at the end of the scene rendering.
  118159. */
  118160. protected _createMergeEffect(): Effect;
  118161. /**
  118162. * Creates the render target textures and post processes used in the highlight layer.
  118163. */
  118164. protected _createTextureAndPostProcesses(): void;
  118165. /**
  118166. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118167. */
  118168. needStencil(): boolean;
  118169. /**
  118170. * Checks for the readiness of the element composing the layer.
  118171. * @param subMesh the mesh to check for
  118172. * @param useInstances specify wether or not to use instances to render the mesh
  118173. * @param emissiveTexture the associated emissive texture used to generate the glow
  118174. * @return true if ready otherwise, false
  118175. */
  118176. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118177. /**
  118178. * Implementation specific of rendering the generating effect on the main canvas.
  118179. * @param effect The effect used to render through
  118180. */
  118181. protected _internalRender(effect: Effect): void;
  118182. /**
  118183. * Returns true if the layer contains information to display, otherwise false.
  118184. */
  118185. shouldRender(): boolean;
  118186. /**
  118187. * Returns true if the mesh should render, otherwise false.
  118188. * @param mesh The mesh to render
  118189. * @returns true if it should render otherwise false
  118190. */
  118191. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118192. /**
  118193. * Sets the required values for both the emissive texture and and the main color.
  118194. */
  118195. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118196. /**
  118197. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118198. * @param mesh The mesh to exclude from the highlight layer
  118199. */
  118200. addExcludedMesh(mesh: Mesh): void;
  118201. /**
  118202. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118203. * @param mesh The mesh to highlight
  118204. */
  118205. removeExcludedMesh(mesh: Mesh): void;
  118206. /**
  118207. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118208. * @param mesh mesh to test
  118209. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118210. */
  118211. hasMesh(mesh: AbstractMesh): boolean;
  118212. /**
  118213. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118214. * @param mesh The mesh to highlight
  118215. * @param color The color of the highlight
  118216. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118217. */
  118218. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118219. /**
  118220. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118221. * @param mesh The mesh to highlight
  118222. */
  118223. removeMesh(mesh: Mesh): void;
  118224. /**
  118225. * Force the stencil to the normal expected value for none glowing parts
  118226. */
  118227. private _defaultStencilReference;
  118228. /**
  118229. * Free any resources and references associated to a mesh.
  118230. * Internal use
  118231. * @param mesh The mesh to free.
  118232. * @hidden
  118233. */
  118234. _disposeMesh(mesh: Mesh): void;
  118235. /**
  118236. * Dispose the highlight layer and free resources.
  118237. */
  118238. dispose(): void;
  118239. /**
  118240. * Gets the class name of the effect layer
  118241. * @returns the string with the class name of the effect layer
  118242. */
  118243. getClassName(): string;
  118244. /**
  118245. * Serializes this Highlight layer
  118246. * @returns a serialized Highlight layer object
  118247. */
  118248. serialize(): any;
  118249. /**
  118250. * Creates a Highlight layer from parsed Highlight layer data
  118251. * @param parsedHightlightLayer defines the Highlight layer data
  118252. * @param scene defines the current scene
  118253. * @param rootUrl defines the root URL containing the Highlight layer information
  118254. * @returns a parsed Highlight layer
  118255. */
  118256. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118257. }
  118258. }
  118259. declare module BABYLON {
  118260. interface AbstractScene {
  118261. /**
  118262. * The list of layers (background and foreground) of the scene
  118263. */
  118264. layers: Array<Layer>;
  118265. }
  118266. /**
  118267. * Defines the layer scene component responsible to manage any layers
  118268. * in a given scene.
  118269. */
  118270. export class LayerSceneComponent implements ISceneComponent {
  118271. /**
  118272. * The component name helpfull to identify the component in the list of scene components.
  118273. */
  118274. readonly name: string;
  118275. /**
  118276. * The scene the component belongs to.
  118277. */
  118278. scene: Scene;
  118279. private _engine;
  118280. /**
  118281. * Creates a new instance of the component for the given scene
  118282. * @param scene Defines the scene to register the component in
  118283. */
  118284. constructor(scene: Scene);
  118285. /**
  118286. * Registers the component in a given scene
  118287. */
  118288. register(): void;
  118289. /**
  118290. * Rebuilds the elements related to this component in case of
  118291. * context lost for instance.
  118292. */
  118293. rebuild(): void;
  118294. /**
  118295. * Disposes the component and the associated ressources.
  118296. */
  118297. dispose(): void;
  118298. private _draw;
  118299. private _drawCameraPredicate;
  118300. private _drawCameraBackground;
  118301. private _drawCameraForeground;
  118302. private _drawRenderTargetPredicate;
  118303. private _drawRenderTargetBackground;
  118304. private _drawRenderTargetForeground;
  118305. /**
  118306. * Adds all the elements from the container to the scene
  118307. * @param container the container holding the elements
  118308. */
  118309. addFromContainer(container: AbstractScene): void;
  118310. /**
  118311. * Removes all the elements in the container from the scene
  118312. * @param container contains the elements to remove
  118313. * @param dispose if the removed element should be disposed (default: false)
  118314. */
  118315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118316. }
  118317. }
  118318. declare module BABYLON {
  118319. /** @hidden */
  118320. export var layerPixelShader: {
  118321. name: string;
  118322. shader: string;
  118323. };
  118324. }
  118325. declare module BABYLON {
  118326. /** @hidden */
  118327. export var layerVertexShader: {
  118328. name: string;
  118329. shader: string;
  118330. };
  118331. }
  118332. declare module BABYLON {
  118333. /**
  118334. * This represents a full screen 2d layer.
  118335. * This can be useful to display a picture in the background of your scene for instance.
  118336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118337. */
  118338. export class Layer {
  118339. /**
  118340. * Define the name of the layer.
  118341. */
  118342. name: string;
  118343. /**
  118344. * Define the texture the layer should display.
  118345. */
  118346. texture: Nullable<Texture>;
  118347. /**
  118348. * Is the layer in background or foreground.
  118349. */
  118350. isBackground: boolean;
  118351. /**
  118352. * Define the color of the layer (instead of texture).
  118353. */
  118354. color: Color4;
  118355. /**
  118356. * Define the scale of the layer in order to zoom in out of the texture.
  118357. */
  118358. scale: Vector2;
  118359. /**
  118360. * Define an offset for the layer in order to shift the texture.
  118361. */
  118362. offset: Vector2;
  118363. /**
  118364. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118365. */
  118366. alphaBlendingMode: number;
  118367. /**
  118368. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118369. * Alpha test will not mix with the background color in case of transparency.
  118370. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118371. */
  118372. alphaTest: boolean;
  118373. /**
  118374. * Define a mask to restrict the layer to only some of the scene cameras.
  118375. */
  118376. layerMask: number;
  118377. /**
  118378. * Define the list of render target the layer is visible into.
  118379. */
  118380. renderTargetTextures: RenderTargetTexture[];
  118381. /**
  118382. * Define if the layer is only used in renderTarget or if it also
  118383. * renders in the main frame buffer of the canvas.
  118384. */
  118385. renderOnlyInRenderTargetTextures: boolean;
  118386. private _scene;
  118387. private _vertexBuffers;
  118388. private _indexBuffer;
  118389. private _effect;
  118390. private _alphaTestEffect;
  118391. /**
  118392. * An event triggered when the layer is disposed.
  118393. */
  118394. onDisposeObservable: Observable<Layer>;
  118395. private _onDisposeObserver;
  118396. /**
  118397. * Back compatibility with callback before the onDisposeObservable existed.
  118398. * The set callback will be triggered when the layer has been disposed.
  118399. */
  118400. onDispose: () => void;
  118401. /**
  118402. * An event triggered before rendering the scene
  118403. */
  118404. onBeforeRenderObservable: Observable<Layer>;
  118405. private _onBeforeRenderObserver;
  118406. /**
  118407. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118408. * The set callback will be triggered just before rendering the layer.
  118409. */
  118410. onBeforeRender: () => void;
  118411. /**
  118412. * An event triggered after rendering the scene
  118413. */
  118414. onAfterRenderObservable: Observable<Layer>;
  118415. private _onAfterRenderObserver;
  118416. /**
  118417. * Back compatibility with callback before the onAfterRenderObservable existed.
  118418. * The set callback will be triggered just after rendering the layer.
  118419. */
  118420. onAfterRender: () => void;
  118421. /**
  118422. * Instantiates a new layer.
  118423. * This represents a full screen 2d layer.
  118424. * This can be useful to display a picture in the background of your scene for instance.
  118425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118426. * @param name Define the name of the layer in the scene
  118427. * @param imgUrl Define the url of the texture to display in the layer
  118428. * @param scene Define the scene the layer belongs to
  118429. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118430. * @param color Defines a color for the layer
  118431. */
  118432. constructor(
  118433. /**
  118434. * Define the name of the layer.
  118435. */
  118436. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118437. private _createIndexBuffer;
  118438. /** @hidden */
  118439. _rebuild(): void;
  118440. /**
  118441. * Renders the layer in the scene.
  118442. */
  118443. render(): void;
  118444. /**
  118445. * Disposes and releases the associated ressources.
  118446. */
  118447. dispose(): void;
  118448. }
  118449. }
  118450. declare module BABYLON {
  118451. /** @hidden */
  118452. export var lensFlarePixelShader: {
  118453. name: string;
  118454. shader: string;
  118455. };
  118456. }
  118457. declare module BABYLON {
  118458. /** @hidden */
  118459. export var lensFlareVertexShader: {
  118460. name: string;
  118461. shader: string;
  118462. };
  118463. }
  118464. declare module BABYLON {
  118465. /**
  118466. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118467. * It is usually composed of several `lensFlare`.
  118468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118469. */
  118470. export class LensFlareSystem {
  118471. /**
  118472. * Define the name of the lens flare system
  118473. */
  118474. name: string;
  118475. /**
  118476. * List of lens flares used in this system.
  118477. */
  118478. lensFlares: LensFlare[];
  118479. /**
  118480. * Define a limit from the border the lens flare can be visible.
  118481. */
  118482. borderLimit: number;
  118483. /**
  118484. * Define a viewport border we do not want to see the lens flare in.
  118485. */
  118486. viewportBorder: number;
  118487. /**
  118488. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118489. */
  118490. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118491. /**
  118492. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118493. */
  118494. layerMask: number;
  118495. /**
  118496. * Define the id of the lens flare system in the scene.
  118497. * (equal to name by default)
  118498. */
  118499. id: string;
  118500. private _scene;
  118501. private _emitter;
  118502. private _vertexBuffers;
  118503. private _indexBuffer;
  118504. private _effect;
  118505. private _positionX;
  118506. private _positionY;
  118507. private _isEnabled;
  118508. /** @hidden */
  118509. static _SceneComponentInitialization: (scene: Scene) => void;
  118510. /**
  118511. * Instantiates a lens flare system.
  118512. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118513. * It is usually composed of several `lensFlare`.
  118514. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118515. * @param name Define the name of the lens flare system in the scene
  118516. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118517. * @param scene Define the scene the lens flare system belongs to
  118518. */
  118519. constructor(
  118520. /**
  118521. * Define the name of the lens flare system
  118522. */
  118523. name: string, emitter: any, scene: Scene);
  118524. /**
  118525. * Define if the lens flare system is enabled.
  118526. */
  118527. isEnabled: boolean;
  118528. /**
  118529. * Get the scene the effects belongs to.
  118530. * @returns the scene holding the lens flare system
  118531. */
  118532. getScene(): Scene;
  118533. /**
  118534. * Get the emitter of the lens flare system.
  118535. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118536. * @returns the emitter of the lens flare system
  118537. */
  118538. getEmitter(): any;
  118539. /**
  118540. * Set the emitter of the lens flare system.
  118541. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118542. * @param newEmitter Define the new emitter of the system
  118543. */
  118544. setEmitter(newEmitter: any): void;
  118545. /**
  118546. * Get the lens flare system emitter position.
  118547. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118548. * @returns the position
  118549. */
  118550. getEmitterPosition(): Vector3;
  118551. /**
  118552. * @hidden
  118553. */
  118554. computeEffectivePosition(globalViewport: Viewport): boolean;
  118555. /** @hidden */
  118556. _isVisible(): boolean;
  118557. /**
  118558. * @hidden
  118559. */
  118560. render(): boolean;
  118561. /**
  118562. * Dispose and release the lens flare with its associated resources.
  118563. */
  118564. dispose(): void;
  118565. /**
  118566. * Parse a lens flare system from a JSON repressentation
  118567. * @param parsedLensFlareSystem Define the JSON to parse
  118568. * @param scene Define the scene the parsed system should be instantiated in
  118569. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118570. * @returns the parsed system
  118571. */
  118572. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118573. /**
  118574. * Serialize the current Lens Flare System into a JSON representation.
  118575. * @returns the serialized JSON
  118576. */
  118577. serialize(): any;
  118578. }
  118579. }
  118580. declare module BABYLON {
  118581. /**
  118582. * This represents one of the lens effect in a `lensFlareSystem`.
  118583. * It controls one of the indiviual texture used in the effect.
  118584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118585. */
  118586. export class LensFlare {
  118587. /**
  118588. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118589. */
  118590. size: number;
  118591. /**
  118592. * 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.
  118593. */
  118594. position: number;
  118595. /**
  118596. * Define the lens color.
  118597. */
  118598. color: Color3;
  118599. /**
  118600. * Define the lens texture.
  118601. */
  118602. texture: Nullable<Texture>;
  118603. /**
  118604. * Define the alpha mode to render this particular lens.
  118605. */
  118606. alphaMode: number;
  118607. private _system;
  118608. /**
  118609. * Creates a new Lens Flare.
  118610. * This represents one of the lens effect in a `lensFlareSystem`.
  118611. * It controls one of the indiviual texture used in the effect.
  118612. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118613. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118614. * @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.
  118615. * @param color Define the lens color
  118616. * @param imgUrl Define the lens texture url
  118617. * @param system Define the `lensFlareSystem` this flare is part of
  118618. * @returns The newly created Lens Flare
  118619. */
  118620. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118621. /**
  118622. * Instantiates a new Lens Flare.
  118623. * This represents one of the lens effect in a `lensFlareSystem`.
  118624. * It controls one of the indiviual texture used in the effect.
  118625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118626. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118627. * @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.
  118628. * @param color Define the lens color
  118629. * @param imgUrl Define the lens texture url
  118630. * @param system Define the `lensFlareSystem` this flare is part of
  118631. */
  118632. constructor(
  118633. /**
  118634. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118635. */
  118636. size: number,
  118637. /**
  118638. * 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.
  118639. */
  118640. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118641. /**
  118642. * Dispose and release the lens flare with its associated resources.
  118643. */
  118644. dispose(): void;
  118645. }
  118646. }
  118647. declare module BABYLON {
  118648. interface AbstractScene {
  118649. /**
  118650. * The list of lens flare system added to the scene
  118651. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118652. */
  118653. lensFlareSystems: Array<LensFlareSystem>;
  118654. /**
  118655. * Removes the given lens flare system from this scene.
  118656. * @param toRemove The lens flare system to remove
  118657. * @returns The index of the removed lens flare system
  118658. */
  118659. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118660. /**
  118661. * Adds the given lens flare system to this scene
  118662. * @param newLensFlareSystem The lens flare system to add
  118663. */
  118664. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118665. /**
  118666. * Gets a lens flare system using its name
  118667. * @param name defines the name to look for
  118668. * @returns the lens flare system or null if not found
  118669. */
  118670. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118671. /**
  118672. * Gets a lens flare system using its id
  118673. * @param id defines the id to look for
  118674. * @returns the lens flare system or null if not found
  118675. */
  118676. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118677. }
  118678. /**
  118679. * Defines the lens flare scene component responsible to manage any lens flares
  118680. * in a given scene.
  118681. */
  118682. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118683. /**
  118684. * The component name helpfull to identify the component in the list of scene components.
  118685. */
  118686. readonly name: string;
  118687. /**
  118688. * The scene the component belongs to.
  118689. */
  118690. scene: Scene;
  118691. /**
  118692. * Creates a new instance of the component for the given scene
  118693. * @param scene Defines the scene to register the component in
  118694. */
  118695. constructor(scene: Scene);
  118696. /**
  118697. * Registers the component in a given scene
  118698. */
  118699. register(): void;
  118700. /**
  118701. * Rebuilds the elements related to this component in case of
  118702. * context lost for instance.
  118703. */
  118704. rebuild(): void;
  118705. /**
  118706. * Adds all the elements from the container to the scene
  118707. * @param container the container holding the elements
  118708. */
  118709. addFromContainer(container: AbstractScene): void;
  118710. /**
  118711. * Removes all the elements in the container from the scene
  118712. * @param container contains the elements to remove
  118713. * @param dispose if the removed element should be disposed (default: false)
  118714. */
  118715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118716. /**
  118717. * Serializes the component data to the specified json object
  118718. * @param serializationObject The object to serialize to
  118719. */
  118720. serialize(serializationObject: any): void;
  118721. /**
  118722. * Disposes the component and the associated ressources.
  118723. */
  118724. dispose(): void;
  118725. private _draw;
  118726. }
  118727. }
  118728. declare module BABYLON {
  118729. /**
  118730. * Defines the shadow generator component responsible to manage any shadow generators
  118731. * in a given scene.
  118732. */
  118733. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118734. /**
  118735. * The component name helpfull to identify the component in the list of scene components.
  118736. */
  118737. readonly name: string;
  118738. /**
  118739. * The scene the component belongs to.
  118740. */
  118741. scene: Scene;
  118742. /**
  118743. * Creates a new instance of the component for the given scene
  118744. * @param scene Defines the scene to register the component in
  118745. */
  118746. constructor(scene: Scene);
  118747. /**
  118748. * Registers the component in a given scene
  118749. */
  118750. register(): void;
  118751. /**
  118752. * Rebuilds the elements related to this component in case of
  118753. * context lost for instance.
  118754. */
  118755. rebuild(): void;
  118756. /**
  118757. * Serializes the component data to the specified json object
  118758. * @param serializationObject The object to serialize to
  118759. */
  118760. serialize(serializationObject: any): void;
  118761. /**
  118762. * Adds all the elements from the container to the scene
  118763. * @param container the container holding the elements
  118764. */
  118765. addFromContainer(container: AbstractScene): void;
  118766. /**
  118767. * Removes all the elements in the container from the scene
  118768. * @param container contains the elements to remove
  118769. * @param dispose if the removed element should be disposed (default: false)
  118770. */
  118771. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118772. /**
  118773. * Rebuilds the elements related to this component in case of
  118774. * context lost for instance.
  118775. */
  118776. dispose(): void;
  118777. private _gatherRenderTargets;
  118778. }
  118779. }
  118780. declare module BABYLON {
  118781. /**
  118782. * A point light is a light defined by an unique point in world space.
  118783. * The light is emitted in every direction from this point.
  118784. * A good example of a point light is a standard light bulb.
  118785. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118786. */
  118787. export class PointLight extends ShadowLight {
  118788. private _shadowAngle;
  118789. /**
  118790. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118791. * This specifies what angle the shadow will use to be created.
  118792. *
  118793. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118794. */
  118795. /**
  118796. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118797. * This specifies what angle the shadow will use to be created.
  118798. *
  118799. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118800. */
  118801. shadowAngle: number;
  118802. /**
  118803. * Gets the direction if it has been set.
  118804. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118805. */
  118806. /**
  118807. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118808. */
  118809. direction: Vector3;
  118810. /**
  118811. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118812. * A PointLight emits the light in every direction.
  118813. * It can cast shadows.
  118814. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118815. * ```javascript
  118816. * var pointLight = new PointLight("pl", camera.position, scene);
  118817. * ```
  118818. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118819. * @param name The light friendly name
  118820. * @param position The position of the point light in the scene
  118821. * @param scene The scene the lights belongs to
  118822. */
  118823. constructor(name: string, position: Vector3, scene: Scene);
  118824. /**
  118825. * Returns the string "PointLight"
  118826. * @returns the class name
  118827. */
  118828. getClassName(): string;
  118829. /**
  118830. * Returns the integer 0.
  118831. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118832. */
  118833. getTypeID(): number;
  118834. /**
  118835. * Specifies wether or not the shadowmap should be a cube texture.
  118836. * @returns true if the shadowmap needs to be a cube texture.
  118837. */
  118838. needCube(): boolean;
  118839. /**
  118840. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118841. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118842. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118843. */
  118844. getShadowDirection(faceIndex?: number): Vector3;
  118845. /**
  118846. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118847. * - fov = PI / 2
  118848. * - aspect ratio : 1.0
  118849. * - z-near and far equal to the active camera minZ and maxZ.
  118850. * Returns the PointLight.
  118851. */
  118852. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118853. protected _buildUniformLayout(): void;
  118854. /**
  118855. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118856. * @param effect The effect to update
  118857. * @param lightIndex The index of the light in the effect to update
  118858. * @returns The point light
  118859. */
  118860. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118861. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118862. /**
  118863. * Prepares the list of defines specific to the light type.
  118864. * @param defines the list of defines
  118865. * @param lightIndex defines the index of the light for the effect
  118866. */
  118867. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118868. }
  118869. }
  118870. declare module BABYLON {
  118871. /**
  118872. * Header information of HDR texture files.
  118873. */
  118874. export interface HDRInfo {
  118875. /**
  118876. * The height of the texture in pixels.
  118877. */
  118878. height: number;
  118879. /**
  118880. * The width of the texture in pixels.
  118881. */
  118882. width: number;
  118883. /**
  118884. * The index of the beginning of the data in the binary file.
  118885. */
  118886. dataPosition: number;
  118887. }
  118888. /**
  118889. * This groups tools to convert HDR texture to native colors array.
  118890. */
  118891. export class HDRTools {
  118892. private static Ldexp;
  118893. private static Rgbe2float;
  118894. private static readStringLine;
  118895. /**
  118896. * Reads header information from an RGBE texture stored in a native array.
  118897. * More information on this format are available here:
  118898. * https://en.wikipedia.org/wiki/RGBE_image_format
  118899. *
  118900. * @param uint8array The binary file stored in native array.
  118901. * @return The header information.
  118902. */
  118903. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118904. /**
  118905. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118906. * This RGBE texture needs to store the information as a panorama.
  118907. *
  118908. * More information on this format are available here:
  118909. * https://en.wikipedia.org/wiki/RGBE_image_format
  118910. *
  118911. * @param buffer The binary file stored in an array buffer.
  118912. * @param size The expected size of the extracted cubemap.
  118913. * @return The Cube Map information.
  118914. */
  118915. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118916. /**
  118917. * Returns the pixels data extracted from an RGBE texture.
  118918. * This pixels will be stored left to right up to down in the R G B order in one array.
  118919. *
  118920. * More information on this format are available here:
  118921. * https://en.wikipedia.org/wiki/RGBE_image_format
  118922. *
  118923. * @param uint8array The binary file stored in an array buffer.
  118924. * @param hdrInfo The header information of the file.
  118925. * @return The pixels data in RGB right to left up to down order.
  118926. */
  118927. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118928. private static RGBE_ReadPixels_RLE;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /**
  118933. * This represents a texture coming from an HDR input.
  118934. *
  118935. * The only supported format is currently panorama picture stored in RGBE format.
  118936. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118937. */
  118938. export class HDRCubeTexture extends BaseTexture {
  118939. private static _facesMapping;
  118940. private _generateHarmonics;
  118941. private _noMipmap;
  118942. private _textureMatrix;
  118943. private _size;
  118944. private _onLoad;
  118945. private _onError;
  118946. /**
  118947. * The texture URL.
  118948. */
  118949. url: string;
  118950. /**
  118951. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118952. */
  118953. coordinatesMode: number;
  118954. protected _isBlocking: boolean;
  118955. /**
  118956. * Sets wether or not the texture is blocking during loading.
  118957. */
  118958. /**
  118959. * Gets wether or not the texture is blocking during loading.
  118960. */
  118961. isBlocking: boolean;
  118962. protected _rotationY: number;
  118963. /**
  118964. * Sets texture matrix rotation angle around Y axis in radians.
  118965. */
  118966. /**
  118967. * Gets texture matrix rotation angle around Y axis radians.
  118968. */
  118969. rotationY: number;
  118970. /**
  118971. * Gets or sets the center of the bounding box associated with the cube texture
  118972. * It must define where the camera used to render the texture was set
  118973. */
  118974. boundingBoxPosition: Vector3;
  118975. private _boundingBoxSize;
  118976. /**
  118977. * Gets or sets the size of the bounding box associated with the cube texture
  118978. * When defined, the cubemap will switch to local mode
  118979. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118980. * @example https://www.babylonjs-playground.com/#RNASML
  118981. */
  118982. boundingBoxSize: Vector3;
  118983. /**
  118984. * Instantiates an HDRTexture from the following parameters.
  118985. *
  118986. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118987. * @param scene The scene the texture will be used in
  118988. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118989. * @param noMipmap Forces to not generate the mipmap if true
  118990. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118991. * @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)
  118992. * @param reserved Reserved flag for internal use.
  118993. */
  118994. 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>);
  118995. /**
  118996. * Get the current class name of the texture useful for serialization or dynamic coding.
  118997. * @returns "HDRCubeTexture"
  118998. */
  118999. getClassName(): string;
  119000. /**
  119001. * Occurs when the file is raw .hdr file.
  119002. */
  119003. private loadTexture;
  119004. clone(): HDRCubeTexture;
  119005. delayLoad(): void;
  119006. /**
  119007. * Get the texture reflection matrix used to rotate/transform the reflection.
  119008. * @returns the reflection matrix
  119009. */
  119010. getReflectionTextureMatrix(): Matrix;
  119011. /**
  119012. * Set the texture reflection matrix used to rotate/transform the reflection.
  119013. * @param value Define the reflection matrix to set
  119014. */
  119015. setReflectionTextureMatrix(value: Matrix): void;
  119016. /**
  119017. * Parses a JSON representation of an HDR Texture in order to create the texture
  119018. * @param parsedTexture Define the JSON representation
  119019. * @param scene Define the scene the texture should be created in
  119020. * @param rootUrl Define the root url in case we need to load relative dependencies
  119021. * @returns the newly created texture after parsing
  119022. */
  119023. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119024. serialize(): any;
  119025. }
  119026. }
  119027. declare module BABYLON {
  119028. /**
  119029. * Class used to control physics engine
  119030. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119031. */
  119032. export class PhysicsEngine implements IPhysicsEngine {
  119033. private _physicsPlugin;
  119034. /**
  119035. * Global value used to control the smallest number supported by the simulation
  119036. */
  119037. static Epsilon: number;
  119038. private _impostors;
  119039. private _joints;
  119040. /**
  119041. * Gets the gravity vector used by the simulation
  119042. */
  119043. gravity: Vector3;
  119044. /**
  119045. * Factory used to create the default physics plugin.
  119046. * @returns The default physics plugin
  119047. */
  119048. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119049. /**
  119050. * Creates a new Physics Engine
  119051. * @param gravity defines the gravity vector used by the simulation
  119052. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119053. */
  119054. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119055. /**
  119056. * Sets the gravity vector used by the simulation
  119057. * @param gravity defines the gravity vector to use
  119058. */
  119059. setGravity(gravity: Vector3): void;
  119060. /**
  119061. * Set the time step of the physics engine.
  119062. * Default is 1/60.
  119063. * To slow it down, enter 1/600 for example.
  119064. * To speed it up, 1/30
  119065. * @param newTimeStep defines the new timestep to apply to this world.
  119066. */
  119067. setTimeStep(newTimeStep?: number): void;
  119068. /**
  119069. * Get the time step of the physics engine.
  119070. * @returns the current time step
  119071. */
  119072. getTimeStep(): number;
  119073. /**
  119074. * Release all resources
  119075. */
  119076. dispose(): void;
  119077. /**
  119078. * Gets the name of the current physics plugin
  119079. * @returns the name of the plugin
  119080. */
  119081. getPhysicsPluginName(): string;
  119082. /**
  119083. * Adding a new impostor for the impostor tracking.
  119084. * This will be done by the impostor itself.
  119085. * @param impostor the impostor to add
  119086. */
  119087. addImpostor(impostor: PhysicsImpostor): void;
  119088. /**
  119089. * Remove an impostor from the engine.
  119090. * This impostor and its mesh will not longer be updated by the physics engine.
  119091. * @param impostor the impostor to remove
  119092. */
  119093. removeImpostor(impostor: PhysicsImpostor): void;
  119094. /**
  119095. * Add a joint to the physics engine
  119096. * @param mainImpostor defines the main impostor to which the joint is added.
  119097. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119098. * @param joint defines the joint that will connect both impostors.
  119099. */
  119100. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119101. /**
  119102. * Removes a joint from the simulation
  119103. * @param mainImpostor defines the impostor used with the joint
  119104. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119105. * @param joint defines the joint to remove
  119106. */
  119107. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119108. /**
  119109. * Called by the scene. No need to call it.
  119110. * @param delta defines the timespam between frames
  119111. */
  119112. _step(delta: number): void;
  119113. /**
  119114. * Gets the current plugin used to run the simulation
  119115. * @returns current plugin
  119116. */
  119117. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119118. /**
  119119. * Gets the list of physic impostors
  119120. * @returns an array of PhysicsImpostor
  119121. */
  119122. getImpostors(): Array<PhysicsImpostor>;
  119123. /**
  119124. * Gets the impostor for a physics enabled object
  119125. * @param object defines the object impersonated by the impostor
  119126. * @returns the PhysicsImpostor or null if not found
  119127. */
  119128. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119129. /**
  119130. * Gets the impostor for a physics body object
  119131. * @param body defines physics body used by the impostor
  119132. * @returns the PhysicsImpostor or null if not found
  119133. */
  119134. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119135. /**
  119136. * Does a raycast in the physics world
  119137. * @param from when should the ray start?
  119138. * @param to when should the ray end?
  119139. * @returns PhysicsRaycastResult
  119140. */
  119141. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /** @hidden */
  119146. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119147. private _useDeltaForWorldStep;
  119148. world: any;
  119149. name: string;
  119150. private _physicsMaterials;
  119151. private _fixedTimeStep;
  119152. private _cannonRaycastResult;
  119153. private _raycastResult;
  119154. private _physicsBodysToRemoveAfterStep;
  119155. BJSCANNON: any;
  119156. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119157. setGravity(gravity: Vector3): void;
  119158. setTimeStep(timeStep: number): void;
  119159. getTimeStep(): number;
  119160. executeStep(delta: number): void;
  119161. private _removeMarkedPhysicsBodiesFromWorld;
  119162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119165. private _processChildMeshes;
  119166. removePhysicsBody(impostor: PhysicsImpostor): void;
  119167. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119169. private _addMaterial;
  119170. private _checkWithEpsilon;
  119171. private _createShape;
  119172. private _createHeightmap;
  119173. private _minus90X;
  119174. private _plus90X;
  119175. private _tmpPosition;
  119176. private _tmpDeltaPosition;
  119177. private _tmpUnityRotation;
  119178. private _updatePhysicsBodyTransformation;
  119179. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119180. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119181. isSupported(): boolean;
  119182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119187. getBodyMass(impostor: PhysicsImpostor): number;
  119188. getBodyFriction(impostor: PhysicsImpostor): number;
  119189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119190. getBodyRestitution(impostor: PhysicsImpostor): number;
  119191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119192. sleepBody(impostor: PhysicsImpostor): void;
  119193. wakeUpBody(impostor: PhysicsImpostor): void;
  119194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119195. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119197. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119198. getRadius(impostor: PhysicsImpostor): number;
  119199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119200. dispose(): void;
  119201. private _extendNamespace;
  119202. /**
  119203. * Does a raycast in the physics world
  119204. * @param from when should the ray start?
  119205. * @param to when should the ray end?
  119206. * @returns PhysicsRaycastResult
  119207. */
  119208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119209. }
  119210. }
  119211. declare module BABYLON {
  119212. /** @hidden */
  119213. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119214. world: any;
  119215. name: string;
  119216. BJSOIMO: any;
  119217. private _raycastResult;
  119218. constructor(iterations?: number, oimoInjection?: any);
  119219. setGravity(gravity: Vector3): void;
  119220. setTimeStep(timeStep: number): void;
  119221. getTimeStep(): number;
  119222. private _tmpImpostorsArray;
  119223. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119224. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119225. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119226. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119227. private _tmpPositionVector;
  119228. removePhysicsBody(impostor: PhysicsImpostor): void;
  119229. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119230. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119231. isSupported(): boolean;
  119232. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119233. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119234. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119235. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119236. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119237. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119238. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119239. getBodyMass(impostor: PhysicsImpostor): number;
  119240. getBodyFriction(impostor: PhysicsImpostor): number;
  119241. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119242. getBodyRestitution(impostor: PhysicsImpostor): number;
  119243. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119244. sleepBody(impostor: PhysicsImpostor): void;
  119245. wakeUpBody(impostor: PhysicsImpostor): void;
  119246. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119247. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119249. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119250. getRadius(impostor: PhysicsImpostor): number;
  119251. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119252. dispose(): void;
  119253. /**
  119254. * Does a raycast in the physics world
  119255. * @param from when should the ray start?
  119256. * @param to when should the ray end?
  119257. * @returns PhysicsRaycastResult
  119258. */
  119259. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119260. }
  119261. }
  119262. declare module BABYLON {
  119263. /**
  119264. * Class containing static functions to help procedurally build meshes
  119265. */
  119266. export class RibbonBuilder {
  119267. /**
  119268. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119269. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119270. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119271. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119272. * * 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
  119273. * * 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
  119274. * * 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
  119275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119278. * * 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
  119279. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119280. * * 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
  119281. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119283. * @param name defines the name of the mesh
  119284. * @param options defines the options used to create the mesh
  119285. * @param scene defines the hosting scene
  119286. * @returns the ribbon mesh
  119287. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119289. */
  119290. static CreateRibbon(name: string, options: {
  119291. pathArray: Vector3[][];
  119292. closeArray?: boolean;
  119293. closePath?: boolean;
  119294. offset?: number;
  119295. updatable?: boolean;
  119296. sideOrientation?: number;
  119297. frontUVs?: Vector4;
  119298. backUVs?: Vector4;
  119299. instance?: Mesh;
  119300. invertUV?: boolean;
  119301. uvs?: Vector2[];
  119302. colors?: Color4[];
  119303. }, scene?: Nullable<Scene>): Mesh;
  119304. }
  119305. }
  119306. declare module BABYLON {
  119307. /**
  119308. * Class containing static functions to help procedurally build meshes
  119309. */
  119310. export class ShapeBuilder {
  119311. /**
  119312. * 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.
  119313. * * 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.
  119314. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119315. * * 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.
  119316. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119317. * * 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
  119318. * * 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
  119319. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119324. * @param name defines the name of the mesh
  119325. * @param options defines the options used to create the mesh
  119326. * @param scene defines the hosting scene
  119327. * @returns the extruded shape mesh
  119328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119330. */
  119331. static ExtrudeShape(name: string, options: {
  119332. shape: Vector3[];
  119333. path: Vector3[];
  119334. scale?: number;
  119335. rotation?: number;
  119336. cap?: number;
  119337. updatable?: boolean;
  119338. sideOrientation?: number;
  119339. frontUVs?: Vector4;
  119340. backUVs?: Vector4;
  119341. instance?: Mesh;
  119342. invertUV?: boolean;
  119343. }, scene?: Nullable<Scene>): Mesh;
  119344. /**
  119345. * Creates an custom extruded shape mesh.
  119346. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119347. * * 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.
  119348. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119349. * * 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
  119350. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119351. * * 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
  119352. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119353. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119354. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119355. * * 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
  119356. * * 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
  119357. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119362. * @param name defines the name of the mesh
  119363. * @param options defines the options used to create the mesh
  119364. * @param scene defines the hosting scene
  119365. * @returns the custom extruded shape mesh
  119366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119369. */
  119370. static ExtrudeShapeCustom(name: string, options: {
  119371. shape: Vector3[];
  119372. path: Vector3[];
  119373. scaleFunction?: any;
  119374. rotationFunction?: any;
  119375. ribbonCloseArray?: boolean;
  119376. ribbonClosePath?: boolean;
  119377. cap?: number;
  119378. updatable?: boolean;
  119379. sideOrientation?: number;
  119380. frontUVs?: Vector4;
  119381. backUVs?: Vector4;
  119382. instance?: Mesh;
  119383. invertUV?: boolean;
  119384. }, scene?: Nullable<Scene>): Mesh;
  119385. private static _ExtrudeShapeGeneric;
  119386. }
  119387. }
  119388. declare module BABYLON {
  119389. /**
  119390. * AmmoJS Physics plugin
  119391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119392. * @see https://github.com/kripken/ammo.js/
  119393. */
  119394. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119395. private _useDeltaForWorldStep;
  119396. /**
  119397. * Reference to the Ammo library
  119398. */
  119399. bjsAMMO: any;
  119400. /**
  119401. * Created ammoJS world which physics bodies are added to
  119402. */
  119403. world: any;
  119404. /**
  119405. * Name of the plugin
  119406. */
  119407. name: string;
  119408. private _timeStep;
  119409. private _fixedTimeStep;
  119410. private _maxSteps;
  119411. private _tmpQuaternion;
  119412. private _tmpAmmoTransform;
  119413. private _tmpAmmoQuaternion;
  119414. private _tmpAmmoConcreteContactResultCallback;
  119415. private _collisionConfiguration;
  119416. private _dispatcher;
  119417. private _overlappingPairCache;
  119418. private _solver;
  119419. private _softBodySolver;
  119420. private _tmpAmmoVectorA;
  119421. private _tmpAmmoVectorB;
  119422. private _tmpAmmoVectorC;
  119423. private _tmpAmmoVectorD;
  119424. private _tmpContactCallbackResult;
  119425. private _tmpAmmoVectorRCA;
  119426. private _tmpAmmoVectorRCB;
  119427. private _raycastResult;
  119428. private static readonly DISABLE_COLLISION_FLAG;
  119429. private static readonly KINEMATIC_FLAG;
  119430. private static readonly DISABLE_DEACTIVATION_FLAG;
  119431. /**
  119432. * Initializes the ammoJS plugin
  119433. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119434. * @param ammoInjection can be used to inject your own ammo reference
  119435. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119436. */
  119437. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119438. /**
  119439. * Sets the gravity of the physics world (m/(s^2))
  119440. * @param gravity Gravity to set
  119441. */
  119442. setGravity(gravity: Vector3): void;
  119443. /**
  119444. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119445. * @param timeStep timestep to use in seconds
  119446. */
  119447. setTimeStep(timeStep: number): void;
  119448. /**
  119449. * 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)
  119450. * @param fixedTimeStep fixedTimeStep to use in seconds
  119451. */
  119452. setFixedTimeStep(fixedTimeStep: number): void;
  119453. /**
  119454. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119455. * @param maxSteps the maximum number of steps by the physics engine per frame
  119456. */
  119457. setMaxSteps(maxSteps: number): void;
  119458. /**
  119459. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119460. * @returns the current timestep in seconds
  119461. */
  119462. getTimeStep(): number;
  119463. private _isImpostorInContact;
  119464. private _isImpostorPairInContact;
  119465. private _stepSimulation;
  119466. /**
  119467. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119468. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119469. * After the step the babylon meshes are set to the position of the physics imposters
  119470. * @param delta amount of time to step forward
  119471. * @param impostors array of imposters to update before/after the step
  119472. */
  119473. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119474. /**
  119475. * Update babylon mesh to match physics world object
  119476. * @param impostor imposter to match
  119477. */
  119478. private _afterSoftStep;
  119479. /**
  119480. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119481. * @param impostor imposter to match
  119482. */
  119483. private _ropeStep;
  119484. /**
  119485. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119486. * @param impostor imposter to match
  119487. */
  119488. private _softbodyOrClothStep;
  119489. private _tmpVector;
  119490. private _tmpMatrix;
  119491. /**
  119492. * Applies an impulse on the imposter
  119493. * @param impostor imposter to apply impulse to
  119494. * @param force amount of force to be applied to the imposter
  119495. * @param contactPoint the location to apply the impulse on the imposter
  119496. */
  119497. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119498. /**
  119499. * Applies a force on the imposter
  119500. * @param impostor imposter to apply force
  119501. * @param force amount of force to be applied to the imposter
  119502. * @param contactPoint the location to apply the force on the imposter
  119503. */
  119504. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119505. /**
  119506. * Creates a physics body using the plugin
  119507. * @param impostor the imposter to create the physics body on
  119508. */
  119509. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119510. /**
  119511. * Removes the physics body from the imposter and disposes of the body's memory
  119512. * @param impostor imposter to remove the physics body from
  119513. */
  119514. removePhysicsBody(impostor: PhysicsImpostor): void;
  119515. /**
  119516. * Generates a joint
  119517. * @param impostorJoint the imposter joint to create the joint with
  119518. */
  119519. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119520. /**
  119521. * Removes a joint
  119522. * @param impostorJoint the imposter joint to remove the joint from
  119523. */
  119524. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119525. private _addMeshVerts;
  119526. /**
  119527. * Initialise the soft body vertices to match its object's (mesh) vertices
  119528. * Softbody vertices (nodes) are in world space and to match this
  119529. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119530. * @param impostor to create the softbody for
  119531. */
  119532. private _softVertexData;
  119533. /**
  119534. * Create an impostor's soft body
  119535. * @param impostor to create the softbody for
  119536. */
  119537. private _createSoftbody;
  119538. /**
  119539. * Create cloth for an impostor
  119540. * @param impostor to create the softbody for
  119541. */
  119542. private _createCloth;
  119543. /**
  119544. * Create rope for an impostor
  119545. * @param impostor to create the softbody for
  119546. */
  119547. private _createRope;
  119548. private _addHullVerts;
  119549. private _createShape;
  119550. /**
  119551. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119552. * @param impostor imposter containing the physics body and babylon object
  119553. */
  119554. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119555. /**
  119556. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119557. * @param impostor imposter containing the physics body and babylon object
  119558. * @param newPosition new position
  119559. * @param newRotation new rotation
  119560. */
  119561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119562. /**
  119563. * If this plugin is supported
  119564. * @returns true if its supported
  119565. */
  119566. isSupported(): boolean;
  119567. /**
  119568. * Sets the linear velocity of the physics body
  119569. * @param impostor imposter to set the velocity on
  119570. * @param velocity velocity to set
  119571. */
  119572. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119573. /**
  119574. * Sets the angular velocity of the physics body
  119575. * @param impostor imposter to set the velocity on
  119576. * @param velocity velocity to set
  119577. */
  119578. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119579. /**
  119580. * gets the linear velocity
  119581. * @param impostor imposter to get linear velocity from
  119582. * @returns linear velocity
  119583. */
  119584. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119585. /**
  119586. * gets the angular velocity
  119587. * @param impostor imposter to get angular velocity from
  119588. * @returns angular velocity
  119589. */
  119590. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119591. /**
  119592. * Sets the mass of physics body
  119593. * @param impostor imposter to set the mass on
  119594. * @param mass mass to set
  119595. */
  119596. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119597. /**
  119598. * Gets the mass of the physics body
  119599. * @param impostor imposter to get the mass from
  119600. * @returns mass
  119601. */
  119602. getBodyMass(impostor: PhysicsImpostor): number;
  119603. /**
  119604. * Gets friction of the impostor
  119605. * @param impostor impostor to get friction from
  119606. * @returns friction value
  119607. */
  119608. getBodyFriction(impostor: PhysicsImpostor): number;
  119609. /**
  119610. * Sets friction of the impostor
  119611. * @param impostor impostor to set friction on
  119612. * @param friction friction value
  119613. */
  119614. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119615. /**
  119616. * Gets restitution of the impostor
  119617. * @param impostor impostor to get restitution from
  119618. * @returns restitution value
  119619. */
  119620. getBodyRestitution(impostor: PhysicsImpostor): number;
  119621. /**
  119622. * Sets resitution of the impostor
  119623. * @param impostor impostor to set resitution on
  119624. * @param restitution resitution value
  119625. */
  119626. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119627. /**
  119628. * Gets pressure inside the impostor
  119629. * @param impostor impostor to get pressure from
  119630. * @returns pressure value
  119631. */
  119632. getBodyPressure(impostor: PhysicsImpostor): number;
  119633. /**
  119634. * Sets pressure inside a soft body impostor
  119635. * Cloth and rope must remain 0 pressure
  119636. * @param impostor impostor to set pressure on
  119637. * @param pressure pressure value
  119638. */
  119639. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119640. /**
  119641. * Gets stiffness of the impostor
  119642. * @param impostor impostor to get stiffness from
  119643. * @returns pressure value
  119644. */
  119645. getBodyStiffness(impostor: PhysicsImpostor): number;
  119646. /**
  119647. * Sets stiffness of the impostor
  119648. * @param impostor impostor to set stiffness on
  119649. * @param stiffness stiffness value from 0 to 1
  119650. */
  119651. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119652. /**
  119653. * Gets velocityIterations of the impostor
  119654. * @param impostor impostor to get velocity iterations from
  119655. * @returns velocityIterations value
  119656. */
  119657. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119658. /**
  119659. * Sets velocityIterations of the impostor
  119660. * @param impostor impostor to set velocity iterations on
  119661. * @param velocityIterations velocityIterations value
  119662. */
  119663. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119664. /**
  119665. * Gets positionIterations of the impostor
  119666. * @param impostor impostor to get position iterations from
  119667. * @returns positionIterations value
  119668. */
  119669. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119670. /**
  119671. * Sets positionIterations of the impostor
  119672. * @param impostor impostor to set position on
  119673. * @param positionIterations positionIterations value
  119674. */
  119675. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119676. /**
  119677. * Append an anchor to a cloth object
  119678. * @param impostor is the cloth impostor to add anchor to
  119679. * @param otherImpostor is the rigid impostor to anchor to
  119680. * @param width ratio across width from 0 to 1
  119681. * @param height ratio up height from 0 to 1
  119682. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119683. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119684. */
  119685. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119686. /**
  119687. * Append an hook to a rope object
  119688. * @param impostor is the rope impostor to add hook to
  119689. * @param otherImpostor is the rigid impostor to hook to
  119690. * @param length ratio along the rope from 0 to 1
  119691. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119692. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119693. */
  119694. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119695. /**
  119696. * Sleeps the physics body and stops it from being active
  119697. * @param impostor impostor to sleep
  119698. */
  119699. sleepBody(impostor: PhysicsImpostor): void;
  119700. /**
  119701. * Activates the physics body
  119702. * @param impostor impostor to activate
  119703. */
  119704. wakeUpBody(impostor: PhysicsImpostor): void;
  119705. /**
  119706. * Updates the distance parameters of the joint
  119707. * @param joint joint to update
  119708. * @param maxDistance maximum distance of the joint
  119709. * @param minDistance minimum distance of the joint
  119710. */
  119711. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119712. /**
  119713. * Sets a motor on the joint
  119714. * @param joint joint to set motor on
  119715. * @param speed speed of the motor
  119716. * @param maxForce maximum force of the motor
  119717. * @param motorIndex index of the motor
  119718. */
  119719. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119720. /**
  119721. * Sets the motors limit
  119722. * @param joint joint to set limit on
  119723. * @param upperLimit upper limit
  119724. * @param lowerLimit lower limit
  119725. */
  119726. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119727. /**
  119728. * Syncs the position and rotation of a mesh with the impostor
  119729. * @param mesh mesh to sync
  119730. * @param impostor impostor to update the mesh with
  119731. */
  119732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119733. /**
  119734. * Gets the radius of the impostor
  119735. * @param impostor impostor to get radius from
  119736. * @returns the radius
  119737. */
  119738. getRadius(impostor: PhysicsImpostor): number;
  119739. /**
  119740. * Gets the box size of the impostor
  119741. * @param impostor impostor to get box size from
  119742. * @param result the resulting box size
  119743. */
  119744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119745. /**
  119746. * Disposes of the impostor
  119747. */
  119748. dispose(): void;
  119749. /**
  119750. * Does a raycast in the physics world
  119751. * @param from when should the ray start?
  119752. * @param to when should the ray end?
  119753. * @returns PhysicsRaycastResult
  119754. */
  119755. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119756. }
  119757. }
  119758. declare module BABYLON {
  119759. interface AbstractScene {
  119760. /**
  119761. * The list of reflection probes added to the scene
  119762. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119763. */
  119764. reflectionProbes: Array<ReflectionProbe>;
  119765. /**
  119766. * Removes the given reflection probe from this scene.
  119767. * @param toRemove The reflection probe to remove
  119768. * @returns The index of the removed reflection probe
  119769. */
  119770. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119771. /**
  119772. * Adds the given reflection probe to this scene.
  119773. * @param newReflectionProbe The reflection probe to add
  119774. */
  119775. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119776. }
  119777. /**
  119778. * Class used to generate realtime reflection / refraction cube textures
  119779. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119780. */
  119781. export class ReflectionProbe {
  119782. /** defines the name of the probe */
  119783. name: string;
  119784. private _scene;
  119785. private _renderTargetTexture;
  119786. private _projectionMatrix;
  119787. private _viewMatrix;
  119788. private _target;
  119789. private _add;
  119790. private _attachedMesh;
  119791. private _invertYAxis;
  119792. /** Gets or sets probe position (center of the cube map) */
  119793. position: Vector3;
  119794. /**
  119795. * Creates a new reflection probe
  119796. * @param name defines the name of the probe
  119797. * @param size defines the texture resolution (for each face)
  119798. * @param scene defines the hosting scene
  119799. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119800. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119801. */
  119802. constructor(
  119803. /** defines the name of the probe */
  119804. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119805. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119806. samples: number;
  119807. /** Gets or sets the refresh rate to use (on every frame by default) */
  119808. refreshRate: number;
  119809. /**
  119810. * Gets the hosting scene
  119811. * @returns a Scene
  119812. */
  119813. getScene(): Scene;
  119814. /** Gets the internal CubeTexture used to render to */
  119815. readonly cubeTexture: RenderTargetTexture;
  119816. /** Gets the list of meshes to render */
  119817. readonly renderList: Nullable<AbstractMesh[]>;
  119818. /**
  119819. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119820. * @param mesh defines the mesh to attach to
  119821. */
  119822. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119823. /**
  119824. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119825. * @param renderingGroupId The rendering group id corresponding to its index
  119826. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119827. */
  119828. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119829. /**
  119830. * Clean all associated resources
  119831. */
  119832. dispose(): void;
  119833. /**
  119834. * Converts the reflection probe information to a readable string for debug purpose.
  119835. * @param fullDetails Supports for multiple levels of logging within scene loading
  119836. * @returns the human readable reflection probe info
  119837. */
  119838. toString(fullDetails?: boolean): string;
  119839. /**
  119840. * Get the class name of the relfection probe.
  119841. * @returns "ReflectionProbe"
  119842. */
  119843. getClassName(): string;
  119844. /**
  119845. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119846. * @returns The JSON representation of the texture
  119847. */
  119848. serialize(): any;
  119849. /**
  119850. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119851. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119852. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119853. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119854. * @returns The parsed reflection probe if successful
  119855. */
  119856. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119857. }
  119858. }
  119859. declare module BABYLON {
  119860. /** @hidden */
  119861. export var _BabylonLoaderRegistered: boolean;
  119862. /**
  119863. * Helps setting up some configuration for the babylon file loader.
  119864. */
  119865. export class BabylonFileLoaderConfiguration {
  119866. /**
  119867. * The loader does not allow injecting custom physix engine into the plugins.
  119868. * Unfortunately in ES6, we need to manually inject them into the plugin.
  119869. * So you could set this variable to your engine import to make it work.
  119870. */
  119871. static LoaderInjectedPhysicsEngine: any;
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. /**
  119876. * The Physically based simple base material of BJS.
  119877. *
  119878. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119879. * It is used as the base class for both the specGloss and metalRough conventions.
  119880. */
  119881. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119882. /**
  119883. * Number of Simultaneous lights allowed on the material.
  119884. */
  119885. maxSimultaneousLights: number;
  119886. /**
  119887. * If sets to true, disables all the lights affecting the material.
  119888. */
  119889. disableLighting: boolean;
  119890. /**
  119891. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119892. */
  119893. environmentTexture: BaseTexture;
  119894. /**
  119895. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119896. */
  119897. invertNormalMapX: boolean;
  119898. /**
  119899. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119900. */
  119901. invertNormalMapY: boolean;
  119902. /**
  119903. * Normal map used in the model.
  119904. */
  119905. normalTexture: BaseTexture;
  119906. /**
  119907. * Emissivie color used to self-illuminate the model.
  119908. */
  119909. emissiveColor: Color3;
  119910. /**
  119911. * Emissivie texture used to self-illuminate the model.
  119912. */
  119913. emissiveTexture: BaseTexture;
  119914. /**
  119915. * Occlusion Channel Strenght.
  119916. */
  119917. occlusionStrength: number;
  119918. /**
  119919. * Occlusion Texture of the material (adding extra occlusion effects).
  119920. */
  119921. occlusionTexture: BaseTexture;
  119922. /**
  119923. * Defines the alpha limits in alpha test mode.
  119924. */
  119925. alphaCutOff: number;
  119926. /**
  119927. * Gets the current double sided mode.
  119928. */
  119929. /**
  119930. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119931. */
  119932. doubleSided: boolean;
  119933. /**
  119934. * Stores the pre-calculated light information of a mesh in a texture.
  119935. */
  119936. lightmapTexture: BaseTexture;
  119937. /**
  119938. * If true, the light map contains occlusion information instead of lighting info.
  119939. */
  119940. useLightmapAsShadowmap: boolean;
  119941. /**
  119942. * Instantiates a new PBRMaterial instance.
  119943. *
  119944. * @param name The material name
  119945. * @param scene The scene the material will be use in.
  119946. */
  119947. constructor(name: string, scene: Scene);
  119948. getClassName(): string;
  119949. }
  119950. }
  119951. declare module BABYLON {
  119952. /**
  119953. * The PBR material of BJS following the metal roughness convention.
  119954. *
  119955. * This fits to the PBR convention in the GLTF definition:
  119956. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119957. */
  119958. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119959. /**
  119960. * The base color has two different interpretations depending on the value of metalness.
  119961. * When the material is a metal, the base color is the specific measured reflectance value
  119962. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119963. * of the material.
  119964. */
  119965. baseColor: Color3;
  119966. /**
  119967. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119968. * well as opacity information in the alpha channel.
  119969. */
  119970. baseTexture: BaseTexture;
  119971. /**
  119972. * Specifies the metallic scalar value of the material.
  119973. * Can also be used to scale the metalness values of the metallic texture.
  119974. */
  119975. metallic: number;
  119976. /**
  119977. * Specifies the roughness scalar value of the material.
  119978. * Can also be used to scale the roughness values of the metallic texture.
  119979. */
  119980. roughness: number;
  119981. /**
  119982. * Texture containing both the metallic value in the B channel and the
  119983. * roughness value in the G channel to keep better precision.
  119984. */
  119985. metallicRoughnessTexture: BaseTexture;
  119986. /**
  119987. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119988. *
  119989. * @param name The material name
  119990. * @param scene The scene the material will be use in.
  119991. */
  119992. constructor(name: string, scene: Scene);
  119993. /**
  119994. * Return the currrent class name of the material.
  119995. */
  119996. getClassName(): string;
  119997. /**
  119998. * Makes a duplicate of the current material.
  119999. * @param name - name to use for the new material.
  120000. */
  120001. clone(name: string): PBRMetallicRoughnessMaterial;
  120002. /**
  120003. * Serialize the material to a parsable JSON object.
  120004. */
  120005. serialize(): any;
  120006. /**
  120007. * Parses a JSON object correponding to the serialize function.
  120008. */
  120009. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120010. }
  120011. }
  120012. declare module BABYLON {
  120013. /**
  120014. * The PBR material of BJS following the specular glossiness convention.
  120015. *
  120016. * This fits to the PBR convention in the GLTF definition:
  120017. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120018. */
  120019. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120020. /**
  120021. * Specifies the diffuse color of the material.
  120022. */
  120023. diffuseColor: Color3;
  120024. /**
  120025. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120026. * channel.
  120027. */
  120028. diffuseTexture: BaseTexture;
  120029. /**
  120030. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120031. */
  120032. specularColor: Color3;
  120033. /**
  120034. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120035. */
  120036. glossiness: number;
  120037. /**
  120038. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120039. */
  120040. specularGlossinessTexture: BaseTexture;
  120041. /**
  120042. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120043. *
  120044. * @param name The material name
  120045. * @param scene The scene the material will be use in.
  120046. */
  120047. constructor(name: string, scene: Scene);
  120048. /**
  120049. * Return the currrent class name of the material.
  120050. */
  120051. getClassName(): string;
  120052. /**
  120053. * Makes a duplicate of the current material.
  120054. * @param name - name to use for the new material.
  120055. */
  120056. clone(name: string): PBRSpecularGlossinessMaterial;
  120057. /**
  120058. * Serialize the material to a parsable JSON object.
  120059. */
  120060. serialize(): any;
  120061. /**
  120062. * Parses a JSON object correponding to the serialize function.
  120063. */
  120064. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120065. }
  120066. }
  120067. declare module BABYLON {
  120068. /**
  120069. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120070. * It can help converting any input color in a desired output one. This can then be used to create effects
  120071. * from sepia, black and white to sixties or futuristic rendering...
  120072. *
  120073. * The only supported format is currently 3dl.
  120074. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120075. */
  120076. export class ColorGradingTexture extends BaseTexture {
  120077. /**
  120078. * The current texture matrix. (will always be identity in color grading texture)
  120079. */
  120080. private _textureMatrix;
  120081. /**
  120082. * The texture URL.
  120083. */
  120084. url: string;
  120085. /**
  120086. * Empty line regex stored for GC.
  120087. */
  120088. private static _noneEmptyLineRegex;
  120089. private _engine;
  120090. /**
  120091. * Instantiates a ColorGradingTexture from the following parameters.
  120092. *
  120093. * @param url The location of the color gradind data (currently only supporting 3dl)
  120094. * @param scene The scene the texture will be used in
  120095. */
  120096. constructor(url: string, scene: Scene);
  120097. /**
  120098. * Returns the texture matrix used in most of the material.
  120099. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120100. */
  120101. getTextureMatrix(): Matrix;
  120102. /**
  120103. * Occurs when the file being loaded is a .3dl LUT file.
  120104. */
  120105. private load3dlTexture;
  120106. /**
  120107. * Starts the loading process of the texture.
  120108. */
  120109. private loadTexture;
  120110. /**
  120111. * Clones the color gradind texture.
  120112. */
  120113. clone(): ColorGradingTexture;
  120114. /**
  120115. * Called during delayed load for textures.
  120116. */
  120117. delayLoad(): void;
  120118. /**
  120119. * Parses a color grading texture serialized by Babylon.
  120120. * @param parsedTexture The texture information being parsedTexture
  120121. * @param scene The scene to load the texture in
  120122. * @param rootUrl The root url of the data assets to load
  120123. * @return A color gradind texture
  120124. */
  120125. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120126. /**
  120127. * Serializes the LUT texture to json format.
  120128. */
  120129. serialize(): any;
  120130. }
  120131. }
  120132. declare module BABYLON {
  120133. /**
  120134. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120135. */
  120136. export class EquiRectangularCubeTexture extends BaseTexture {
  120137. /** The six faces of the cube. */
  120138. private static _FacesMapping;
  120139. private _noMipmap;
  120140. private _onLoad;
  120141. private _onError;
  120142. /** The size of the cubemap. */
  120143. private _size;
  120144. /** The buffer of the image. */
  120145. private _buffer;
  120146. /** The width of the input image. */
  120147. private _width;
  120148. /** The height of the input image. */
  120149. private _height;
  120150. /** The URL to the image. */
  120151. url: string;
  120152. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120153. coordinatesMode: number;
  120154. /**
  120155. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120156. * @param url The location of the image
  120157. * @param scene The scene the texture will be used in
  120158. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120159. * @param noMipmap Forces to not generate the mipmap if true
  120160. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120161. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120162. * @param onLoad — defines a callback called when texture is loaded
  120163. * @param onError — defines a callback called if there is an error
  120164. */
  120165. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120166. /**
  120167. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120168. */
  120169. private loadImage;
  120170. /**
  120171. * Convert the image buffer into a cubemap and create a CubeTexture.
  120172. */
  120173. private loadTexture;
  120174. /**
  120175. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120176. * @param buffer The ArrayBuffer that should be converted.
  120177. * @returns The buffer as Float32Array.
  120178. */
  120179. private getFloat32ArrayFromArrayBuffer;
  120180. /**
  120181. * Get the current class name of the texture useful for serialization or dynamic coding.
  120182. * @returns "EquiRectangularCubeTexture"
  120183. */
  120184. getClassName(): string;
  120185. /**
  120186. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120187. * @returns A clone of the current EquiRectangularCubeTexture.
  120188. */
  120189. clone(): EquiRectangularCubeTexture;
  120190. }
  120191. }
  120192. declare module BABYLON {
  120193. /**
  120194. * Based on jsTGALoader - Javascript loader for TGA file
  120195. * By Vincent Thibault
  120196. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120197. */
  120198. export class TGATools {
  120199. private static _TYPE_INDEXED;
  120200. private static _TYPE_RGB;
  120201. private static _TYPE_GREY;
  120202. private static _TYPE_RLE_INDEXED;
  120203. private static _TYPE_RLE_RGB;
  120204. private static _TYPE_RLE_GREY;
  120205. private static _ORIGIN_MASK;
  120206. private static _ORIGIN_SHIFT;
  120207. private static _ORIGIN_BL;
  120208. private static _ORIGIN_BR;
  120209. private static _ORIGIN_UL;
  120210. private static _ORIGIN_UR;
  120211. /**
  120212. * Gets the header of a TGA file
  120213. * @param data defines the TGA data
  120214. * @returns the header
  120215. */
  120216. static GetTGAHeader(data: Uint8Array): any;
  120217. /**
  120218. * Uploads TGA content to a Babylon Texture
  120219. * @hidden
  120220. */
  120221. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120222. /** @hidden */
  120223. 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;
  120224. /** @hidden */
  120225. 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;
  120226. /** @hidden */
  120227. 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;
  120228. /** @hidden */
  120229. 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;
  120230. /** @hidden */
  120231. 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;
  120232. /** @hidden */
  120233. 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;
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /**
  120238. * Implementation of the TGA Texture Loader.
  120239. * @hidden
  120240. */
  120241. export class _TGATextureLoader implements IInternalTextureLoader {
  120242. /**
  120243. * Defines wether the loader supports cascade loading the different faces.
  120244. */
  120245. readonly supportCascades: boolean;
  120246. /**
  120247. * This returns if the loader support the current file information.
  120248. * @param extension defines the file extension of the file being loaded
  120249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120250. * @param fallback defines the fallback internal texture if any
  120251. * @param isBase64 defines whether the texture is encoded as a base64
  120252. * @param isBuffer defines whether the texture data are stored as a buffer
  120253. * @returns true if the loader can load the specified file
  120254. */
  120255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120256. /**
  120257. * Transform the url before loading if required.
  120258. * @param rootUrl the url of the texture
  120259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120260. * @returns the transformed texture
  120261. */
  120262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120263. /**
  120264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120265. * @param rootUrl the url of the texture
  120266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120267. * @returns the fallback texture
  120268. */
  120269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120270. /**
  120271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120272. * @param data contains the texture data
  120273. * @param texture defines the BabylonJS internal texture
  120274. * @param createPolynomials will be true if polynomials have been requested
  120275. * @param onLoad defines the callback to trigger once the texture is ready
  120276. * @param onError defines the callback to trigger in case of error
  120277. */
  120278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120279. /**
  120280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120281. * @param data contains the texture data
  120282. * @param texture defines the BabylonJS internal texture
  120283. * @param callback defines the method to call once ready to upload
  120284. */
  120285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120286. }
  120287. }
  120288. declare module BABYLON {
  120289. /**
  120290. * Info about the .basis files
  120291. */
  120292. class BasisFileInfo {
  120293. /**
  120294. * If the file has alpha
  120295. */
  120296. hasAlpha: boolean;
  120297. /**
  120298. * Info about each image of the basis file
  120299. */
  120300. images: Array<{
  120301. levels: Array<{
  120302. width: number;
  120303. height: number;
  120304. transcodedPixels: ArrayBufferView;
  120305. }>;
  120306. }>;
  120307. }
  120308. /**
  120309. * Result of transcoding a basis file
  120310. */
  120311. class TranscodeResult {
  120312. /**
  120313. * Info about the .basis file
  120314. */
  120315. fileInfo: BasisFileInfo;
  120316. /**
  120317. * Format to use when loading the file
  120318. */
  120319. format: number;
  120320. }
  120321. /**
  120322. * Configuration options for the Basis transcoder
  120323. */
  120324. export class BasisTranscodeConfiguration {
  120325. /**
  120326. * Supported compression formats used to determine the supported output format of the transcoder
  120327. */
  120328. supportedCompressionFormats?: {
  120329. /**
  120330. * etc1 compression format
  120331. */
  120332. etc1?: boolean;
  120333. /**
  120334. * s3tc compression format
  120335. */
  120336. s3tc?: boolean;
  120337. /**
  120338. * pvrtc compression format
  120339. */
  120340. pvrtc?: boolean;
  120341. /**
  120342. * etc2 compression format
  120343. */
  120344. etc2?: boolean;
  120345. };
  120346. /**
  120347. * If mipmap levels should be loaded for transcoded images (Default: true)
  120348. */
  120349. loadMipmapLevels?: boolean;
  120350. /**
  120351. * Index of a single image to load (Default: all images)
  120352. */
  120353. loadSingleImage?: number;
  120354. }
  120355. /**
  120356. * Used to load .Basis files
  120357. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120358. */
  120359. export class BasisTools {
  120360. private static _IgnoreSupportedFormats;
  120361. /**
  120362. * URL to use when loading the basis transcoder
  120363. */
  120364. static JSModuleURL: string;
  120365. /**
  120366. * URL to use when loading the wasm module for the transcoder
  120367. */
  120368. static WasmModuleURL: string;
  120369. /**
  120370. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120371. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120372. * @returns internal format corresponding to the Basis format
  120373. */
  120374. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120375. private static _WorkerPromise;
  120376. private static _Worker;
  120377. private static _actionId;
  120378. private static _CreateWorkerAsync;
  120379. /**
  120380. * Transcodes a loaded image file to compressed pixel data
  120381. * @param imageData image data to transcode
  120382. * @param config configuration options for the transcoding
  120383. * @returns a promise resulting in the transcoded image
  120384. */
  120385. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120386. /**
  120387. * Loads a texture from the transcode result
  120388. * @param texture texture load to
  120389. * @param transcodeResult the result of transcoding the basis file to load from
  120390. */
  120391. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120392. }
  120393. }
  120394. declare module BABYLON {
  120395. /**
  120396. * Loader for .basis file format
  120397. */
  120398. export class _BasisTextureLoader implements IInternalTextureLoader {
  120399. /**
  120400. * Defines whether the loader supports cascade loading the different faces.
  120401. */
  120402. readonly supportCascades: boolean;
  120403. /**
  120404. * This returns if the loader support the current file information.
  120405. * @param extension defines the file extension of the file being loaded
  120406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120407. * @param fallback defines the fallback internal texture if any
  120408. * @param isBase64 defines whether the texture is encoded as a base64
  120409. * @param isBuffer defines whether the texture data are stored as a buffer
  120410. * @returns true if the loader can load the specified file
  120411. */
  120412. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120413. /**
  120414. * Transform the url before loading if required.
  120415. * @param rootUrl the url of the texture
  120416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120417. * @returns the transformed texture
  120418. */
  120419. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120420. /**
  120421. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120422. * @param rootUrl the url of the texture
  120423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120424. * @returns the fallback texture
  120425. */
  120426. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120427. /**
  120428. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120429. * @param data contains the texture data
  120430. * @param texture defines the BabylonJS internal texture
  120431. * @param createPolynomials will be true if polynomials have been requested
  120432. * @param onLoad defines the callback to trigger once the texture is ready
  120433. * @param onError defines the callback to trigger in case of error
  120434. */
  120435. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120436. /**
  120437. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120438. * @param data contains the texture data
  120439. * @param texture defines the BabylonJS internal texture
  120440. * @param callback defines the method to call once ready to upload
  120441. */
  120442. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120443. }
  120444. }
  120445. declare module BABYLON {
  120446. /**
  120447. * 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.
  120448. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120449. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120450. */
  120451. export class CustomProceduralTexture extends ProceduralTexture {
  120452. private _animate;
  120453. private _time;
  120454. private _config;
  120455. private _texturePath;
  120456. /**
  120457. * Instantiates a new Custom Procedural Texture.
  120458. * 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.
  120459. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120460. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120461. * @param name Define the name of the texture
  120462. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120463. * @param size Define the size of the texture to create
  120464. * @param scene Define the scene the texture belongs to
  120465. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120466. * @param generateMipMaps Define if the texture should creates mip maps or not
  120467. */
  120468. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120469. private _loadJson;
  120470. /**
  120471. * Is the texture ready to be used ? (rendered at least once)
  120472. * @returns true if ready, otherwise, false.
  120473. */
  120474. isReady(): boolean;
  120475. /**
  120476. * Render the texture to its associated render target.
  120477. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120478. */
  120479. render(useCameraPostProcess?: boolean): void;
  120480. /**
  120481. * Update the list of dependant textures samplers in the shader.
  120482. */
  120483. updateTextures(): void;
  120484. /**
  120485. * Update the uniform values of the procedural texture in the shader.
  120486. */
  120487. updateShaderUniforms(): void;
  120488. /**
  120489. * Define if the texture animates or not.
  120490. */
  120491. animate: boolean;
  120492. }
  120493. }
  120494. declare module BABYLON {
  120495. /** @hidden */
  120496. export var noisePixelShader: {
  120497. name: string;
  120498. shader: string;
  120499. };
  120500. }
  120501. declare module BABYLON {
  120502. /**
  120503. * Class used to generate noise procedural textures
  120504. */
  120505. export class NoiseProceduralTexture extends ProceduralTexture {
  120506. private _time;
  120507. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120508. brightness: number;
  120509. /** Defines the number of octaves to process */
  120510. octaves: number;
  120511. /** Defines the level of persistence (0.8 by default) */
  120512. persistence: number;
  120513. /** Gets or sets animation speed factor (default is 1) */
  120514. animationSpeedFactor: number;
  120515. /**
  120516. * Creates a new NoiseProceduralTexture
  120517. * @param name defines the name fo the texture
  120518. * @param size defines the size of the texture (default is 256)
  120519. * @param scene defines the hosting scene
  120520. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120521. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120522. */
  120523. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120524. private _updateShaderUniforms;
  120525. protected _getDefines(): string;
  120526. /** Generate the current state of the procedural texture */
  120527. render(useCameraPostProcess?: boolean): void;
  120528. /**
  120529. * Serializes this noise procedural texture
  120530. * @returns a serialized noise procedural texture object
  120531. */
  120532. serialize(): any;
  120533. /**
  120534. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120535. * @param parsedTexture defines parsed texture data
  120536. * @param scene defines the current scene
  120537. * @param rootUrl defines the root URL containing noise procedural texture information
  120538. * @returns a parsed NoiseProceduralTexture
  120539. */
  120540. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120541. }
  120542. }
  120543. declare module BABYLON {
  120544. /**
  120545. * Raw cube texture where the raw buffers are passed in
  120546. */
  120547. export class RawCubeTexture extends CubeTexture {
  120548. /**
  120549. * Creates a cube texture where the raw buffers are passed in.
  120550. * @param scene defines the scene the texture is attached to
  120551. * @param data defines the array of data to use to create each face
  120552. * @param size defines the size of the textures
  120553. * @param format defines the format of the data
  120554. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  120555. * @param generateMipMaps defines if the engine should generate the mip levels
  120556. * @param invertY defines if data must be stored with Y axis inverted
  120557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120558. * @param compression defines the compression used (null by default)
  120559. */
  120560. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120561. /**
  120562. * Updates the raw cube texture.
  120563. * @param data defines the data to store
  120564. * @param format defines the data format
  120565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120566. * @param invertY defines if data must be stored with Y axis inverted
  120567. * @param compression defines the compression used (null by default)
  120568. * @param level defines which level of the texture to update
  120569. */
  120570. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120571. /**
  120572. * Updates a raw cube texture with RGBD encoded data.
  120573. * @param data defines the array of data [mipmap][face] to use to create each face
  120574. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120577. * @returns a promsie that resolves when the operation is complete
  120578. */
  120579. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120580. /**
  120581. * Clones the raw cube texture.
  120582. * @return a new cube texture
  120583. */
  120584. clone(): CubeTexture;
  120585. /** @hidden */
  120586. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120587. }
  120588. }
  120589. declare module BABYLON {
  120590. /**
  120591. * Class used to store 3D textures containing user data
  120592. */
  120593. export class RawTexture3D extends Texture {
  120594. /** Gets or sets the texture format to use */
  120595. format: number;
  120596. private _engine;
  120597. /**
  120598. * Create a new RawTexture3D
  120599. * @param data defines the data of the texture
  120600. * @param width defines the width of the texture
  120601. * @param height defines the height of the texture
  120602. * @param depth defines the depth of the texture
  120603. * @param format defines the texture format to use
  120604. * @param scene defines the hosting scene
  120605. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120606. * @param invertY defines if texture must be stored with Y axis inverted
  120607. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120608. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120609. */
  120610. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120611. /** Gets or sets the texture format to use */
  120612. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120613. /**
  120614. * Update the texture with new data
  120615. * @param data defines the data to store in the texture
  120616. */
  120617. update(data: ArrayBufferView): void;
  120618. }
  120619. }
  120620. declare module BABYLON {
  120621. /**
  120622. * Creates a refraction texture used by refraction channel of the standard material.
  120623. * It is like a mirror but to see through a material.
  120624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120625. */
  120626. export class RefractionTexture extends RenderTargetTexture {
  120627. /**
  120628. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120629. * 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.
  120630. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120631. */
  120632. refractionPlane: Plane;
  120633. /**
  120634. * Define how deep under the surface we should see.
  120635. */
  120636. depth: number;
  120637. /**
  120638. * Creates a refraction texture used by refraction channel of the standard material.
  120639. * It is like a mirror but to see through a material.
  120640. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120641. * @param name Define the texture name
  120642. * @param size Define the size of the underlying texture
  120643. * @param scene Define the scene the refraction belongs to
  120644. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120645. */
  120646. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120647. /**
  120648. * Clone the refraction texture.
  120649. * @returns the cloned texture
  120650. */
  120651. clone(): RefractionTexture;
  120652. /**
  120653. * Serialize the texture to a JSON representation you could use in Parse later on
  120654. * @returns the serialized JSON representation
  120655. */
  120656. serialize(): any;
  120657. }
  120658. }
  120659. declare module BABYLON {
  120660. /**
  120661. * Defines the options related to the creation of an HtmlElementTexture
  120662. */
  120663. export interface IHtmlElementTextureOptions {
  120664. /**
  120665. * Defines wether mip maps should be created or not.
  120666. */
  120667. generateMipMaps?: boolean;
  120668. /**
  120669. * Defines the sampling mode of the texture.
  120670. */
  120671. samplingMode?: number;
  120672. /**
  120673. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120674. */
  120675. engine: Nullable<ThinEngine>;
  120676. /**
  120677. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120678. */
  120679. scene: Nullable<Scene>;
  120680. }
  120681. /**
  120682. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120683. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120684. * is automatically managed.
  120685. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120686. * in your application.
  120687. *
  120688. * As the update is not automatic, you need to call them manually.
  120689. */
  120690. export class HtmlElementTexture extends BaseTexture {
  120691. /**
  120692. * The texture URL.
  120693. */
  120694. element: HTMLVideoElement | HTMLCanvasElement;
  120695. private static readonly DefaultOptions;
  120696. private _textureMatrix;
  120697. private _engine;
  120698. private _isVideo;
  120699. private _generateMipMaps;
  120700. private _samplingMode;
  120701. /**
  120702. * Instantiates a HtmlElementTexture from the following parameters.
  120703. *
  120704. * @param name Defines the name of the texture
  120705. * @param element Defines the video or canvas the texture is filled with
  120706. * @param options Defines the other none mandatory texture creation options
  120707. */
  120708. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120709. private _createInternalTexture;
  120710. /**
  120711. * Returns the texture matrix used in most of the material.
  120712. */
  120713. getTextureMatrix(): Matrix;
  120714. /**
  120715. * Updates the content of the texture.
  120716. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120717. */
  120718. update(invertY?: Nullable<boolean>): void;
  120719. }
  120720. }
  120721. declare module BABYLON {
  120722. /**
  120723. * Enum used to define the target of a block
  120724. */
  120725. export enum NodeMaterialBlockTargets {
  120726. /** Vertex shader */
  120727. Vertex = 1,
  120728. /** Fragment shader */
  120729. Fragment = 2,
  120730. /** Neutral */
  120731. Neutral = 4,
  120732. /** Vertex and Fragment */
  120733. VertexAndFragment = 3
  120734. }
  120735. }
  120736. declare module BABYLON {
  120737. /**
  120738. * Defines the kind of connection point for node based material
  120739. */
  120740. export enum NodeMaterialBlockConnectionPointTypes {
  120741. /** Float */
  120742. Float = 1,
  120743. /** Int */
  120744. Int = 2,
  120745. /** Vector2 */
  120746. Vector2 = 4,
  120747. /** Vector3 */
  120748. Vector3 = 8,
  120749. /** Vector4 */
  120750. Vector4 = 16,
  120751. /** Color3 */
  120752. Color3 = 32,
  120753. /** Color4 */
  120754. Color4 = 64,
  120755. /** Matrix */
  120756. Matrix = 128,
  120757. /** Detect type based on connection */
  120758. AutoDetect = 1024,
  120759. /** Output type that will be defined by input type */
  120760. BasedOnInput = 2048
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. /**
  120765. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120766. */
  120767. export enum NodeMaterialBlockConnectionPointMode {
  120768. /** Value is an uniform */
  120769. Uniform = 0,
  120770. /** Value is a mesh attribute */
  120771. Attribute = 1,
  120772. /** Value is a varying between vertex and fragment shaders */
  120773. Varying = 2,
  120774. /** Mode is undefined */
  120775. Undefined = 3
  120776. }
  120777. }
  120778. declare module BABYLON {
  120779. /**
  120780. * Enum used to define system values e.g. values automatically provided by the system
  120781. */
  120782. export enum NodeMaterialSystemValues {
  120783. /** World */
  120784. World = 1,
  120785. /** View */
  120786. View = 2,
  120787. /** Projection */
  120788. Projection = 3,
  120789. /** ViewProjection */
  120790. ViewProjection = 4,
  120791. /** WorldView */
  120792. WorldView = 5,
  120793. /** WorldViewProjection */
  120794. WorldViewProjection = 6,
  120795. /** CameraPosition */
  120796. CameraPosition = 7,
  120797. /** Fog Color */
  120798. FogColor = 8,
  120799. /** Delta time */
  120800. DeltaTime = 9
  120801. }
  120802. }
  120803. declare module BABYLON {
  120804. /**
  120805. * Root class for all node material optimizers
  120806. */
  120807. export class NodeMaterialOptimizer {
  120808. /**
  120809. * Function used to optimize a NodeMaterial graph
  120810. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120811. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120812. */
  120813. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120814. }
  120815. }
  120816. declare module BABYLON {
  120817. /**
  120818. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120819. */
  120820. export class TransformBlock extends NodeMaterialBlock {
  120821. /**
  120822. * Defines the value to use to complement W value to transform it to a Vector4
  120823. */
  120824. complementW: number;
  120825. /**
  120826. * Defines the value to use to complement z value to transform it to a Vector4
  120827. */
  120828. complementZ: number;
  120829. /**
  120830. * Creates a new TransformBlock
  120831. * @param name defines the block name
  120832. */
  120833. constructor(name: string);
  120834. /**
  120835. * Gets the current class name
  120836. * @returns the class name
  120837. */
  120838. getClassName(): string;
  120839. /**
  120840. * Gets the vector input
  120841. */
  120842. readonly vector: NodeMaterialConnectionPoint;
  120843. /**
  120844. * Gets the output component
  120845. */
  120846. readonly output: NodeMaterialConnectionPoint;
  120847. /**
  120848. * Gets the matrix transform input
  120849. */
  120850. readonly transform: NodeMaterialConnectionPoint;
  120851. protected _buildBlock(state: NodeMaterialBuildState): this;
  120852. serialize(): any;
  120853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120854. protected _dumpPropertiesCode(): string;
  120855. }
  120856. }
  120857. declare module BABYLON {
  120858. /**
  120859. * Block used to output the vertex position
  120860. */
  120861. export class VertexOutputBlock extends NodeMaterialBlock {
  120862. /**
  120863. * Creates a new VertexOutputBlock
  120864. * @param name defines the block name
  120865. */
  120866. constructor(name: string);
  120867. /**
  120868. * Gets the current class name
  120869. * @returns the class name
  120870. */
  120871. getClassName(): string;
  120872. /**
  120873. * Gets the vector input component
  120874. */
  120875. readonly vector: NodeMaterialConnectionPoint;
  120876. protected _buildBlock(state: NodeMaterialBuildState): this;
  120877. }
  120878. }
  120879. declare module BABYLON {
  120880. /**
  120881. * Block used to output the final color
  120882. */
  120883. export class FragmentOutputBlock extends NodeMaterialBlock {
  120884. /**
  120885. * Create a new FragmentOutputBlock
  120886. * @param name defines the block name
  120887. */
  120888. constructor(name: string);
  120889. /**
  120890. * Gets the current class name
  120891. * @returns the class name
  120892. */
  120893. getClassName(): string;
  120894. /**
  120895. * Gets the rgba input component
  120896. */
  120897. readonly rgba: NodeMaterialConnectionPoint;
  120898. /**
  120899. * Gets the rgb input component
  120900. */
  120901. readonly rgb: NodeMaterialConnectionPoint;
  120902. /**
  120903. * Gets the a input component
  120904. */
  120905. readonly a: NodeMaterialConnectionPoint;
  120906. protected _buildBlock(state: NodeMaterialBuildState): this;
  120907. }
  120908. }
  120909. declare module BABYLON {
  120910. /**
  120911. * Block used to read a reflection texture from a sampler
  120912. */
  120913. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120914. private _define3DName;
  120915. private _defineCubicName;
  120916. private _defineExplicitName;
  120917. private _defineProjectionName;
  120918. private _defineLocalCubicName;
  120919. private _defineSphericalName;
  120920. private _definePlanarName;
  120921. private _defineEquirectangularName;
  120922. private _defineMirroredEquirectangularFixedName;
  120923. private _defineEquirectangularFixedName;
  120924. private _defineSkyboxName;
  120925. private _cubeSamplerName;
  120926. private _2DSamplerName;
  120927. private _positionUVWName;
  120928. private _directionWName;
  120929. private _reflectionCoordsName;
  120930. private _reflection2DCoordsName;
  120931. private _reflectionColorName;
  120932. private _reflectionMatrixName;
  120933. /**
  120934. * Gets or sets the texture associated with the node
  120935. */
  120936. texture: Nullable<BaseTexture>;
  120937. /**
  120938. * Create a new TextureBlock
  120939. * @param name defines the block name
  120940. */
  120941. constructor(name: string);
  120942. /**
  120943. * Gets the current class name
  120944. * @returns the class name
  120945. */
  120946. getClassName(): string;
  120947. /**
  120948. * Gets the world position input component
  120949. */
  120950. readonly position: NodeMaterialConnectionPoint;
  120951. /**
  120952. * Gets the world position input component
  120953. */
  120954. readonly worldPosition: NodeMaterialConnectionPoint;
  120955. /**
  120956. * Gets the world normal input component
  120957. */
  120958. readonly worldNormal: NodeMaterialConnectionPoint;
  120959. /**
  120960. * Gets the world input component
  120961. */
  120962. readonly world: NodeMaterialConnectionPoint;
  120963. /**
  120964. * Gets the camera (or eye) position component
  120965. */
  120966. readonly cameraPosition: NodeMaterialConnectionPoint;
  120967. /**
  120968. * Gets the view input component
  120969. */
  120970. readonly view: NodeMaterialConnectionPoint;
  120971. /**
  120972. * Gets the rgb output component
  120973. */
  120974. readonly rgb: NodeMaterialConnectionPoint;
  120975. /**
  120976. * Gets the r output component
  120977. */
  120978. readonly r: NodeMaterialConnectionPoint;
  120979. /**
  120980. * Gets the g output component
  120981. */
  120982. readonly g: NodeMaterialConnectionPoint;
  120983. /**
  120984. * Gets the b output component
  120985. */
  120986. readonly b: NodeMaterialConnectionPoint;
  120987. autoConfigure(material: NodeMaterial): void;
  120988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120989. isReady(): boolean;
  120990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120991. private _injectVertexCode;
  120992. private _writeOutput;
  120993. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120994. protected _dumpPropertiesCode(): string;
  120995. serialize(): any;
  120996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120997. }
  120998. }
  120999. declare module BABYLON {
  121000. /**
  121001. * Interface used to configure the node material editor
  121002. */
  121003. export interface INodeMaterialEditorOptions {
  121004. /** Define the URl to load node editor script */
  121005. editorURL?: string;
  121006. }
  121007. /** @hidden */
  121008. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121009. /** BONES */
  121010. NUM_BONE_INFLUENCERS: number;
  121011. BonesPerMesh: number;
  121012. BONETEXTURE: boolean;
  121013. /** MORPH TARGETS */
  121014. MORPHTARGETS: boolean;
  121015. MORPHTARGETS_NORMAL: boolean;
  121016. MORPHTARGETS_TANGENT: boolean;
  121017. MORPHTARGETS_UV: boolean;
  121018. NUM_MORPH_INFLUENCERS: number;
  121019. /** IMAGE PROCESSING */
  121020. IMAGEPROCESSING: boolean;
  121021. VIGNETTE: boolean;
  121022. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121023. VIGNETTEBLENDMODEOPAQUE: boolean;
  121024. TONEMAPPING: boolean;
  121025. TONEMAPPING_ACES: boolean;
  121026. CONTRAST: boolean;
  121027. EXPOSURE: boolean;
  121028. COLORCURVES: boolean;
  121029. COLORGRADING: boolean;
  121030. COLORGRADING3D: boolean;
  121031. SAMPLER3DGREENDEPTH: boolean;
  121032. SAMPLER3DBGRMAP: boolean;
  121033. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121034. /** MISC. */
  121035. BUMPDIRECTUV: number;
  121036. constructor();
  121037. setValue(name: string, value: boolean): void;
  121038. }
  121039. /**
  121040. * Class used to configure NodeMaterial
  121041. */
  121042. export interface INodeMaterialOptions {
  121043. /**
  121044. * Defines if blocks should emit comments
  121045. */
  121046. emitComments: boolean;
  121047. }
  121048. /**
  121049. * Class used to create a node based material built by assembling shader blocks
  121050. */
  121051. export class NodeMaterial extends PushMaterial {
  121052. private static _BuildIdGenerator;
  121053. private _options;
  121054. private _vertexCompilationState;
  121055. private _fragmentCompilationState;
  121056. private _sharedData;
  121057. private _buildId;
  121058. private _buildWasSuccessful;
  121059. private _cachedWorldViewMatrix;
  121060. private _cachedWorldViewProjectionMatrix;
  121061. private _optimizers;
  121062. private _animationFrame;
  121063. /** Define the URl to load node editor script */
  121064. static EditorURL: string;
  121065. private BJSNODEMATERIALEDITOR;
  121066. /** Get the inspector from bundle or global */
  121067. private _getGlobalNodeMaterialEditor;
  121068. /**
  121069. * 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)
  121070. */
  121071. ignoreAlpha: boolean;
  121072. /**
  121073. * Defines the maximum number of lights that can be used in the material
  121074. */
  121075. maxSimultaneousLights: number;
  121076. /**
  121077. * Observable raised when the material is built
  121078. */
  121079. onBuildObservable: Observable<NodeMaterial>;
  121080. /**
  121081. * Gets or sets the root nodes of the material vertex shader
  121082. */
  121083. _vertexOutputNodes: NodeMaterialBlock[];
  121084. /**
  121085. * Gets or sets the root nodes of the material fragment (pixel) shader
  121086. */
  121087. _fragmentOutputNodes: NodeMaterialBlock[];
  121088. /** Gets or sets options to control the node material overall behavior */
  121089. options: INodeMaterialOptions;
  121090. /**
  121091. * Default configuration related to image processing available in the standard Material.
  121092. */
  121093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121094. /**
  121095. * Gets the image processing configuration used either in this material.
  121096. */
  121097. /**
  121098. * Sets the Default image processing configuration used either in the this material.
  121099. *
  121100. * If sets to null, the scene one is in use.
  121101. */
  121102. imageProcessingConfiguration: ImageProcessingConfiguration;
  121103. /**
  121104. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121105. */
  121106. attachedBlocks: NodeMaterialBlock[];
  121107. /**
  121108. * Create a new node based material
  121109. * @param name defines the material name
  121110. * @param scene defines the hosting scene
  121111. * @param options defines creation option
  121112. */
  121113. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121114. /**
  121115. * Gets the current class name of the material e.g. "NodeMaterial"
  121116. * @returns the class name
  121117. */
  121118. getClassName(): string;
  121119. /**
  121120. * Keep track of the image processing observer to allow dispose and replace.
  121121. */
  121122. private _imageProcessingObserver;
  121123. /**
  121124. * Attaches a new image processing configuration to the Standard Material.
  121125. * @param configuration
  121126. */
  121127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121128. /**
  121129. * Get a block by its name
  121130. * @param name defines the name of the block to retrieve
  121131. * @returns the required block or null if not found
  121132. */
  121133. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121134. /**
  121135. * Get a block by its name
  121136. * @param predicate defines the predicate used to find the good candidate
  121137. * @returns the required block or null if not found
  121138. */
  121139. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121140. /**
  121141. * Get an input block by its name
  121142. * @param predicate defines the predicate used to find the good candidate
  121143. * @returns the required input block or null if not found
  121144. */
  121145. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121146. /**
  121147. * Gets the list of input blocks attached to this material
  121148. * @returns an array of InputBlocks
  121149. */
  121150. getInputBlocks(): InputBlock[];
  121151. /**
  121152. * Adds a new optimizer to the list of optimizers
  121153. * @param optimizer defines the optimizers to add
  121154. * @returns the current material
  121155. */
  121156. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121157. /**
  121158. * Remove an optimizer from the list of optimizers
  121159. * @param optimizer defines the optimizers to remove
  121160. * @returns the current material
  121161. */
  121162. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121163. /**
  121164. * Add a new block to the list of output nodes
  121165. * @param node defines the node to add
  121166. * @returns the current material
  121167. */
  121168. addOutputNode(node: NodeMaterialBlock): this;
  121169. /**
  121170. * Remove a block from the list of root nodes
  121171. * @param node defines the node to remove
  121172. * @returns the current material
  121173. */
  121174. removeOutputNode(node: NodeMaterialBlock): this;
  121175. private _addVertexOutputNode;
  121176. private _removeVertexOutputNode;
  121177. private _addFragmentOutputNode;
  121178. private _removeFragmentOutputNode;
  121179. /**
  121180. * Specifies if the material will require alpha blending
  121181. * @returns a boolean specifying if alpha blending is needed
  121182. */
  121183. needAlphaBlending(): boolean;
  121184. /**
  121185. * Specifies if this material should be rendered in alpha test mode
  121186. * @returns a boolean specifying if an alpha test is needed.
  121187. */
  121188. needAlphaTesting(): boolean;
  121189. private _initializeBlock;
  121190. private _resetDualBlocks;
  121191. /**
  121192. * Build the material and generates the inner effect
  121193. * @param verbose defines if the build should log activity
  121194. */
  121195. build(verbose?: boolean): void;
  121196. /**
  121197. * Runs an otpimization phase to try to improve the shader code
  121198. */
  121199. optimize(): void;
  121200. private _prepareDefinesForAttributes;
  121201. /**
  121202. * Get if the submesh is ready to be used and all its information available.
  121203. * Child classes can use it to update shaders
  121204. * @param mesh defines the mesh to check
  121205. * @param subMesh defines which submesh to check
  121206. * @param useInstances specifies that instances should be used
  121207. * @returns a boolean indicating that the submesh is ready or not
  121208. */
  121209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121210. /**
  121211. * Get a string representing the shaders built by the current node graph
  121212. */
  121213. readonly compiledShaders: string;
  121214. /**
  121215. * Binds the world matrix to the material
  121216. * @param world defines the world transformation matrix
  121217. */
  121218. bindOnlyWorldMatrix(world: Matrix): void;
  121219. /**
  121220. * Binds the submesh to this material by preparing the effect and shader to draw
  121221. * @param world defines the world transformation matrix
  121222. * @param mesh defines the mesh containing the submesh
  121223. * @param subMesh defines the submesh to bind the material to
  121224. */
  121225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121226. /**
  121227. * Gets the active textures from the material
  121228. * @returns an array of textures
  121229. */
  121230. getActiveTextures(): BaseTexture[];
  121231. /**
  121232. * Gets the list of texture blocks
  121233. * @returns an array of texture blocks
  121234. */
  121235. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121236. /**
  121237. * Specifies if the material uses a texture
  121238. * @param texture defines the texture to check against the material
  121239. * @returns a boolean specifying if the material uses the texture
  121240. */
  121241. hasTexture(texture: BaseTexture): boolean;
  121242. /**
  121243. * Disposes the material
  121244. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121245. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121246. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121247. */
  121248. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121249. /** Creates the node editor window. */
  121250. private _createNodeEditor;
  121251. /**
  121252. * Launch the node material editor
  121253. * @param config Define the configuration of the editor
  121254. * @return a promise fulfilled when the node editor is visible
  121255. */
  121256. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121257. /**
  121258. * Clear the current material
  121259. */
  121260. clear(): void;
  121261. /**
  121262. * Clear the current material and set it to a default state
  121263. */
  121264. setToDefault(): void;
  121265. /**
  121266. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121267. * @param url defines the url to load from
  121268. * @returns a promise that will fullfil when the material is fully loaded
  121269. */
  121270. loadAsync(url: string): Promise<void>;
  121271. private _gatherBlocks;
  121272. /**
  121273. * Generate a string containing the code declaration required to create an equivalent of this material
  121274. * @returns a string
  121275. */
  121276. generateCode(): string;
  121277. /**
  121278. * Serializes this material in a JSON representation
  121279. * @returns the serialized material object
  121280. */
  121281. serialize(): any;
  121282. private _restoreConnections;
  121283. /**
  121284. * Clear the current graph and load a new one from a serialization object
  121285. * @param source defines the JSON representation of the material
  121286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121287. */
  121288. loadFromSerialization(source: any, rootUrl?: string): void;
  121289. /**
  121290. * Creates a node material from parsed material data
  121291. * @param source defines the JSON representation of the material
  121292. * @param scene defines the hosting scene
  121293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121294. * @returns a new node material
  121295. */
  121296. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121297. /**
  121298. * Creates a new node material set to default basic configuration
  121299. * @param name defines the name of the material
  121300. * @param scene defines the hosting scene
  121301. * @returns a new NodeMaterial
  121302. */
  121303. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121304. }
  121305. }
  121306. declare module BABYLON {
  121307. /**
  121308. * Block used to read a texture from a sampler
  121309. */
  121310. export class TextureBlock extends NodeMaterialBlock {
  121311. private _defineName;
  121312. private _linearDefineName;
  121313. private _samplerName;
  121314. private _transformedUVName;
  121315. private _textureTransformName;
  121316. private _textureInfoName;
  121317. private _mainUVName;
  121318. private _mainUVDefineName;
  121319. /**
  121320. * Gets or sets the texture associated with the node
  121321. */
  121322. texture: Nullable<Texture>;
  121323. /**
  121324. * Create a new TextureBlock
  121325. * @param name defines the block name
  121326. */
  121327. constructor(name: string);
  121328. /**
  121329. * Gets the current class name
  121330. * @returns the class name
  121331. */
  121332. getClassName(): string;
  121333. /**
  121334. * Gets the uv input component
  121335. */
  121336. readonly uv: NodeMaterialConnectionPoint;
  121337. /**
  121338. * Gets the rgba output component
  121339. */
  121340. readonly rgba: NodeMaterialConnectionPoint;
  121341. /**
  121342. * Gets the rgb output component
  121343. */
  121344. readonly rgb: NodeMaterialConnectionPoint;
  121345. /**
  121346. * Gets the r output component
  121347. */
  121348. readonly r: NodeMaterialConnectionPoint;
  121349. /**
  121350. * Gets the g output component
  121351. */
  121352. readonly g: NodeMaterialConnectionPoint;
  121353. /**
  121354. * Gets the b output component
  121355. */
  121356. readonly b: NodeMaterialConnectionPoint;
  121357. /**
  121358. * Gets the a output component
  121359. */
  121360. readonly a: NodeMaterialConnectionPoint;
  121361. readonly target: NodeMaterialBlockTargets;
  121362. autoConfigure(material: NodeMaterial): void;
  121363. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121365. isReady(): boolean;
  121366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121367. private readonly _isMixed;
  121368. private _injectVertexCode;
  121369. private _writeOutput;
  121370. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121371. protected _dumpPropertiesCode(): string;
  121372. serialize(): any;
  121373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121374. }
  121375. }
  121376. declare module BABYLON {
  121377. /**
  121378. * Class used to store shared data between 2 NodeMaterialBuildState
  121379. */
  121380. export class NodeMaterialBuildStateSharedData {
  121381. /**
  121382. * Gets the list of emitted varyings
  121383. */
  121384. temps: string[];
  121385. /**
  121386. * Gets the list of emitted varyings
  121387. */
  121388. varyings: string[];
  121389. /**
  121390. * Gets the varying declaration string
  121391. */
  121392. varyingDeclaration: string;
  121393. /**
  121394. * Input blocks
  121395. */
  121396. inputBlocks: InputBlock[];
  121397. /**
  121398. * Input blocks
  121399. */
  121400. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121401. /**
  121402. * Bindable blocks (Blocks that need to set data to the effect)
  121403. */
  121404. bindableBlocks: NodeMaterialBlock[];
  121405. /**
  121406. * List of blocks that can provide a compilation fallback
  121407. */
  121408. blocksWithFallbacks: NodeMaterialBlock[];
  121409. /**
  121410. * List of blocks that can provide a define update
  121411. */
  121412. blocksWithDefines: NodeMaterialBlock[];
  121413. /**
  121414. * List of blocks that can provide a repeatable content
  121415. */
  121416. repeatableContentBlocks: NodeMaterialBlock[];
  121417. /**
  121418. * List of blocks that can provide a dynamic list of uniforms
  121419. */
  121420. dynamicUniformBlocks: NodeMaterialBlock[];
  121421. /**
  121422. * List of blocks that can block the isReady function for the material
  121423. */
  121424. blockingBlocks: NodeMaterialBlock[];
  121425. /**
  121426. * Gets the list of animated inputs
  121427. */
  121428. animatedInputs: InputBlock[];
  121429. /**
  121430. * Build Id used to avoid multiple recompilations
  121431. */
  121432. buildId: number;
  121433. /** List of emitted variables */
  121434. variableNames: {
  121435. [key: string]: number;
  121436. };
  121437. /** List of emitted defines */
  121438. defineNames: {
  121439. [key: string]: number;
  121440. };
  121441. /** Should emit comments? */
  121442. emitComments: boolean;
  121443. /** Emit build activity */
  121444. verbose: boolean;
  121445. /** Gets or sets the hosting scene */
  121446. scene: Scene;
  121447. /**
  121448. * Gets the compilation hints emitted at compilation time
  121449. */
  121450. hints: {
  121451. needWorldViewMatrix: boolean;
  121452. needWorldViewProjectionMatrix: boolean;
  121453. needAlphaBlending: boolean;
  121454. needAlphaTesting: boolean;
  121455. };
  121456. /**
  121457. * List of compilation checks
  121458. */
  121459. checks: {
  121460. emitVertex: boolean;
  121461. emitFragment: boolean;
  121462. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121463. };
  121464. /** Creates a new shared data */
  121465. constructor();
  121466. /**
  121467. * Emits console errors and exceptions if there is a failing check
  121468. */
  121469. emitErrors(): void;
  121470. }
  121471. }
  121472. declare module BABYLON {
  121473. /**
  121474. * Class used to store node based material build state
  121475. */
  121476. export class NodeMaterialBuildState {
  121477. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121478. supportUniformBuffers: boolean;
  121479. /**
  121480. * Gets the list of emitted attributes
  121481. */
  121482. attributes: string[];
  121483. /**
  121484. * Gets the list of emitted uniforms
  121485. */
  121486. uniforms: string[];
  121487. /**
  121488. * Gets the list of emitted constants
  121489. */
  121490. constants: string[];
  121491. /**
  121492. * Gets the list of emitted samplers
  121493. */
  121494. samplers: string[];
  121495. /**
  121496. * Gets the list of emitted functions
  121497. */
  121498. functions: {
  121499. [key: string]: string;
  121500. };
  121501. /**
  121502. * Gets the list of emitted extensions
  121503. */
  121504. extensions: {
  121505. [key: string]: string;
  121506. };
  121507. /**
  121508. * Gets the target of the compilation state
  121509. */
  121510. target: NodeMaterialBlockTargets;
  121511. /**
  121512. * Gets the list of emitted counters
  121513. */
  121514. counters: {
  121515. [key: string]: number;
  121516. };
  121517. /**
  121518. * Shared data between multiple NodeMaterialBuildState instances
  121519. */
  121520. sharedData: NodeMaterialBuildStateSharedData;
  121521. /** @hidden */
  121522. _vertexState: NodeMaterialBuildState;
  121523. /** @hidden */
  121524. _attributeDeclaration: string;
  121525. /** @hidden */
  121526. _uniformDeclaration: string;
  121527. /** @hidden */
  121528. _constantDeclaration: string;
  121529. /** @hidden */
  121530. _samplerDeclaration: string;
  121531. /** @hidden */
  121532. _varyingTransfer: string;
  121533. private _repeatableContentAnchorIndex;
  121534. /** @hidden */
  121535. _builtCompilationString: string;
  121536. /**
  121537. * Gets the emitted compilation strings
  121538. */
  121539. compilationString: string;
  121540. /**
  121541. * Finalize the compilation strings
  121542. * @param state defines the current compilation state
  121543. */
  121544. finalize(state: NodeMaterialBuildState): void;
  121545. /** @hidden */
  121546. readonly _repeatableContentAnchor: string;
  121547. /** @hidden */
  121548. _getFreeVariableName(prefix: string): string;
  121549. /** @hidden */
  121550. _getFreeDefineName(prefix: string): string;
  121551. /** @hidden */
  121552. _excludeVariableName(name: string): void;
  121553. /** @hidden */
  121554. _emit2DSampler(name: string): void;
  121555. /** @hidden */
  121556. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  121557. /** @hidden */
  121558. _emitExtension(name: string, extension: string): void;
  121559. /** @hidden */
  121560. _emitFunction(name: string, code: string, comments: string): void;
  121561. /** @hidden */
  121562. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  121563. replaceStrings?: {
  121564. search: RegExp;
  121565. replace: string;
  121566. }[];
  121567. repeatKey?: string;
  121568. }): string;
  121569. /** @hidden */
  121570. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  121571. repeatKey?: string;
  121572. removeAttributes?: boolean;
  121573. removeUniforms?: boolean;
  121574. removeVaryings?: boolean;
  121575. removeIfDef?: boolean;
  121576. replaceStrings?: {
  121577. search: RegExp;
  121578. replace: string;
  121579. }[];
  121580. }, storeKey?: string): void;
  121581. /** @hidden */
  121582. _registerTempVariable(name: string): boolean;
  121583. /** @hidden */
  121584. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  121585. /** @hidden */
  121586. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  121587. /** @hidden */
  121588. _emitFloat(value: number): string;
  121589. }
  121590. }
  121591. declare module BABYLON {
  121592. /**
  121593. * Defines a block that can be used inside a node based material
  121594. */
  121595. export class NodeMaterialBlock {
  121596. private _buildId;
  121597. private _buildTarget;
  121598. private _target;
  121599. private _isFinalMerger;
  121600. private _isInput;
  121601. /** @hidden */
  121602. _codeVariableName: string;
  121603. /** @hidden */
  121604. _inputs: NodeMaterialConnectionPoint[];
  121605. /** @hidden */
  121606. _outputs: NodeMaterialConnectionPoint[];
  121607. /** @hidden */
  121608. _preparationId: number;
  121609. /**
  121610. * Gets or sets the name of the block
  121611. */
  121612. name: string;
  121613. /**
  121614. * Gets or sets the unique id of the node
  121615. */
  121616. uniqueId: number;
  121617. /**
  121618. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121619. */
  121620. readonly isFinalMerger: boolean;
  121621. /**
  121622. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121623. */
  121624. readonly isInput: boolean;
  121625. /**
  121626. * Gets or sets the build Id
  121627. */
  121628. buildId: number;
  121629. /**
  121630. * Gets or sets the target of the block
  121631. */
  121632. target: NodeMaterialBlockTargets;
  121633. /**
  121634. * Gets the list of input points
  121635. */
  121636. readonly inputs: NodeMaterialConnectionPoint[];
  121637. /** Gets the list of output points */
  121638. readonly outputs: NodeMaterialConnectionPoint[];
  121639. /**
  121640. * Find an input by its name
  121641. * @param name defines the name of the input to look for
  121642. * @returns the input or null if not found
  121643. */
  121644. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121645. /**
  121646. * Find an output by its name
  121647. * @param name defines the name of the outputto look for
  121648. * @returns the output or null if not found
  121649. */
  121650. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121651. /**
  121652. * Creates a new NodeMaterialBlock
  121653. * @param name defines the block name
  121654. * @param target defines the target of that block (Vertex by default)
  121655. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121656. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121657. */
  121658. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121659. /**
  121660. * Initialize the block and prepare the context for build
  121661. * @param state defines the state that will be used for the build
  121662. */
  121663. initialize(state: NodeMaterialBuildState): void;
  121664. /**
  121665. * Bind data to effect. Will only be called for blocks with isBindable === true
  121666. * @param effect defines the effect to bind data to
  121667. * @param nodeMaterial defines the hosting NodeMaterial
  121668. * @param mesh defines the mesh that will be rendered
  121669. */
  121670. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121671. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121672. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121673. protected _writeFloat(value: number): string;
  121674. /**
  121675. * Gets the current class name e.g. "NodeMaterialBlock"
  121676. * @returns the class name
  121677. */
  121678. getClassName(): string;
  121679. /**
  121680. * Register a new input. Must be called inside a block constructor
  121681. * @param name defines the connection point name
  121682. * @param type defines the connection point type
  121683. * @param isOptional defines a boolean indicating that this input can be omitted
  121684. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121685. * @returns the current block
  121686. */
  121687. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121688. /**
  121689. * Register a new output. Must be called inside a block constructor
  121690. * @param name defines the connection point name
  121691. * @param type defines the connection point type
  121692. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121693. * @returns the current block
  121694. */
  121695. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121696. /**
  121697. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121698. * @param forOutput defines an optional connection point to check compatibility with
  121699. * @returns the first available input or null
  121700. */
  121701. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121702. /**
  121703. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121704. * @param forBlock defines an optional block to check compatibility with
  121705. * @returns the first available input or null
  121706. */
  121707. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121708. /**
  121709. * Gets the sibling of the given output
  121710. * @param current defines the current output
  121711. * @returns the next output in the list or null
  121712. */
  121713. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121714. /**
  121715. * Connect current block with another block
  121716. * @param other defines the block to connect with
  121717. * @param options define the various options to help pick the right connections
  121718. * @returns the current block
  121719. */
  121720. connectTo(other: NodeMaterialBlock, options?: {
  121721. input?: string;
  121722. output?: string;
  121723. outputSwizzle?: string;
  121724. }): this | undefined;
  121725. protected _buildBlock(state: NodeMaterialBuildState): void;
  121726. /**
  121727. * Add uniforms, samplers and uniform buffers at compilation time
  121728. * @param state defines the state to update
  121729. * @param nodeMaterial defines the node material requesting the update
  121730. * @param defines defines the material defines to update
  121731. * @param uniformBuffers defines the list of uniform buffer names
  121732. */
  121733. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121734. /**
  121735. * Add potential fallbacks if shader compilation fails
  121736. * @param mesh defines the mesh to be rendered
  121737. * @param fallbacks defines the current prioritized list of fallbacks
  121738. */
  121739. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121740. /**
  121741. * Initialize defines for shader compilation
  121742. * @param mesh defines the mesh to be rendered
  121743. * @param nodeMaterial defines the node material requesting the update
  121744. * @param defines defines the material defines to update
  121745. * @param useInstances specifies that instances should be used
  121746. */
  121747. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121748. /**
  121749. * Update defines for shader compilation
  121750. * @param mesh defines the mesh to be rendered
  121751. * @param nodeMaterial defines the node material requesting the update
  121752. * @param defines defines the material defines to update
  121753. * @param useInstances specifies that instances should be used
  121754. */
  121755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121756. /**
  121757. * Lets the block try to connect some inputs automatically
  121758. * @param material defines the hosting NodeMaterial
  121759. */
  121760. autoConfigure(material: NodeMaterial): void;
  121761. /**
  121762. * Function called when a block is declared as repeatable content generator
  121763. * @param vertexShaderState defines the current compilation state for the vertex shader
  121764. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121765. * @param mesh defines the mesh to be rendered
  121766. * @param defines defines the material defines to update
  121767. */
  121768. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121769. /**
  121770. * Checks if the block is ready
  121771. * @param mesh defines the mesh to be rendered
  121772. * @param nodeMaterial defines the node material requesting the update
  121773. * @param defines defines the material defines to update
  121774. * @param useInstances specifies that instances should be used
  121775. * @returns true if the block is ready
  121776. */
  121777. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121778. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121779. private _processBuild;
  121780. /**
  121781. * Compile the current node and generate the shader code
  121782. * @param state defines the current compilation state (uniforms, samplers, current string)
  121783. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121784. * @returns true if already built
  121785. */
  121786. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121787. protected _inputRename(name: string): string;
  121788. protected _outputRename(name: string): string;
  121789. protected _dumpPropertiesCode(): string;
  121790. /** @hidden */
  121791. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121792. /** @hidden */
  121793. _dumpCodeForOutputConnections(): string;
  121794. /**
  121795. * Clone the current block to a new identical block
  121796. * @param scene defines the hosting scene
  121797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121798. * @returns a copy of the current block
  121799. */
  121800. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121801. /**
  121802. * Serializes this block in a JSON representation
  121803. * @returns the serialized block object
  121804. */
  121805. serialize(): any;
  121806. /** @hidden */
  121807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121808. /**
  121809. * Release resources
  121810. */
  121811. dispose(): void;
  121812. }
  121813. }
  121814. declare module BABYLON {
  121815. /**
  121816. * Enum defining the type of animations supported by InputBlock
  121817. */
  121818. export enum AnimatedInputBlockTypes {
  121819. /** No animation */
  121820. None = 0,
  121821. /** Time based animation. Will only work for floats */
  121822. Time = 1
  121823. }
  121824. }
  121825. declare module BABYLON {
  121826. /**
  121827. * Block used to expose an input value
  121828. */
  121829. export class InputBlock extends NodeMaterialBlock {
  121830. private _mode;
  121831. private _associatedVariableName;
  121832. private _storedValue;
  121833. private _valueCallback;
  121834. private _type;
  121835. private _animationType;
  121836. /** Gets or set a value used to limit the range of float values */
  121837. min: number;
  121838. /** Gets or set a value used to limit the range of float values */
  121839. max: number;
  121840. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121841. matrixMode: number;
  121842. /** @hidden */
  121843. _systemValue: Nullable<NodeMaterialSystemValues>;
  121844. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121845. visibleInInspector: boolean;
  121846. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121847. isConstant: boolean;
  121848. /**
  121849. * Gets or sets the connection point type (default is float)
  121850. */
  121851. readonly type: NodeMaterialBlockConnectionPointTypes;
  121852. /**
  121853. * Creates a new InputBlock
  121854. * @param name defines the block name
  121855. * @param target defines the target of that block (Vertex by default)
  121856. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121857. */
  121858. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121859. /**
  121860. * Gets the output component
  121861. */
  121862. readonly output: NodeMaterialConnectionPoint;
  121863. /**
  121864. * Set the source of this connection point to a vertex attribute
  121865. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121866. * @returns the current connection point
  121867. */
  121868. setAsAttribute(attributeName?: string): InputBlock;
  121869. /**
  121870. * Set the source of this connection point to a system value
  121871. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121872. * @returns the current connection point
  121873. */
  121874. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121875. /**
  121876. * Gets or sets the value of that point.
  121877. * Please note that this value will be ignored if valueCallback is defined
  121878. */
  121879. value: any;
  121880. /**
  121881. * Gets or sets a callback used to get the value of that point.
  121882. * Please note that setting this value will force the connection point to ignore the value property
  121883. */
  121884. valueCallback: () => any;
  121885. /**
  121886. * Gets or sets the associated variable name in the shader
  121887. */
  121888. associatedVariableName: string;
  121889. /** Gets or sets the type of animation applied to the input */
  121890. animationType: AnimatedInputBlockTypes;
  121891. /**
  121892. * Gets a boolean indicating that this connection point not defined yet
  121893. */
  121894. readonly isUndefined: boolean;
  121895. /**
  121896. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121897. * In this case the connection point name must be the name of the uniform to use.
  121898. * Can only be set on inputs
  121899. */
  121900. isUniform: boolean;
  121901. /**
  121902. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121903. * In this case the connection point name must be the name of the attribute to use
  121904. * Can only be set on inputs
  121905. */
  121906. isAttribute: boolean;
  121907. /**
  121908. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121909. * Can only be set on exit points
  121910. */
  121911. isVarying: boolean;
  121912. /**
  121913. * Gets a boolean indicating that the current connection point is a system value
  121914. */
  121915. readonly isSystemValue: boolean;
  121916. /**
  121917. * Gets or sets the current well known value or null if not defined as a system value
  121918. */
  121919. systemValue: Nullable<NodeMaterialSystemValues>;
  121920. /**
  121921. * Gets the current class name
  121922. * @returns the class name
  121923. */
  121924. getClassName(): string;
  121925. /**
  121926. * Animate the input if animationType !== None
  121927. * @param scene defines the rendering scene
  121928. */
  121929. animate(scene: Scene): void;
  121930. private _emitDefine;
  121931. initialize(state: NodeMaterialBuildState): void;
  121932. /**
  121933. * Set the input block to its default value (based on its type)
  121934. */
  121935. setDefaultValue(): void;
  121936. private _emitConstant;
  121937. private _emit;
  121938. /** @hidden */
  121939. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121940. /** @hidden */
  121941. _transmit(effect: Effect, scene: Scene): void;
  121942. protected _buildBlock(state: NodeMaterialBuildState): void;
  121943. protected _dumpPropertiesCode(): string;
  121944. serialize(): any;
  121945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121946. }
  121947. }
  121948. declare module BABYLON {
  121949. /**
  121950. * Defines a connection point for a block
  121951. */
  121952. export class NodeMaterialConnectionPoint {
  121953. /** @hidden */
  121954. _ownerBlock: NodeMaterialBlock;
  121955. /** @hidden */
  121956. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121957. private _endpoints;
  121958. private _associatedVariableName;
  121959. /** @hidden */
  121960. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121961. /** @hidden */
  121962. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121963. private _type;
  121964. /** @hidden */
  121965. _enforceAssociatedVariableName: boolean;
  121966. /**
  121967. * Gets or sets the additional types supported by this connection point
  121968. */
  121969. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121970. /**
  121971. * Gets or sets the additional types excluded by this connection point
  121972. */
  121973. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121974. /**
  121975. * Observable triggered when this point is connected
  121976. */
  121977. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  121978. /**
  121979. * Gets or sets the associated variable name in the shader
  121980. */
  121981. associatedVariableName: string;
  121982. /**
  121983. * Gets or sets the connection point type (default is float)
  121984. */
  121985. type: NodeMaterialBlockConnectionPointTypes;
  121986. /**
  121987. * Gets or sets the connection point name
  121988. */
  121989. name: string;
  121990. /**
  121991. * Gets or sets a boolean indicating that this connection point can be omitted
  121992. */
  121993. isOptional: boolean;
  121994. /**
  121995. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121996. */
  121997. define: string;
  121998. /** @hidden */
  121999. _prioritizeVertex: boolean;
  122000. private _target;
  122001. /** Gets or sets the target of that connection point */
  122002. target: NodeMaterialBlockTargets;
  122003. /**
  122004. * Gets a boolean indicating that the current point is connected
  122005. */
  122006. readonly isConnected: boolean;
  122007. /**
  122008. * Gets a boolean indicating that the current point is connected to an input block
  122009. */
  122010. readonly isConnectedToInputBlock: boolean;
  122011. /**
  122012. * Gets a the connected input block (if any)
  122013. */
  122014. readonly connectInputBlock: Nullable<InputBlock>;
  122015. /** Get the other side of the connection (if any) */
  122016. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122017. /** Get the block that owns this connection point */
  122018. readonly ownerBlock: NodeMaterialBlock;
  122019. /** Get the block connected on the other side of this connection (if any) */
  122020. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122021. /** Get the block connected on the endpoints of this connection (if any) */
  122022. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122023. /** Gets the list of connected endpoints */
  122024. readonly endpoints: NodeMaterialConnectionPoint[];
  122025. /** Gets a boolean indicating if that output point is connected to at least one input */
  122026. readonly hasEndpoints: boolean;
  122027. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122028. readonly isConnectedInVertexShader: boolean;
  122029. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122030. readonly isConnectedInFragmentShader: boolean;
  122031. /**
  122032. * Creates a new connection point
  122033. * @param name defines the connection point name
  122034. * @param ownerBlock defines the block hosting this connection point
  122035. */
  122036. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122037. /**
  122038. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122039. * @returns the class name
  122040. */
  122041. getClassName(): string;
  122042. /**
  122043. * Gets an boolean indicating if the current point can be connected to another point
  122044. * @param connectionPoint defines the other connection point
  122045. * @returns true if the connection is possible
  122046. */
  122047. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122048. /**
  122049. * Connect this point to another connection point
  122050. * @param connectionPoint defines the other connection point
  122051. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122052. * @returns the current connection point
  122053. */
  122054. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122055. /**
  122056. * Disconnect this point from one of his endpoint
  122057. * @param endpoint defines the other connection point
  122058. * @returns the current connection point
  122059. */
  122060. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122061. /**
  122062. * Serializes this point in a JSON representation
  122063. * @returns the serialized point object
  122064. */
  122065. serialize(): any;
  122066. /**
  122067. * Release resources
  122068. */
  122069. dispose(): void;
  122070. }
  122071. }
  122072. declare module BABYLON {
  122073. /**
  122074. * Block used to add support for vertex skinning (bones)
  122075. */
  122076. export class BonesBlock extends NodeMaterialBlock {
  122077. /**
  122078. * Creates a new BonesBlock
  122079. * @param name defines the block name
  122080. */
  122081. constructor(name: string);
  122082. /**
  122083. * Initialize the block and prepare the context for build
  122084. * @param state defines the state that will be used for the build
  122085. */
  122086. initialize(state: NodeMaterialBuildState): void;
  122087. /**
  122088. * Gets the current class name
  122089. * @returns the class name
  122090. */
  122091. getClassName(): string;
  122092. /**
  122093. * Gets the matrix indices input component
  122094. */
  122095. readonly matricesIndices: NodeMaterialConnectionPoint;
  122096. /**
  122097. * Gets the matrix weights input component
  122098. */
  122099. readonly matricesWeights: NodeMaterialConnectionPoint;
  122100. /**
  122101. * Gets the extra matrix indices input component
  122102. */
  122103. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122104. /**
  122105. * Gets the extra matrix weights input component
  122106. */
  122107. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122108. /**
  122109. * Gets the world input component
  122110. */
  122111. readonly world: NodeMaterialConnectionPoint;
  122112. /**
  122113. * Gets the output component
  122114. */
  122115. readonly output: NodeMaterialConnectionPoint;
  122116. autoConfigure(material: NodeMaterial): void;
  122117. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122120. protected _buildBlock(state: NodeMaterialBuildState): this;
  122121. }
  122122. }
  122123. declare module BABYLON {
  122124. /**
  122125. * Block used to add support for instances
  122126. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122127. */
  122128. export class InstancesBlock extends NodeMaterialBlock {
  122129. /**
  122130. * Creates a new InstancesBlock
  122131. * @param name defines the block name
  122132. */
  122133. constructor(name: string);
  122134. /**
  122135. * Gets the current class name
  122136. * @returns the class name
  122137. */
  122138. getClassName(): string;
  122139. /**
  122140. * Gets the first world row input component
  122141. */
  122142. readonly world0: NodeMaterialConnectionPoint;
  122143. /**
  122144. * Gets the second world row input component
  122145. */
  122146. readonly world1: NodeMaterialConnectionPoint;
  122147. /**
  122148. * Gets the third world row input component
  122149. */
  122150. readonly world2: NodeMaterialConnectionPoint;
  122151. /**
  122152. * Gets the forth world row input component
  122153. */
  122154. readonly world3: NodeMaterialConnectionPoint;
  122155. /**
  122156. * Gets the world input component
  122157. */
  122158. readonly world: NodeMaterialConnectionPoint;
  122159. /**
  122160. * Gets the output component
  122161. */
  122162. readonly output: NodeMaterialConnectionPoint;
  122163. autoConfigure(material: NodeMaterial): void;
  122164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122165. protected _buildBlock(state: NodeMaterialBuildState): this;
  122166. }
  122167. }
  122168. declare module BABYLON {
  122169. /**
  122170. * Block used to add morph targets support to vertex shader
  122171. */
  122172. export class MorphTargetsBlock extends NodeMaterialBlock {
  122173. private _repeatableContentAnchor;
  122174. private _repeatebleContentGenerated;
  122175. /**
  122176. * Create a new MorphTargetsBlock
  122177. * @param name defines the block name
  122178. */
  122179. constructor(name: string);
  122180. /**
  122181. * Gets the current class name
  122182. * @returns the class name
  122183. */
  122184. getClassName(): string;
  122185. /**
  122186. * Gets the position input component
  122187. */
  122188. readonly position: NodeMaterialConnectionPoint;
  122189. /**
  122190. * Gets the normal input component
  122191. */
  122192. readonly normal: NodeMaterialConnectionPoint;
  122193. /**
  122194. * Gets the tangent input component
  122195. */
  122196. readonly tangent: NodeMaterialConnectionPoint;
  122197. /**
  122198. * Gets the tangent input component
  122199. */
  122200. readonly uv: NodeMaterialConnectionPoint;
  122201. /**
  122202. * Gets the position output component
  122203. */
  122204. readonly positionOutput: NodeMaterialConnectionPoint;
  122205. /**
  122206. * Gets the normal output component
  122207. */
  122208. readonly normalOutput: NodeMaterialConnectionPoint;
  122209. /**
  122210. * Gets the tangent output component
  122211. */
  122212. readonly tangentOutput: NodeMaterialConnectionPoint;
  122213. /**
  122214. * Gets the tangent output component
  122215. */
  122216. readonly uvOutput: NodeMaterialConnectionPoint;
  122217. initialize(state: NodeMaterialBuildState): void;
  122218. autoConfigure(material: NodeMaterial): void;
  122219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122221. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122222. protected _buildBlock(state: NodeMaterialBuildState): this;
  122223. }
  122224. }
  122225. declare module BABYLON {
  122226. /**
  122227. * Block used to get data information from a light
  122228. */
  122229. export class LightInformationBlock extends NodeMaterialBlock {
  122230. private _lightDataUniformName;
  122231. private _lightColorUniformName;
  122232. private _lightTypeDefineName;
  122233. /**
  122234. * Gets or sets the light associated with this block
  122235. */
  122236. light: Nullable<Light>;
  122237. /**
  122238. * Creates a new LightInformationBlock
  122239. * @param name defines the block name
  122240. */
  122241. constructor(name: string);
  122242. /**
  122243. * Gets the current class name
  122244. * @returns the class name
  122245. */
  122246. getClassName(): string;
  122247. /**
  122248. * Gets the world position input component
  122249. */
  122250. readonly worldPosition: NodeMaterialConnectionPoint;
  122251. /**
  122252. * Gets the direction output component
  122253. */
  122254. readonly direction: NodeMaterialConnectionPoint;
  122255. /**
  122256. * Gets the direction output component
  122257. */
  122258. readonly color: NodeMaterialConnectionPoint;
  122259. /**
  122260. * Gets the direction output component
  122261. */
  122262. readonly intensity: NodeMaterialConnectionPoint;
  122263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122265. protected _buildBlock(state: NodeMaterialBuildState): this;
  122266. serialize(): any;
  122267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Block used to add image processing support to fragment shader
  122273. */
  122274. export class ImageProcessingBlock extends NodeMaterialBlock {
  122275. /**
  122276. * Create a new ImageProcessingBlock
  122277. * @param name defines the block name
  122278. */
  122279. constructor(name: string);
  122280. /**
  122281. * Gets the current class name
  122282. * @returns the class name
  122283. */
  122284. getClassName(): string;
  122285. /**
  122286. * Gets the color input component
  122287. */
  122288. readonly color: NodeMaterialConnectionPoint;
  122289. /**
  122290. * Gets the output component
  122291. */
  122292. readonly output: NodeMaterialConnectionPoint;
  122293. /**
  122294. * Initialize the block and prepare the context for build
  122295. * @param state defines the state that will be used for the build
  122296. */
  122297. initialize(state: NodeMaterialBuildState): void;
  122298. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122300. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122301. protected _buildBlock(state: NodeMaterialBuildState): this;
  122302. }
  122303. }
  122304. declare module BABYLON {
  122305. /**
  122306. * Block used to pertub normals based on a normal map
  122307. */
  122308. export class PerturbNormalBlock extends NodeMaterialBlock {
  122309. private _tangentSpaceParameterName;
  122310. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122311. invertX: boolean;
  122312. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122313. invertY: boolean;
  122314. /**
  122315. * Create a new PerturbNormalBlock
  122316. * @param name defines the block name
  122317. */
  122318. constructor(name: string);
  122319. /**
  122320. * Gets the current class name
  122321. * @returns the class name
  122322. */
  122323. getClassName(): string;
  122324. /**
  122325. * Gets the world position input component
  122326. */
  122327. readonly worldPosition: NodeMaterialConnectionPoint;
  122328. /**
  122329. * Gets the world normal input component
  122330. */
  122331. readonly worldNormal: NodeMaterialConnectionPoint;
  122332. /**
  122333. * Gets the uv input component
  122334. */
  122335. readonly uv: NodeMaterialConnectionPoint;
  122336. /**
  122337. * Gets the normal map color input component
  122338. */
  122339. readonly normalMapColor: NodeMaterialConnectionPoint;
  122340. /**
  122341. * Gets the strength input component
  122342. */
  122343. readonly strength: NodeMaterialConnectionPoint;
  122344. /**
  122345. * Gets the output component
  122346. */
  122347. readonly output: NodeMaterialConnectionPoint;
  122348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122350. autoConfigure(material: NodeMaterial): void;
  122351. protected _buildBlock(state: NodeMaterialBuildState): this;
  122352. protected _dumpPropertiesCode(): string;
  122353. serialize(): any;
  122354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122355. }
  122356. }
  122357. declare module BABYLON {
  122358. /**
  122359. * Block used to discard a pixel if a value is smaller than a cutoff
  122360. */
  122361. export class DiscardBlock extends NodeMaterialBlock {
  122362. /**
  122363. * Create a new DiscardBlock
  122364. * @param name defines the block name
  122365. */
  122366. constructor(name: string);
  122367. /**
  122368. * Gets the current class name
  122369. * @returns the class name
  122370. */
  122371. getClassName(): string;
  122372. /**
  122373. * Gets the color input component
  122374. */
  122375. readonly value: NodeMaterialConnectionPoint;
  122376. /**
  122377. * Gets the cutoff input component
  122378. */
  122379. readonly cutoff: NodeMaterialConnectionPoint;
  122380. protected _buildBlock(state: NodeMaterialBuildState): this;
  122381. }
  122382. }
  122383. declare module BABYLON {
  122384. /**
  122385. * Block used to add support for scene fog
  122386. */
  122387. export class FogBlock extends NodeMaterialBlock {
  122388. private _fogDistanceName;
  122389. private _fogParameters;
  122390. /**
  122391. * Create a new FogBlock
  122392. * @param name defines the block name
  122393. */
  122394. constructor(name: string);
  122395. /**
  122396. * Gets the current class name
  122397. * @returns the class name
  122398. */
  122399. getClassName(): string;
  122400. /**
  122401. * Gets the world position input component
  122402. */
  122403. readonly worldPosition: NodeMaterialConnectionPoint;
  122404. /**
  122405. * Gets the view input component
  122406. */
  122407. readonly view: NodeMaterialConnectionPoint;
  122408. /**
  122409. * Gets the color input component
  122410. */
  122411. readonly input: NodeMaterialConnectionPoint;
  122412. /**
  122413. * Gets the fog color input component
  122414. */
  122415. readonly fogColor: NodeMaterialConnectionPoint;
  122416. /**
  122417. * Gets the output component
  122418. */
  122419. readonly output: NodeMaterialConnectionPoint;
  122420. autoConfigure(material: NodeMaterial): void;
  122421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122423. protected _buildBlock(state: NodeMaterialBuildState): this;
  122424. }
  122425. }
  122426. declare module BABYLON {
  122427. /**
  122428. * Block used to add light in the fragment shader
  122429. */
  122430. export class LightBlock extends NodeMaterialBlock {
  122431. private _lightId;
  122432. /**
  122433. * Gets or sets the light associated with this block
  122434. */
  122435. light: Nullable<Light>;
  122436. /**
  122437. * Create a new LightBlock
  122438. * @param name defines the block name
  122439. */
  122440. constructor(name: string);
  122441. /**
  122442. * Gets the current class name
  122443. * @returns the class name
  122444. */
  122445. getClassName(): string;
  122446. /**
  122447. * Gets the world position input component
  122448. */
  122449. readonly worldPosition: NodeMaterialConnectionPoint;
  122450. /**
  122451. * Gets the world normal input component
  122452. */
  122453. readonly worldNormal: NodeMaterialConnectionPoint;
  122454. /**
  122455. * Gets the camera (or eye) position component
  122456. */
  122457. readonly cameraPosition: NodeMaterialConnectionPoint;
  122458. /**
  122459. * Gets the glossiness component
  122460. */
  122461. readonly glossiness: NodeMaterialConnectionPoint;
  122462. /**
  122463. * Gets the glossinness power component
  122464. */
  122465. readonly glossPower: NodeMaterialConnectionPoint;
  122466. /**
  122467. * Gets the diffuse color component
  122468. */
  122469. readonly diffuseColor: NodeMaterialConnectionPoint;
  122470. /**
  122471. * Gets the specular color component
  122472. */
  122473. readonly specularColor: NodeMaterialConnectionPoint;
  122474. /**
  122475. * Gets the diffuse output component
  122476. */
  122477. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122478. /**
  122479. * Gets the specular output component
  122480. */
  122481. readonly specularOutput: NodeMaterialConnectionPoint;
  122482. autoConfigure(material: NodeMaterial): void;
  122483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122484. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122486. private _injectVertexCode;
  122487. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122488. serialize(): any;
  122489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122490. }
  122491. }
  122492. declare module BABYLON {
  122493. /**
  122494. * Block used to multiply 2 values
  122495. */
  122496. export class MultiplyBlock extends NodeMaterialBlock {
  122497. /**
  122498. * Creates a new MultiplyBlock
  122499. * @param name defines the block name
  122500. */
  122501. constructor(name: string);
  122502. /**
  122503. * Gets the current class name
  122504. * @returns the class name
  122505. */
  122506. getClassName(): string;
  122507. /**
  122508. * Gets the left operand input component
  122509. */
  122510. readonly left: NodeMaterialConnectionPoint;
  122511. /**
  122512. * Gets the right operand input component
  122513. */
  122514. readonly right: NodeMaterialConnectionPoint;
  122515. /**
  122516. * Gets the output component
  122517. */
  122518. readonly output: NodeMaterialConnectionPoint;
  122519. protected _buildBlock(state: NodeMaterialBuildState): this;
  122520. }
  122521. }
  122522. declare module BABYLON {
  122523. /**
  122524. * Block used to add 2 vectors
  122525. */
  122526. export class AddBlock extends NodeMaterialBlock {
  122527. /**
  122528. * Creates a new AddBlock
  122529. * @param name defines the block name
  122530. */
  122531. constructor(name: string);
  122532. /**
  122533. * Gets the current class name
  122534. * @returns the class name
  122535. */
  122536. getClassName(): string;
  122537. /**
  122538. * Gets the left operand input component
  122539. */
  122540. readonly left: NodeMaterialConnectionPoint;
  122541. /**
  122542. * Gets the right operand input component
  122543. */
  122544. readonly right: NodeMaterialConnectionPoint;
  122545. /**
  122546. * Gets the output component
  122547. */
  122548. readonly output: NodeMaterialConnectionPoint;
  122549. protected _buildBlock(state: NodeMaterialBuildState): this;
  122550. }
  122551. }
  122552. declare module BABYLON {
  122553. /**
  122554. * Block used to scale a vector by a float
  122555. */
  122556. export class ScaleBlock extends NodeMaterialBlock {
  122557. /**
  122558. * Creates a new ScaleBlock
  122559. * @param name defines the block name
  122560. */
  122561. constructor(name: string);
  122562. /**
  122563. * Gets the current class name
  122564. * @returns the class name
  122565. */
  122566. getClassName(): string;
  122567. /**
  122568. * Gets the input component
  122569. */
  122570. readonly input: NodeMaterialConnectionPoint;
  122571. /**
  122572. * Gets the factor input component
  122573. */
  122574. readonly factor: NodeMaterialConnectionPoint;
  122575. /**
  122576. * Gets the output component
  122577. */
  122578. readonly output: NodeMaterialConnectionPoint;
  122579. protected _buildBlock(state: NodeMaterialBuildState): this;
  122580. }
  122581. }
  122582. declare module BABYLON {
  122583. /**
  122584. * Block used to clamp a float
  122585. */
  122586. export class ClampBlock extends NodeMaterialBlock {
  122587. /** Gets or sets the minimum range */
  122588. minimum: number;
  122589. /** Gets or sets the maximum range */
  122590. maximum: number;
  122591. /**
  122592. * Creates a new ClampBlock
  122593. * @param name defines the block name
  122594. */
  122595. constructor(name: string);
  122596. /**
  122597. * Gets the current class name
  122598. * @returns the class name
  122599. */
  122600. getClassName(): string;
  122601. /**
  122602. * Gets the value input component
  122603. */
  122604. readonly value: NodeMaterialConnectionPoint;
  122605. /**
  122606. * Gets the output component
  122607. */
  122608. readonly output: NodeMaterialConnectionPoint;
  122609. protected _buildBlock(state: NodeMaterialBuildState): this;
  122610. protected _dumpPropertiesCode(): string;
  122611. serialize(): any;
  122612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122613. }
  122614. }
  122615. declare module BABYLON {
  122616. /**
  122617. * Block used to apply a cross product between 2 vectors
  122618. */
  122619. export class CrossBlock extends NodeMaterialBlock {
  122620. /**
  122621. * Creates a new CrossBlock
  122622. * @param name defines the block name
  122623. */
  122624. constructor(name: string);
  122625. /**
  122626. * Gets the current class name
  122627. * @returns the class name
  122628. */
  122629. getClassName(): string;
  122630. /**
  122631. * Gets the left operand input component
  122632. */
  122633. readonly left: NodeMaterialConnectionPoint;
  122634. /**
  122635. * Gets the right operand input component
  122636. */
  122637. readonly right: NodeMaterialConnectionPoint;
  122638. /**
  122639. * Gets the output component
  122640. */
  122641. readonly output: NodeMaterialConnectionPoint;
  122642. protected _buildBlock(state: NodeMaterialBuildState): this;
  122643. }
  122644. }
  122645. declare module BABYLON {
  122646. /**
  122647. * Block used to apply a dot product between 2 vectors
  122648. */
  122649. export class DotBlock extends NodeMaterialBlock {
  122650. /**
  122651. * Creates a new DotBlock
  122652. * @param name defines the block name
  122653. */
  122654. constructor(name: string);
  122655. /**
  122656. * Gets the current class name
  122657. * @returns the class name
  122658. */
  122659. getClassName(): string;
  122660. /**
  122661. * Gets the left operand input component
  122662. */
  122663. readonly left: NodeMaterialConnectionPoint;
  122664. /**
  122665. * Gets the right operand input component
  122666. */
  122667. readonly right: NodeMaterialConnectionPoint;
  122668. /**
  122669. * Gets the output component
  122670. */
  122671. readonly output: NodeMaterialConnectionPoint;
  122672. protected _buildBlock(state: NodeMaterialBuildState): this;
  122673. }
  122674. }
  122675. declare module BABYLON {
  122676. /**
  122677. * Block used to remap a float from a range to a new one
  122678. */
  122679. export class RemapBlock extends NodeMaterialBlock {
  122680. /**
  122681. * Gets or sets the source range
  122682. */
  122683. sourceRange: Vector2;
  122684. /**
  122685. * Gets or sets the target range
  122686. */
  122687. targetRange: Vector2;
  122688. /**
  122689. * Creates a new RemapBlock
  122690. * @param name defines the block name
  122691. */
  122692. constructor(name: string);
  122693. /**
  122694. * Gets the current class name
  122695. * @returns the class name
  122696. */
  122697. getClassName(): string;
  122698. /**
  122699. * Gets the input component
  122700. */
  122701. readonly input: NodeMaterialConnectionPoint;
  122702. /**
  122703. * Gets the source min input component
  122704. */
  122705. readonly sourceMin: NodeMaterialConnectionPoint;
  122706. /**
  122707. * Gets the source max input component
  122708. */
  122709. readonly sourceMax: NodeMaterialConnectionPoint;
  122710. /**
  122711. * Gets the target min input component
  122712. */
  122713. readonly targetMin: NodeMaterialConnectionPoint;
  122714. /**
  122715. * Gets the target max input component
  122716. */
  122717. readonly targetMax: NodeMaterialConnectionPoint;
  122718. /**
  122719. * Gets the output component
  122720. */
  122721. readonly output: NodeMaterialConnectionPoint;
  122722. protected _buildBlock(state: NodeMaterialBuildState): this;
  122723. protected _dumpPropertiesCode(): string;
  122724. serialize(): any;
  122725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122726. }
  122727. }
  122728. declare module BABYLON {
  122729. /**
  122730. * Block used to normalize a vector
  122731. */
  122732. export class NormalizeBlock extends NodeMaterialBlock {
  122733. /**
  122734. * Creates a new NormalizeBlock
  122735. * @param name defines the block name
  122736. */
  122737. constructor(name: string);
  122738. /**
  122739. * Gets the current class name
  122740. * @returns the class name
  122741. */
  122742. getClassName(): string;
  122743. /**
  122744. * Gets the input component
  122745. */
  122746. readonly input: NodeMaterialConnectionPoint;
  122747. /**
  122748. * Gets the output component
  122749. */
  122750. readonly output: NodeMaterialConnectionPoint;
  122751. protected _buildBlock(state: NodeMaterialBuildState): this;
  122752. }
  122753. }
  122754. declare module BABYLON {
  122755. /**
  122756. * Operations supported by the Trigonometry block
  122757. */
  122758. export enum TrigonometryBlockOperations {
  122759. /** Cos */
  122760. Cos = 0,
  122761. /** Sin */
  122762. Sin = 1,
  122763. /** Abs */
  122764. Abs = 2,
  122765. /** Exp */
  122766. Exp = 3,
  122767. /** Exp2 */
  122768. Exp2 = 4,
  122769. /** Round */
  122770. Round = 5,
  122771. /** Floor */
  122772. Floor = 6,
  122773. /** Ceiling */
  122774. Ceiling = 7,
  122775. /** Square root */
  122776. Sqrt = 8,
  122777. /** Log */
  122778. Log = 9,
  122779. /** Tangent */
  122780. Tan = 10,
  122781. /** Arc tangent */
  122782. ArcTan = 11,
  122783. /** Arc cosinus */
  122784. ArcCos = 12,
  122785. /** Arc sinus */
  122786. ArcSin = 13,
  122787. /** Fraction */
  122788. Fract = 14,
  122789. /** Sign */
  122790. Sign = 15,
  122791. /** To radians (from degrees) */
  122792. Radians = 16,
  122793. /** To degrees (from radians) */
  122794. Degrees = 17
  122795. }
  122796. /**
  122797. * Block used to apply trigonometry operation to floats
  122798. */
  122799. export class TrigonometryBlock extends NodeMaterialBlock {
  122800. /**
  122801. * Gets or sets the operation applied by the block
  122802. */
  122803. operation: TrigonometryBlockOperations;
  122804. /**
  122805. * Creates a new TrigonometryBlock
  122806. * @param name defines the block name
  122807. */
  122808. constructor(name: string);
  122809. /**
  122810. * Gets the current class name
  122811. * @returns the class name
  122812. */
  122813. getClassName(): string;
  122814. /**
  122815. * Gets the input component
  122816. */
  122817. readonly input: NodeMaterialConnectionPoint;
  122818. /**
  122819. * Gets the output component
  122820. */
  122821. readonly output: NodeMaterialConnectionPoint;
  122822. protected _buildBlock(state: NodeMaterialBuildState): this;
  122823. serialize(): any;
  122824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122825. }
  122826. }
  122827. declare module BABYLON {
  122828. /**
  122829. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122830. */
  122831. export class ColorMergerBlock extends NodeMaterialBlock {
  122832. /**
  122833. * Create a new ColorMergerBlock
  122834. * @param name defines the block name
  122835. */
  122836. constructor(name: string);
  122837. /**
  122838. * Gets the current class name
  122839. * @returns the class name
  122840. */
  122841. getClassName(): string;
  122842. /**
  122843. * Gets the r component (input)
  122844. */
  122845. readonly r: NodeMaterialConnectionPoint;
  122846. /**
  122847. * Gets the g component (input)
  122848. */
  122849. readonly g: NodeMaterialConnectionPoint;
  122850. /**
  122851. * Gets the b component (input)
  122852. */
  122853. readonly b: NodeMaterialConnectionPoint;
  122854. /**
  122855. * Gets the a component (input)
  122856. */
  122857. readonly a: NodeMaterialConnectionPoint;
  122858. /**
  122859. * Gets the rgba component (output)
  122860. */
  122861. readonly rgba: NodeMaterialConnectionPoint;
  122862. /**
  122863. * Gets the rgb component (output)
  122864. */
  122865. readonly rgb: NodeMaterialConnectionPoint;
  122866. protected _buildBlock(state: NodeMaterialBuildState): this;
  122867. }
  122868. }
  122869. declare module BABYLON {
  122870. /**
  122871. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122872. */
  122873. export class VectorMergerBlock extends NodeMaterialBlock {
  122874. /**
  122875. * Create a new VectorMergerBlock
  122876. * @param name defines the block name
  122877. */
  122878. constructor(name: string);
  122879. /**
  122880. * Gets the current class name
  122881. * @returns the class name
  122882. */
  122883. getClassName(): string;
  122884. /**
  122885. * Gets the x component (input)
  122886. */
  122887. readonly x: NodeMaterialConnectionPoint;
  122888. /**
  122889. * Gets the y component (input)
  122890. */
  122891. readonly y: NodeMaterialConnectionPoint;
  122892. /**
  122893. * Gets the z component (input)
  122894. */
  122895. readonly z: NodeMaterialConnectionPoint;
  122896. /**
  122897. * Gets the w component (input)
  122898. */
  122899. readonly w: NodeMaterialConnectionPoint;
  122900. /**
  122901. * Gets the xyzw component (output)
  122902. */
  122903. readonly xyzw: NodeMaterialConnectionPoint;
  122904. /**
  122905. * Gets the xyz component (output)
  122906. */
  122907. readonly xyz: NodeMaterialConnectionPoint;
  122908. /**
  122909. * Gets the xy component (output)
  122910. */
  122911. readonly xy: NodeMaterialConnectionPoint;
  122912. protected _buildBlock(state: NodeMaterialBuildState): this;
  122913. }
  122914. }
  122915. declare module BABYLON {
  122916. /**
  122917. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122918. */
  122919. export class ColorSplitterBlock extends NodeMaterialBlock {
  122920. /**
  122921. * Create a new ColorSplitterBlock
  122922. * @param name defines the block name
  122923. */
  122924. constructor(name: string);
  122925. /**
  122926. * Gets the current class name
  122927. * @returns the class name
  122928. */
  122929. getClassName(): string;
  122930. /**
  122931. * Gets the rgba component (input)
  122932. */
  122933. readonly rgba: NodeMaterialConnectionPoint;
  122934. /**
  122935. * Gets the rgb component (input)
  122936. */
  122937. readonly rgbIn: NodeMaterialConnectionPoint;
  122938. /**
  122939. * Gets the rgb component (output)
  122940. */
  122941. readonly rgbOut: NodeMaterialConnectionPoint;
  122942. /**
  122943. * Gets the r component (output)
  122944. */
  122945. readonly r: NodeMaterialConnectionPoint;
  122946. /**
  122947. * Gets the g component (output)
  122948. */
  122949. readonly g: NodeMaterialConnectionPoint;
  122950. /**
  122951. * Gets the b component (output)
  122952. */
  122953. readonly b: NodeMaterialConnectionPoint;
  122954. /**
  122955. * Gets the a component (output)
  122956. */
  122957. readonly a: NodeMaterialConnectionPoint;
  122958. protected _inputRename(name: string): string;
  122959. protected _outputRename(name: string): string;
  122960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122961. }
  122962. }
  122963. declare module BABYLON {
  122964. /**
  122965. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122966. */
  122967. export class VectorSplitterBlock extends NodeMaterialBlock {
  122968. /**
  122969. * Create a new VectorSplitterBlock
  122970. * @param name defines the block name
  122971. */
  122972. constructor(name: string);
  122973. /**
  122974. * Gets the current class name
  122975. * @returns the class name
  122976. */
  122977. getClassName(): string;
  122978. /**
  122979. * Gets the xyzw component (input)
  122980. */
  122981. readonly xyzw: NodeMaterialConnectionPoint;
  122982. /**
  122983. * Gets the xyz component (input)
  122984. */
  122985. readonly xyzIn: NodeMaterialConnectionPoint;
  122986. /**
  122987. * Gets the xy component (input)
  122988. */
  122989. readonly xyIn: NodeMaterialConnectionPoint;
  122990. /**
  122991. * Gets the xyz component (output)
  122992. */
  122993. readonly xyzOut: NodeMaterialConnectionPoint;
  122994. /**
  122995. * Gets the xy component (output)
  122996. */
  122997. readonly xyOut: NodeMaterialConnectionPoint;
  122998. /**
  122999. * Gets the x component (output)
  123000. */
  123001. readonly x: NodeMaterialConnectionPoint;
  123002. /**
  123003. * Gets the y component (output)
  123004. */
  123005. readonly y: NodeMaterialConnectionPoint;
  123006. /**
  123007. * Gets the z component (output)
  123008. */
  123009. readonly z: NodeMaterialConnectionPoint;
  123010. /**
  123011. * Gets the w component (output)
  123012. */
  123013. readonly w: NodeMaterialConnectionPoint;
  123014. protected _inputRename(name: string): string;
  123015. protected _outputRename(name: string): string;
  123016. protected _buildBlock(state: NodeMaterialBuildState): this;
  123017. }
  123018. }
  123019. declare module BABYLON {
  123020. /**
  123021. * Block used to lerp between 2 values
  123022. */
  123023. export class LerpBlock extends NodeMaterialBlock {
  123024. /**
  123025. * Creates a new LerpBlock
  123026. * @param name defines the block name
  123027. */
  123028. constructor(name: string);
  123029. /**
  123030. * Gets the current class name
  123031. * @returns the class name
  123032. */
  123033. getClassName(): string;
  123034. /**
  123035. * Gets the left operand input component
  123036. */
  123037. readonly left: NodeMaterialConnectionPoint;
  123038. /**
  123039. * Gets the right operand input component
  123040. */
  123041. readonly right: NodeMaterialConnectionPoint;
  123042. /**
  123043. * Gets the gradient operand input component
  123044. */
  123045. readonly gradient: NodeMaterialConnectionPoint;
  123046. /**
  123047. * Gets the output component
  123048. */
  123049. readonly output: NodeMaterialConnectionPoint;
  123050. protected _buildBlock(state: NodeMaterialBuildState): this;
  123051. }
  123052. }
  123053. declare module BABYLON {
  123054. /**
  123055. * Block used to divide 2 vectors
  123056. */
  123057. export class DivideBlock extends NodeMaterialBlock {
  123058. /**
  123059. * Creates a new DivideBlock
  123060. * @param name defines the block name
  123061. */
  123062. constructor(name: string);
  123063. /**
  123064. * Gets the current class name
  123065. * @returns the class name
  123066. */
  123067. getClassName(): string;
  123068. /**
  123069. * Gets the left operand input component
  123070. */
  123071. readonly left: NodeMaterialConnectionPoint;
  123072. /**
  123073. * Gets the right operand input component
  123074. */
  123075. readonly right: NodeMaterialConnectionPoint;
  123076. /**
  123077. * Gets the output component
  123078. */
  123079. readonly output: NodeMaterialConnectionPoint;
  123080. protected _buildBlock(state: NodeMaterialBuildState): this;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * Block used to subtract 2 vectors
  123086. */
  123087. export class SubtractBlock extends NodeMaterialBlock {
  123088. /**
  123089. * Creates a new SubtractBlock
  123090. * @param name defines the block name
  123091. */
  123092. constructor(name: string);
  123093. /**
  123094. * Gets the current class name
  123095. * @returns the class name
  123096. */
  123097. getClassName(): string;
  123098. /**
  123099. * Gets the left operand input component
  123100. */
  123101. readonly left: NodeMaterialConnectionPoint;
  123102. /**
  123103. * Gets the right operand input component
  123104. */
  123105. readonly right: NodeMaterialConnectionPoint;
  123106. /**
  123107. * Gets the output component
  123108. */
  123109. readonly output: NodeMaterialConnectionPoint;
  123110. protected _buildBlock(state: NodeMaterialBuildState): this;
  123111. }
  123112. }
  123113. declare module BABYLON {
  123114. /**
  123115. * Block used to step a value
  123116. */
  123117. export class StepBlock extends NodeMaterialBlock {
  123118. /**
  123119. * Creates a new StepBlock
  123120. * @param name defines the block name
  123121. */
  123122. constructor(name: string);
  123123. /**
  123124. * Gets the current class name
  123125. * @returns the class name
  123126. */
  123127. getClassName(): string;
  123128. /**
  123129. * Gets the value operand input component
  123130. */
  123131. readonly value: NodeMaterialConnectionPoint;
  123132. /**
  123133. * Gets the edge operand input component
  123134. */
  123135. readonly edge: NodeMaterialConnectionPoint;
  123136. /**
  123137. * Gets the output component
  123138. */
  123139. readonly output: NodeMaterialConnectionPoint;
  123140. protected _buildBlock(state: NodeMaterialBuildState): this;
  123141. }
  123142. }
  123143. declare module BABYLON {
  123144. /**
  123145. * Block used to get the opposite (1 - x) of a value
  123146. */
  123147. export class OneMinusBlock extends NodeMaterialBlock {
  123148. /**
  123149. * Creates a new OneMinusBlock
  123150. * @param name defines the block name
  123151. */
  123152. constructor(name: string);
  123153. /**
  123154. * Gets the current class name
  123155. * @returns the class name
  123156. */
  123157. getClassName(): string;
  123158. /**
  123159. * Gets the input component
  123160. */
  123161. readonly input: NodeMaterialConnectionPoint;
  123162. /**
  123163. * Gets the output component
  123164. */
  123165. readonly output: NodeMaterialConnectionPoint;
  123166. protected _buildBlock(state: NodeMaterialBuildState): this;
  123167. }
  123168. }
  123169. declare module BABYLON {
  123170. /**
  123171. * Block used to get the view direction
  123172. */
  123173. export class ViewDirectionBlock extends NodeMaterialBlock {
  123174. /**
  123175. * Creates a new ViewDirectionBlock
  123176. * @param name defines the block name
  123177. */
  123178. constructor(name: string);
  123179. /**
  123180. * Gets the current class name
  123181. * @returns the class name
  123182. */
  123183. getClassName(): string;
  123184. /**
  123185. * Gets the world position component
  123186. */
  123187. readonly worldPosition: NodeMaterialConnectionPoint;
  123188. /**
  123189. * Gets the camera position component
  123190. */
  123191. readonly cameraPosition: NodeMaterialConnectionPoint;
  123192. /**
  123193. * Gets the output component
  123194. */
  123195. readonly output: NodeMaterialConnectionPoint;
  123196. autoConfigure(material: NodeMaterial): void;
  123197. protected _buildBlock(state: NodeMaterialBuildState): this;
  123198. }
  123199. }
  123200. declare module BABYLON {
  123201. /**
  123202. * Block used to compute fresnel value
  123203. */
  123204. export class FresnelBlock extends NodeMaterialBlock {
  123205. /**
  123206. * Create a new FresnelBlock
  123207. * @param name defines the block name
  123208. */
  123209. constructor(name: string);
  123210. /**
  123211. * Gets the current class name
  123212. * @returns the class name
  123213. */
  123214. getClassName(): string;
  123215. /**
  123216. * Gets the world normal input component
  123217. */
  123218. readonly worldNormal: NodeMaterialConnectionPoint;
  123219. /**
  123220. * Gets the view direction input component
  123221. */
  123222. readonly viewDirection: NodeMaterialConnectionPoint;
  123223. /**
  123224. * Gets the bias input component
  123225. */
  123226. readonly bias: NodeMaterialConnectionPoint;
  123227. /**
  123228. * Gets the camera (or eye) position component
  123229. */
  123230. readonly power: NodeMaterialConnectionPoint;
  123231. /**
  123232. * Gets the fresnel output component
  123233. */
  123234. readonly fresnel: NodeMaterialConnectionPoint;
  123235. autoConfigure(material: NodeMaterial): void;
  123236. protected _buildBlock(state: NodeMaterialBuildState): this;
  123237. }
  123238. }
  123239. declare module BABYLON {
  123240. /**
  123241. * Block used to get the max of 2 values
  123242. */
  123243. export class MaxBlock extends NodeMaterialBlock {
  123244. /**
  123245. * Creates a new MaxBlock
  123246. * @param name defines the block name
  123247. */
  123248. constructor(name: string);
  123249. /**
  123250. * Gets the current class name
  123251. * @returns the class name
  123252. */
  123253. getClassName(): string;
  123254. /**
  123255. * Gets the left operand input component
  123256. */
  123257. readonly left: NodeMaterialConnectionPoint;
  123258. /**
  123259. * Gets the right operand input component
  123260. */
  123261. readonly right: NodeMaterialConnectionPoint;
  123262. /**
  123263. * Gets the output component
  123264. */
  123265. readonly output: NodeMaterialConnectionPoint;
  123266. protected _buildBlock(state: NodeMaterialBuildState): this;
  123267. }
  123268. }
  123269. declare module BABYLON {
  123270. /**
  123271. * Block used to get the min of 2 values
  123272. */
  123273. export class MinBlock extends NodeMaterialBlock {
  123274. /**
  123275. * Creates a new MinBlock
  123276. * @param name defines the block name
  123277. */
  123278. constructor(name: string);
  123279. /**
  123280. * Gets the current class name
  123281. * @returns the class name
  123282. */
  123283. getClassName(): string;
  123284. /**
  123285. * Gets the left operand input component
  123286. */
  123287. readonly left: NodeMaterialConnectionPoint;
  123288. /**
  123289. * Gets the right operand input component
  123290. */
  123291. readonly right: NodeMaterialConnectionPoint;
  123292. /**
  123293. * Gets the output component
  123294. */
  123295. readonly output: NodeMaterialConnectionPoint;
  123296. protected _buildBlock(state: NodeMaterialBuildState): this;
  123297. }
  123298. }
  123299. declare module BABYLON {
  123300. /**
  123301. * Block used to get the distance between 2 values
  123302. */
  123303. export class DistanceBlock extends NodeMaterialBlock {
  123304. /**
  123305. * Creates a new DistanceBlock
  123306. * @param name defines the block name
  123307. */
  123308. constructor(name: string);
  123309. /**
  123310. * Gets the current class name
  123311. * @returns the class name
  123312. */
  123313. getClassName(): string;
  123314. /**
  123315. * Gets the left operand input component
  123316. */
  123317. readonly left: NodeMaterialConnectionPoint;
  123318. /**
  123319. * Gets the right operand input component
  123320. */
  123321. readonly right: NodeMaterialConnectionPoint;
  123322. /**
  123323. * Gets the output component
  123324. */
  123325. readonly output: NodeMaterialConnectionPoint;
  123326. protected _buildBlock(state: NodeMaterialBuildState): this;
  123327. }
  123328. }
  123329. declare module BABYLON {
  123330. /**
  123331. * Block used to get the length of a vector
  123332. */
  123333. export class LengthBlock extends NodeMaterialBlock {
  123334. /**
  123335. * Creates a new LengthBlock
  123336. * @param name defines the block name
  123337. */
  123338. constructor(name: string);
  123339. /**
  123340. * Gets the current class name
  123341. * @returns the class name
  123342. */
  123343. getClassName(): string;
  123344. /**
  123345. * Gets the value input component
  123346. */
  123347. readonly value: NodeMaterialConnectionPoint;
  123348. /**
  123349. * Gets the output component
  123350. */
  123351. readonly output: NodeMaterialConnectionPoint;
  123352. protected _buildBlock(state: NodeMaterialBuildState): this;
  123353. }
  123354. }
  123355. declare module BABYLON {
  123356. /**
  123357. * Block used to get negative version of a value (i.e. x * -1)
  123358. */
  123359. export class NegateBlock extends NodeMaterialBlock {
  123360. /**
  123361. * Creates a new NegateBlock
  123362. * @param name defines the block name
  123363. */
  123364. constructor(name: string);
  123365. /**
  123366. * Gets the current class name
  123367. * @returns the class name
  123368. */
  123369. getClassName(): string;
  123370. /**
  123371. * Gets the value input component
  123372. */
  123373. readonly value: NodeMaterialConnectionPoint;
  123374. /**
  123375. * Gets the output component
  123376. */
  123377. readonly output: NodeMaterialConnectionPoint;
  123378. protected _buildBlock(state: NodeMaterialBuildState): this;
  123379. }
  123380. }
  123381. declare module BABYLON {
  123382. /**
  123383. * Block used to get the value of the first parameter raised to the power of the second
  123384. */
  123385. export class PowBlock extends NodeMaterialBlock {
  123386. /**
  123387. * Creates a new PowBlock
  123388. * @param name defines the block name
  123389. */
  123390. constructor(name: string);
  123391. /**
  123392. * Gets the current class name
  123393. * @returns the class name
  123394. */
  123395. getClassName(): string;
  123396. /**
  123397. * Gets the value operand input component
  123398. */
  123399. readonly value: NodeMaterialConnectionPoint;
  123400. /**
  123401. * Gets the power operand input component
  123402. */
  123403. readonly power: NodeMaterialConnectionPoint;
  123404. /**
  123405. * Gets the output component
  123406. */
  123407. readonly output: NodeMaterialConnectionPoint;
  123408. protected _buildBlock(state: NodeMaterialBuildState): this;
  123409. }
  123410. }
  123411. declare module BABYLON {
  123412. /**
  123413. * Block used to get a random number
  123414. */
  123415. export class RandomNumberBlock extends NodeMaterialBlock {
  123416. /**
  123417. * Creates a new RandomNumberBlock
  123418. * @param name defines the block name
  123419. */
  123420. constructor(name: string);
  123421. /**
  123422. * Gets the current class name
  123423. * @returns the class name
  123424. */
  123425. getClassName(): string;
  123426. /**
  123427. * Gets the seed input component
  123428. */
  123429. readonly seed: NodeMaterialConnectionPoint;
  123430. /**
  123431. * Gets the output component
  123432. */
  123433. readonly output: NodeMaterialConnectionPoint;
  123434. protected _buildBlock(state: NodeMaterialBuildState): this;
  123435. }
  123436. }
  123437. declare module BABYLON {
  123438. /**
  123439. * Block used to compute arc tangent of 2 values
  123440. */
  123441. export class ArcTan2Block extends NodeMaterialBlock {
  123442. /**
  123443. * Creates a new ArcTan2Block
  123444. * @param name defines the block name
  123445. */
  123446. constructor(name: string);
  123447. /**
  123448. * Gets the current class name
  123449. * @returns the class name
  123450. */
  123451. getClassName(): string;
  123452. /**
  123453. * Gets the x operand input component
  123454. */
  123455. readonly x: NodeMaterialConnectionPoint;
  123456. /**
  123457. * Gets the y operand input component
  123458. */
  123459. readonly y: NodeMaterialConnectionPoint;
  123460. /**
  123461. * Gets the output component
  123462. */
  123463. readonly output: NodeMaterialConnectionPoint;
  123464. protected _buildBlock(state: NodeMaterialBuildState): this;
  123465. }
  123466. }
  123467. declare module BABYLON {
  123468. /**
  123469. * Block used to smooth step a value
  123470. */
  123471. export class SmoothStepBlock extends NodeMaterialBlock {
  123472. /**
  123473. * Creates a new SmoothStepBlock
  123474. * @param name defines the block name
  123475. */
  123476. constructor(name: string);
  123477. /**
  123478. * Gets the current class name
  123479. * @returns the class name
  123480. */
  123481. getClassName(): string;
  123482. /**
  123483. * Gets the value operand input component
  123484. */
  123485. readonly value: NodeMaterialConnectionPoint;
  123486. /**
  123487. * Gets the first edge operand input component
  123488. */
  123489. readonly edge0: NodeMaterialConnectionPoint;
  123490. /**
  123491. * Gets the second edge operand input component
  123492. */
  123493. readonly edge1: NodeMaterialConnectionPoint;
  123494. /**
  123495. * Gets the output component
  123496. */
  123497. readonly output: NodeMaterialConnectionPoint;
  123498. protected _buildBlock(state: NodeMaterialBuildState): this;
  123499. }
  123500. }
  123501. declare module BABYLON {
  123502. /**
  123503. * Block used to get the reciprocal (1 / x) of a value
  123504. */
  123505. export class ReciprocalBlock extends NodeMaterialBlock {
  123506. /**
  123507. * Creates a new ReciprocalBlock
  123508. * @param name defines the block name
  123509. */
  123510. constructor(name: string);
  123511. /**
  123512. * Gets the current class name
  123513. * @returns the class name
  123514. */
  123515. getClassName(): string;
  123516. /**
  123517. * Gets the input component
  123518. */
  123519. readonly input: NodeMaterialConnectionPoint;
  123520. /**
  123521. * Gets the output component
  123522. */
  123523. readonly output: NodeMaterialConnectionPoint;
  123524. protected _buildBlock(state: NodeMaterialBuildState): this;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * Block used to replace a color by another one
  123530. */
  123531. export class ReplaceColorBlock extends NodeMaterialBlock {
  123532. /**
  123533. * Creates a new ReplaceColorBlock
  123534. * @param name defines the block name
  123535. */
  123536. constructor(name: string);
  123537. /**
  123538. * Gets the current class name
  123539. * @returns the class name
  123540. */
  123541. getClassName(): string;
  123542. /**
  123543. * Gets the value input component
  123544. */
  123545. readonly value: NodeMaterialConnectionPoint;
  123546. /**
  123547. * Gets the reference input component
  123548. */
  123549. readonly reference: NodeMaterialConnectionPoint;
  123550. /**
  123551. * Gets the distance input component
  123552. */
  123553. readonly distance: NodeMaterialConnectionPoint;
  123554. /**
  123555. * Gets the replacement input component
  123556. */
  123557. readonly replacement: NodeMaterialConnectionPoint;
  123558. /**
  123559. * Gets the output component
  123560. */
  123561. readonly output: NodeMaterialConnectionPoint;
  123562. protected _buildBlock(state: NodeMaterialBuildState): this;
  123563. }
  123564. }
  123565. declare module BABYLON {
  123566. /**
  123567. * Block used to posterize a value
  123568. * @see https://en.wikipedia.org/wiki/Posterization
  123569. */
  123570. export class PosterizeBlock extends NodeMaterialBlock {
  123571. /**
  123572. * Creates a new PosterizeBlock
  123573. * @param name defines the block name
  123574. */
  123575. constructor(name: string);
  123576. /**
  123577. * Gets the current class name
  123578. * @returns the class name
  123579. */
  123580. getClassName(): string;
  123581. /**
  123582. * Gets the value input component
  123583. */
  123584. readonly value: NodeMaterialConnectionPoint;
  123585. /**
  123586. * Gets the steps input component
  123587. */
  123588. readonly steps: NodeMaterialConnectionPoint;
  123589. /**
  123590. * Gets the output component
  123591. */
  123592. readonly output: NodeMaterialConnectionPoint;
  123593. protected _buildBlock(state: NodeMaterialBuildState): this;
  123594. }
  123595. }
  123596. declare module BABYLON {
  123597. /**
  123598. * Operations supported by the Wave block
  123599. */
  123600. export enum WaveBlockKind {
  123601. /** SawTooth */
  123602. SawTooth = 0,
  123603. /** Square */
  123604. Square = 1,
  123605. /** Triangle */
  123606. Triangle = 2
  123607. }
  123608. /**
  123609. * Block used to apply wave operation to floats
  123610. */
  123611. export class WaveBlock extends NodeMaterialBlock {
  123612. /**
  123613. * Gets or sets the kibnd of wave to be applied by the block
  123614. */
  123615. kind: WaveBlockKind;
  123616. /**
  123617. * Creates a new WaveBlock
  123618. * @param name defines the block name
  123619. */
  123620. constructor(name: string);
  123621. /**
  123622. * Gets the current class name
  123623. * @returns the class name
  123624. */
  123625. getClassName(): string;
  123626. /**
  123627. * Gets the input component
  123628. */
  123629. readonly input: NodeMaterialConnectionPoint;
  123630. /**
  123631. * Gets the output component
  123632. */
  123633. readonly output: NodeMaterialConnectionPoint;
  123634. protected _buildBlock(state: NodeMaterialBuildState): this;
  123635. serialize(): any;
  123636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123637. }
  123638. }
  123639. declare module BABYLON {
  123640. /**
  123641. * Class used to store a color step for the GradientBlock
  123642. */
  123643. export class GradientBlockColorStep {
  123644. /**
  123645. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123646. */
  123647. step: number;
  123648. /**
  123649. * Gets or sets the color associated with this step
  123650. */
  123651. color: Color3;
  123652. /**
  123653. * Creates a new GradientBlockColorStep
  123654. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123655. * @param color defines the color associated with this step
  123656. */
  123657. constructor(
  123658. /**
  123659. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123660. */
  123661. step: number,
  123662. /**
  123663. * Gets or sets the color associated with this step
  123664. */
  123665. color: Color3);
  123666. }
  123667. /**
  123668. * Block used to return a color from a gradient based on an input value between 0 and 1
  123669. */
  123670. export class GradientBlock extends NodeMaterialBlock {
  123671. /**
  123672. * Gets or sets the list of color steps
  123673. */
  123674. colorSteps: GradientBlockColorStep[];
  123675. /**
  123676. * Creates a new GradientBlock
  123677. * @param name defines the block name
  123678. */
  123679. constructor(name: string);
  123680. /**
  123681. * Gets the current class name
  123682. * @returns the class name
  123683. */
  123684. getClassName(): string;
  123685. /**
  123686. * Gets the gradient input component
  123687. */
  123688. readonly gradient: NodeMaterialConnectionPoint;
  123689. /**
  123690. * Gets the output component
  123691. */
  123692. readonly output: NodeMaterialConnectionPoint;
  123693. private _writeColorConstant;
  123694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123695. serialize(): any;
  123696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123697. protected _dumpPropertiesCode(): string;
  123698. }
  123699. }
  123700. declare module BABYLON {
  123701. /**
  123702. * Block used to normalize lerp between 2 values
  123703. */
  123704. export class NLerpBlock extends NodeMaterialBlock {
  123705. /**
  123706. * Creates a new NLerpBlock
  123707. * @param name defines the block name
  123708. */
  123709. constructor(name: string);
  123710. /**
  123711. * Gets the current class name
  123712. * @returns the class name
  123713. */
  123714. getClassName(): string;
  123715. /**
  123716. * Gets the left operand input component
  123717. */
  123718. readonly left: NodeMaterialConnectionPoint;
  123719. /**
  123720. * Gets the right operand input component
  123721. */
  123722. readonly right: NodeMaterialConnectionPoint;
  123723. /**
  123724. * Gets the gradient operand input component
  123725. */
  123726. readonly gradient: NodeMaterialConnectionPoint;
  123727. /**
  123728. * Gets the output component
  123729. */
  123730. readonly output: NodeMaterialConnectionPoint;
  123731. protected _buildBlock(state: NodeMaterialBuildState): this;
  123732. }
  123733. }
  123734. declare module BABYLON {
  123735. /**
  123736. * Block used to test if the fragment shader is front facing
  123737. */
  123738. export class FrontFacingBlock extends NodeMaterialBlock {
  123739. /**
  123740. * Creates a new FrontFacingBlock
  123741. * @param name defines the block name
  123742. */
  123743. constructor(name: string);
  123744. /**
  123745. * Gets the current class name
  123746. * @returns the class name
  123747. */
  123748. getClassName(): string;
  123749. /**
  123750. * Gets the world normal component
  123751. */
  123752. readonly worldNormal: NodeMaterialConnectionPoint;
  123753. /**
  123754. * Gets the view direction input component
  123755. */
  123756. readonly viewDirection: NodeMaterialConnectionPoint;
  123757. /**
  123758. * Gets the output component
  123759. */
  123760. readonly output: NodeMaterialConnectionPoint;
  123761. autoConfigure(material: NodeMaterial): void;
  123762. protected _buildBlock(state: NodeMaterialBuildState): this;
  123763. }
  123764. }
  123765. declare module BABYLON {
  123766. /**
  123767. * Effect Render Options
  123768. */
  123769. export interface IEffectRendererOptions {
  123770. /**
  123771. * Defines the vertices positions.
  123772. */
  123773. positions?: number[];
  123774. /**
  123775. * Defines the indices.
  123776. */
  123777. indices?: number[];
  123778. }
  123779. /**
  123780. * Helper class to render one or more effects
  123781. */
  123782. export class EffectRenderer {
  123783. private engine;
  123784. private static _DefaultOptions;
  123785. private _vertexBuffers;
  123786. private _indexBuffer;
  123787. private _ringBufferIndex;
  123788. private _ringScreenBuffer;
  123789. private _fullscreenViewport;
  123790. private _getNextFrameBuffer;
  123791. /**
  123792. * Creates an effect renderer
  123793. * @param engine the engine to use for rendering
  123794. * @param options defines the options of the effect renderer
  123795. */
  123796. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123797. /**
  123798. * Sets the current viewport in normalized coordinates 0-1
  123799. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123800. */
  123801. setViewport(viewport?: Viewport): void;
  123802. /**
  123803. * Binds the embedded attributes buffer to the effect.
  123804. * @param effect Defines the effect to bind the attributes for
  123805. */
  123806. bindBuffers(effect: Effect): void;
  123807. /**
  123808. * Sets the current effect wrapper to use during draw.
  123809. * The effect needs to be ready before calling this api.
  123810. * This also sets the default full screen position attribute.
  123811. * @param effectWrapper Defines the effect to draw with
  123812. */
  123813. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123814. /**
  123815. * Draws a full screen quad.
  123816. */
  123817. draw(): void;
  123818. /**
  123819. * renders one or more effects to a specified texture
  123820. * @param effectWrappers list of effects to renderer
  123821. * @param outputTexture texture to draw to, if null it will render to the screen
  123822. */
  123823. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123824. /**
  123825. * Disposes of the effect renderer
  123826. */
  123827. dispose(): void;
  123828. }
  123829. /**
  123830. * Options to create an EffectWrapper
  123831. */
  123832. interface EffectWrapperCreationOptions {
  123833. /**
  123834. * Engine to use to create the effect
  123835. */
  123836. engine: ThinEngine;
  123837. /**
  123838. * Fragment shader for the effect
  123839. */
  123840. fragmentShader: string;
  123841. /**
  123842. * Vertex shader for the effect
  123843. */
  123844. vertexShader?: string;
  123845. /**
  123846. * Attributes to use in the shader
  123847. */
  123848. attributeNames?: Array<string>;
  123849. /**
  123850. * Uniforms to use in the shader
  123851. */
  123852. uniformNames?: Array<string>;
  123853. /**
  123854. * Texture sampler names to use in the shader
  123855. */
  123856. samplerNames?: Array<string>;
  123857. /**
  123858. * The friendly name of the effect displayed in Spector.
  123859. */
  123860. name?: string;
  123861. }
  123862. /**
  123863. * Wraps an effect to be used for rendering
  123864. */
  123865. export class EffectWrapper {
  123866. /**
  123867. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123868. */
  123869. onApplyObservable: Observable<{}>;
  123870. /**
  123871. * The underlying effect
  123872. */
  123873. effect: Effect;
  123874. /**
  123875. * Creates an effect to be renderer
  123876. * @param creationOptions options to create the effect
  123877. */
  123878. constructor(creationOptions: EffectWrapperCreationOptions);
  123879. /**
  123880. * Disposes of the effect wrapper
  123881. */
  123882. dispose(): void;
  123883. }
  123884. }
  123885. declare module BABYLON {
  123886. /**
  123887. * Helper class to push actions to a pool of workers.
  123888. */
  123889. export class WorkerPool implements IDisposable {
  123890. private _workerInfos;
  123891. private _pendingActions;
  123892. /**
  123893. * Constructor
  123894. * @param workers Array of workers to use for actions
  123895. */
  123896. constructor(workers: Array<Worker>);
  123897. /**
  123898. * Terminates all workers and clears any pending actions.
  123899. */
  123900. dispose(): void;
  123901. /**
  123902. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123903. * pended until a worker has completed its action.
  123904. * @param action The action to perform. Call onComplete when the action is complete.
  123905. */
  123906. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123907. private _execute;
  123908. }
  123909. }
  123910. declare module BABYLON {
  123911. /**
  123912. * Configuration for Draco compression
  123913. */
  123914. export interface IDracoCompressionConfiguration {
  123915. /**
  123916. * Configuration for the decoder.
  123917. */
  123918. decoder: {
  123919. /**
  123920. * The url to the WebAssembly module.
  123921. */
  123922. wasmUrl?: string;
  123923. /**
  123924. * The url to the WebAssembly binary.
  123925. */
  123926. wasmBinaryUrl?: string;
  123927. /**
  123928. * The url to the fallback JavaScript module.
  123929. */
  123930. fallbackUrl?: string;
  123931. };
  123932. }
  123933. /**
  123934. * Draco compression (https://google.github.io/draco/)
  123935. *
  123936. * This class wraps the Draco module.
  123937. *
  123938. * **Encoder**
  123939. *
  123940. * The encoder is not currently implemented.
  123941. *
  123942. * **Decoder**
  123943. *
  123944. * 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.
  123945. *
  123946. * To update the configuration, use the following code:
  123947. * ```javascript
  123948. * DracoCompression.Configuration = {
  123949. * decoder: {
  123950. * wasmUrl: "<url to the WebAssembly library>",
  123951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123952. * fallbackUrl: "<url to the fallback JavaScript library>",
  123953. * }
  123954. * };
  123955. * ```
  123956. *
  123957. * 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.
  123958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123960. *
  123961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123962. * ```javascript
  123963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123964. * ```
  123965. *
  123966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123967. */
  123968. export class DracoCompression implements IDisposable {
  123969. private _workerPoolPromise?;
  123970. private _decoderModulePromise?;
  123971. /**
  123972. * The configuration. Defaults to the following urls:
  123973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123976. */
  123977. static Configuration: IDracoCompressionConfiguration;
  123978. /**
  123979. * Returns true if the decoder configuration is available.
  123980. */
  123981. static readonly DecoderAvailable: boolean;
  123982. /**
  123983. * Default number of workers to create when creating the draco compression object.
  123984. */
  123985. static DefaultNumWorkers: number;
  123986. private static GetDefaultNumWorkers;
  123987. private static _Default;
  123988. /**
  123989. * Default instance for the draco compression object.
  123990. */
  123991. static readonly Default: DracoCompression;
  123992. /**
  123993. * Constructor
  123994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123995. */
  123996. constructor(numWorkers?: number);
  123997. /**
  123998. * Stop all async operations and release resources.
  123999. */
  124000. dispose(): void;
  124001. /**
  124002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124003. * @returns a promise that resolves when ready
  124004. */
  124005. whenReadyAsync(): Promise<void>;
  124006. /**
  124007. * Decode Draco compressed mesh data to vertex data.
  124008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124010. * @returns A promise that resolves with the decoded vertex data
  124011. */
  124012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124013. [kind: string]: number;
  124014. }): Promise<VertexData>;
  124015. }
  124016. }
  124017. declare module BABYLON {
  124018. /**
  124019. * Class for building Constructive Solid Geometry
  124020. */
  124021. export class CSG {
  124022. private polygons;
  124023. /**
  124024. * The world matrix
  124025. */
  124026. matrix: Matrix;
  124027. /**
  124028. * Stores the position
  124029. */
  124030. position: Vector3;
  124031. /**
  124032. * Stores the rotation
  124033. */
  124034. rotation: Vector3;
  124035. /**
  124036. * Stores the rotation quaternion
  124037. */
  124038. rotationQuaternion: Nullable<Quaternion>;
  124039. /**
  124040. * Stores the scaling vector
  124041. */
  124042. scaling: Vector3;
  124043. /**
  124044. * Convert the Mesh to CSG
  124045. * @param mesh The Mesh to convert to CSG
  124046. * @returns A new CSG from the Mesh
  124047. */
  124048. static FromMesh(mesh: Mesh): CSG;
  124049. /**
  124050. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124051. * @param polygons Polygons used to construct a CSG solid
  124052. */
  124053. private static FromPolygons;
  124054. /**
  124055. * Clones, or makes a deep copy, of the CSG
  124056. * @returns A new CSG
  124057. */
  124058. clone(): CSG;
  124059. /**
  124060. * Unions this CSG with another CSG
  124061. * @param csg The CSG to union against this CSG
  124062. * @returns The unioned CSG
  124063. */
  124064. union(csg: CSG): CSG;
  124065. /**
  124066. * Unions this CSG with another CSG in place
  124067. * @param csg The CSG to union against this CSG
  124068. */
  124069. unionInPlace(csg: CSG): void;
  124070. /**
  124071. * Subtracts this CSG with another CSG
  124072. * @param csg The CSG to subtract against this CSG
  124073. * @returns A new CSG
  124074. */
  124075. subtract(csg: CSG): CSG;
  124076. /**
  124077. * Subtracts this CSG with another CSG in place
  124078. * @param csg The CSG to subtact against this CSG
  124079. */
  124080. subtractInPlace(csg: CSG): void;
  124081. /**
  124082. * Intersect this CSG with another CSG
  124083. * @param csg The CSG to intersect against this CSG
  124084. * @returns A new CSG
  124085. */
  124086. intersect(csg: CSG): CSG;
  124087. /**
  124088. * Intersects this CSG with another CSG in place
  124089. * @param csg The CSG to intersect against this CSG
  124090. */
  124091. intersectInPlace(csg: CSG): void;
  124092. /**
  124093. * Return a new CSG solid with solid and empty space switched. This solid is
  124094. * not modified.
  124095. * @returns A new CSG solid with solid and empty space switched
  124096. */
  124097. inverse(): CSG;
  124098. /**
  124099. * Inverses the CSG in place
  124100. */
  124101. inverseInPlace(): void;
  124102. /**
  124103. * This is used to keep meshes transformations so they can be restored
  124104. * when we build back a Babylon Mesh
  124105. * NB : All CSG operations are performed in world coordinates
  124106. * @param csg The CSG to copy the transform attributes from
  124107. * @returns This CSG
  124108. */
  124109. copyTransformAttributes(csg: CSG): CSG;
  124110. /**
  124111. * Build Raw mesh from CSG
  124112. * Coordinates here are in world space
  124113. * @param name The name of the mesh geometry
  124114. * @param scene The Scene
  124115. * @param keepSubMeshes Specifies if the submeshes should be kept
  124116. * @returns A new Mesh
  124117. */
  124118. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124119. /**
  124120. * Build Mesh from CSG taking material and transforms into account
  124121. * @param name The name of the Mesh
  124122. * @param material The material of the Mesh
  124123. * @param scene The Scene
  124124. * @param keepSubMeshes Specifies if submeshes should be kept
  124125. * @returns The new Mesh
  124126. */
  124127. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124128. }
  124129. }
  124130. declare module BABYLON {
  124131. /**
  124132. * Class used to create a trail following a mesh
  124133. */
  124134. export class TrailMesh extends Mesh {
  124135. private _generator;
  124136. private _autoStart;
  124137. private _running;
  124138. private _diameter;
  124139. private _length;
  124140. private _sectionPolygonPointsCount;
  124141. private _sectionVectors;
  124142. private _sectionNormalVectors;
  124143. private _beforeRenderObserver;
  124144. /**
  124145. * @constructor
  124146. * @param name The value used by scene.getMeshByName() to do a lookup.
  124147. * @param generator The mesh to generate a trail.
  124148. * @param scene The scene to add this mesh to.
  124149. * @param diameter Diameter of trailing mesh. Default is 1.
  124150. * @param length Length of trailing mesh. Default is 60.
  124151. * @param autoStart Automatically start trailing mesh. Default true.
  124152. */
  124153. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124154. /**
  124155. * "TrailMesh"
  124156. * @returns "TrailMesh"
  124157. */
  124158. getClassName(): string;
  124159. private _createMesh;
  124160. /**
  124161. * Start trailing mesh.
  124162. */
  124163. start(): void;
  124164. /**
  124165. * Stop trailing mesh.
  124166. */
  124167. stop(): void;
  124168. /**
  124169. * Update trailing mesh geometry.
  124170. */
  124171. update(): void;
  124172. /**
  124173. * Returns a new TrailMesh object.
  124174. * @param name is a string, the name given to the new mesh
  124175. * @param newGenerator use new generator object for cloned trail mesh
  124176. * @returns a new mesh
  124177. */
  124178. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124179. /**
  124180. * Serializes this trail mesh
  124181. * @param serializationObject object to write serialization to
  124182. */
  124183. serialize(serializationObject: any): void;
  124184. /**
  124185. * Parses a serialized trail mesh
  124186. * @param parsedMesh the serialized mesh
  124187. * @param scene the scene to create the trail mesh in
  124188. * @returns the created trail mesh
  124189. */
  124190. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124191. }
  124192. }
  124193. declare module BABYLON {
  124194. /**
  124195. * Class containing static functions to help procedurally build meshes
  124196. */
  124197. export class TiledBoxBuilder {
  124198. /**
  124199. * Creates a box mesh
  124200. * 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)
  124201. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124205. * @param name defines the name of the mesh
  124206. * @param options defines the options used to create the mesh
  124207. * @param scene defines the hosting scene
  124208. * @returns the box mesh
  124209. */
  124210. static CreateTiledBox(name: string, options: {
  124211. pattern?: number;
  124212. width?: number;
  124213. height?: number;
  124214. depth?: number;
  124215. tileSize?: number;
  124216. tileWidth?: number;
  124217. tileHeight?: number;
  124218. alignHorizontal?: number;
  124219. alignVertical?: number;
  124220. faceUV?: Vector4[];
  124221. faceColors?: Color4[];
  124222. sideOrientation?: number;
  124223. updatable?: boolean;
  124224. }, scene?: Nullable<Scene>): Mesh;
  124225. }
  124226. }
  124227. declare module BABYLON {
  124228. /**
  124229. * Class containing static functions to help procedurally build meshes
  124230. */
  124231. export class TorusKnotBuilder {
  124232. /**
  124233. * Creates a torus knot mesh
  124234. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124235. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124236. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124237. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124241. * @param name defines the name of the mesh
  124242. * @param options defines the options used to create the mesh
  124243. * @param scene defines the hosting scene
  124244. * @returns the torus knot mesh
  124245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124246. */
  124247. static CreateTorusKnot(name: string, options: {
  124248. radius?: number;
  124249. tube?: number;
  124250. radialSegments?: number;
  124251. tubularSegments?: number;
  124252. p?: number;
  124253. q?: number;
  124254. updatable?: boolean;
  124255. sideOrientation?: number;
  124256. frontUVs?: Vector4;
  124257. backUVs?: Vector4;
  124258. }, scene: any): Mesh;
  124259. }
  124260. }
  124261. declare module BABYLON {
  124262. /**
  124263. * Polygon
  124264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124265. */
  124266. export class Polygon {
  124267. /**
  124268. * Creates a rectangle
  124269. * @param xmin bottom X coord
  124270. * @param ymin bottom Y coord
  124271. * @param xmax top X coord
  124272. * @param ymax top Y coord
  124273. * @returns points that make the resulting rectation
  124274. */
  124275. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124276. /**
  124277. * Creates a circle
  124278. * @param radius radius of circle
  124279. * @param cx scale in x
  124280. * @param cy scale in y
  124281. * @param numberOfSides number of sides that make up the circle
  124282. * @returns points that make the resulting circle
  124283. */
  124284. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124285. /**
  124286. * Creates a polygon from input string
  124287. * @param input Input polygon data
  124288. * @returns the parsed points
  124289. */
  124290. static Parse(input: string): Vector2[];
  124291. /**
  124292. * Starts building a polygon from x and y coordinates
  124293. * @param x x coordinate
  124294. * @param y y coordinate
  124295. * @returns the started path2
  124296. */
  124297. static StartingAt(x: number, y: number): Path2;
  124298. }
  124299. /**
  124300. * Builds a polygon
  124301. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124302. */
  124303. export class PolygonMeshBuilder {
  124304. private _points;
  124305. private _outlinepoints;
  124306. private _holes;
  124307. private _name;
  124308. private _scene;
  124309. private _epoints;
  124310. private _eholes;
  124311. private _addToepoint;
  124312. /**
  124313. * Babylon reference to the earcut plugin.
  124314. */
  124315. bjsEarcut: any;
  124316. /**
  124317. * Creates a PolygonMeshBuilder
  124318. * @param name name of the builder
  124319. * @param contours Path of the polygon
  124320. * @param scene scene to add to when creating the mesh
  124321. * @param earcutInjection can be used to inject your own earcut reference
  124322. */
  124323. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124324. /**
  124325. * Adds a whole within the polygon
  124326. * @param hole Array of points defining the hole
  124327. * @returns this
  124328. */
  124329. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124330. /**
  124331. * Creates the polygon
  124332. * @param updatable If the mesh should be updatable
  124333. * @param depth The depth of the mesh created
  124334. * @returns the created mesh
  124335. */
  124336. build(updatable?: boolean, depth?: number): Mesh;
  124337. /**
  124338. * Creates the polygon
  124339. * @param depth The depth of the mesh created
  124340. * @returns the created VertexData
  124341. */
  124342. buildVertexData(depth?: number): VertexData;
  124343. /**
  124344. * Adds a side to the polygon
  124345. * @param positions points that make the polygon
  124346. * @param normals normals of the polygon
  124347. * @param uvs uvs of the polygon
  124348. * @param indices indices of the polygon
  124349. * @param bounds bounds of the polygon
  124350. * @param points points of the polygon
  124351. * @param depth depth of the polygon
  124352. * @param flip flip of the polygon
  124353. */
  124354. private addSide;
  124355. }
  124356. }
  124357. declare module BABYLON {
  124358. /**
  124359. * Class containing static functions to help procedurally build meshes
  124360. */
  124361. export class PolygonBuilder {
  124362. /**
  124363. * Creates a polygon mesh
  124364. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124365. * * 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
  124366. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124369. * * Remember you can only change the shape positions, not their number when updating a polygon
  124370. * @param name defines the name of the mesh
  124371. * @param options defines the options used to create the mesh
  124372. * @param scene defines the hosting scene
  124373. * @param earcutInjection can be used to inject your own earcut reference
  124374. * @returns the polygon mesh
  124375. */
  124376. static CreatePolygon(name: string, options: {
  124377. shape: Vector3[];
  124378. holes?: Vector3[][];
  124379. depth?: number;
  124380. faceUV?: Vector4[];
  124381. faceColors?: Color4[];
  124382. updatable?: boolean;
  124383. sideOrientation?: number;
  124384. frontUVs?: Vector4;
  124385. backUVs?: Vector4;
  124386. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124387. /**
  124388. * Creates an extruded polygon mesh, with depth in the Y direction.
  124389. * * 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)
  124390. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124391. * @param name defines the name of the mesh
  124392. * @param options defines the options used to create the mesh
  124393. * @param scene defines the hosting scene
  124394. * @param earcutInjection can be used to inject your own earcut reference
  124395. * @returns the polygon mesh
  124396. */
  124397. static ExtrudePolygon(name: string, options: {
  124398. shape: Vector3[];
  124399. holes?: Vector3[][];
  124400. depth?: number;
  124401. faceUV?: Vector4[];
  124402. faceColors?: Color4[];
  124403. updatable?: boolean;
  124404. sideOrientation?: number;
  124405. frontUVs?: Vector4;
  124406. backUVs?: Vector4;
  124407. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124408. }
  124409. }
  124410. declare module BABYLON {
  124411. /**
  124412. * Class containing static functions to help procedurally build meshes
  124413. */
  124414. export class LatheBuilder {
  124415. /**
  124416. * Creates lathe mesh.
  124417. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124418. * * 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
  124419. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124420. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124421. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124422. * * 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
  124423. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124424. * * 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
  124425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124429. * @param name defines the name of the mesh
  124430. * @param options defines the options used to create the mesh
  124431. * @param scene defines the hosting scene
  124432. * @returns the lathe mesh
  124433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124434. */
  124435. static CreateLathe(name: string, options: {
  124436. shape: Vector3[];
  124437. radius?: number;
  124438. tessellation?: number;
  124439. clip?: number;
  124440. arc?: number;
  124441. closed?: boolean;
  124442. updatable?: boolean;
  124443. sideOrientation?: number;
  124444. frontUVs?: Vector4;
  124445. backUVs?: Vector4;
  124446. cap?: number;
  124447. invertUV?: boolean;
  124448. }, scene?: Nullable<Scene>): Mesh;
  124449. }
  124450. }
  124451. declare module BABYLON {
  124452. /**
  124453. * Class containing static functions to help procedurally build meshes
  124454. */
  124455. export class TiledPlaneBuilder {
  124456. /**
  124457. * Creates a tiled plane mesh
  124458. * * The parameter `pattern` will, depending on value, do nothing or
  124459. * * * flip (reflect about central vertical) alternate tiles across and up
  124460. * * * flip every tile on alternate rows
  124461. * * * rotate (180 degs) alternate tiles across and up
  124462. * * * rotate every tile on alternate rows
  124463. * * * flip and rotate alternate tiles across and up
  124464. * * * flip and rotate every tile on alternate rows
  124465. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124466. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124469. * * 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)
  124470. * * 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)
  124471. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124472. * @param name defines the name of the mesh
  124473. * @param options defines the options used to create the mesh
  124474. * @param scene defines the hosting scene
  124475. * @returns the box mesh
  124476. */
  124477. static CreateTiledPlane(name: string, options: {
  124478. pattern?: number;
  124479. tileSize?: number;
  124480. tileWidth?: number;
  124481. tileHeight?: number;
  124482. size?: number;
  124483. width?: number;
  124484. height?: number;
  124485. alignHorizontal?: number;
  124486. alignVertical?: number;
  124487. sideOrientation?: number;
  124488. frontUVs?: Vector4;
  124489. backUVs?: Vector4;
  124490. updatable?: boolean;
  124491. }, scene?: Nullable<Scene>): Mesh;
  124492. }
  124493. }
  124494. declare module BABYLON {
  124495. /**
  124496. * Class containing static functions to help procedurally build meshes
  124497. */
  124498. export class TubeBuilder {
  124499. /**
  124500. * Creates a tube mesh.
  124501. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124502. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124503. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124504. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124505. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124506. * * 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)
  124507. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124508. * * 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
  124509. * * 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
  124510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124514. * @param name defines the name of the mesh
  124515. * @param options defines the options used to create the mesh
  124516. * @param scene defines the hosting scene
  124517. * @returns the tube mesh
  124518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124519. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124520. */
  124521. static CreateTube(name: string, options: {
  124522. path: Vector3[];
  124523. radius?: number;
  124524. tessellation?: number;
  124525. radiusFunction?: {
  124526. (i: number, distance: number): number;
  124527. };
  124528. cap?: number;
  124529. arc?: number;
  124530. updatable?: boolean;
  124531. sideOrientation?: number;
  124532. frontUVs?: Vector4;
  124533. backUVs?: Vector4;
  124534. instance?: Mesh;
  124535. invertUV?: boolean;
  124536. }, scene?: Nullable<Scene>): Mesh;
  124537. }
  124538. }
  124539. declare module BABYLON {
  124540. /**
  124541. * Class containing static functions to help procedurally build meshes
  124542. */
  124543. export class IcoSphereBuilder {
  124544. /**
  124545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124547. * * 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`)
  124548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124549. * * 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
  124550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124553. * @param name defines the name of the mesh
  124554. * @param options defines the options used to create the mesh
  124555. * @param scene defines the hosting scene
  124556. * @returns the icosahedron mesh
  124557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124558. */
  124559. static CreateIcoSphere(name: string, options: {
  124560. radius?: number;
  124561. radiusX?: number;
  124562. radiusY?: number;
  124563. radiusZ?: number;
  124564. flat?: boolean;
  124565. subdivisions?: number;
  124566. sideOrientation?: number;
  124567. frontUVs?: Vector4;
  124568. backUVs?: Vector4;
  124569. updatable?: boolean;
  124570. }, scene?: Nullable<Scene>): Mesh;
  124571. }
  124572. }
  124573. declare module BABYLON {
  124574. /**
  124575. * Class containing static functions to help procedurally build meshes
  124576. */
  124577. export class DecalBuilder {
  124578. /**
  124579. * Creates a decal mesh.
  124580. * 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
  124581. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124582. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124583. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124584. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124585. * @param name defines the name of the mesh
  124586. * @param sourceMesh defines the mesh where the decal must be applied
  124587. * @param options defines the options used to create the mesh
  124588. * @param scene defines the hosting scene
  124589. * @returns the decal mesh
  124590. * @see https://doc.babylonjs.com/how_to/decals
  124591. */
  124592. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124593. position?: Vector3;
  124594. normal?: Vector3;
  124595. size?: Vector3;
  124596. angle?: number;
  124597. }): Mesh;
  124598. }
  124599. }
  124600. declare module BABYLON {
  124601. /**
  124602. * Class containing static functions to help procedurally build meshes
  124603. */
  124604. export class MeshBuilder {
  124605. /**
  124606. * Creates a box mesh
  124607. * * The parameter `size` sets the size (float) of each box side (default 1)
  124608. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  124609. * * 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)
  124610. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124614. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124615. * @param name defines the name of the mesh
  124616. * @param options defines the options used to create the mesh
  124617. * @param scene defines the hosting scene
  124618. * @returns the box mesh
  124619. */
  124620. static CreateBox(name: string, options: {
  124621. size?: number;
  124622. width?: number;
  124623. height?: number;
  124624. depth?: number;
  124625. faceUV?: Vector4[];
  124626. faceColors?: Color4[];
  124627. sideOrientation?: number;
  124628. frontUVs?: Vector4;
  124629. backUVs?: Vector4;
  124630. updatable?: boolean;
  124631. }, scene?: Nullable<Scene>): Mesh;
  124632. /**
  124633. * Creates a tiled box mesh
  124634. * * faceTiles sets the pattern, tile size and number of tiles for a face
  124635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124636. * @param name defines the name of the mesh
  124637. * @param options defines the options used to create the mesh
  124638. * @param scene defines the hosting scene
  124639. * @returns the tiled box mesh
  124640. */
  124641. static CreateTiledBox(name: string, options: {
  124642. pattern?: number;
  124643. size?: number;
  124644. width?: number;
  124645. height?: number;
  124646. depth: number;
  124647. tileSize?: number;
  124648. tileWidth?: number;
  124649. tileHeight?: number;
  124650. faceUV?: Vector4[];
  124651. faceColors?: Color4[];
  124652. alignHorizontal?: number;
  124653. alignVertical?: number;
  124654. sideOrientation?: number;
  124655. updatable?: boolean;
  124656. }, scene?: Nullable<Scene>): Mesh;
  124657. /**
  124658. * Creates a sphere mesh
  124659. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124660. * * 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`)
  124661. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124662. * * 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
  124663. * * 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)
  124664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124667. * @param name defines the name of the mesh
  124668. * @param options defines the options used to create the mesh
  124669. * @param scene defines the hosting scene
  124670. * @returns the sphere mesh
  124671. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124672. */
  124673. static CreateSphere(name: string, options: {
  124674. segments?: number;
  124675. diameter?: number;
  124676. diameterX?: number;
  124677. diameterY?: number;
  124678. diameterZ?: number;
  124679. arc?: number;
  124680. slice?: number;
  124681. sideOrientation?: number;
  124682. frontUVs?: Vector4;
  124683. backUVs?: Vector4;
  124684. updatable?: boolean;
  124685. }, scene?: Nullable<Scene>): Mesh;
  124686. /**
  124687. * Creates a plane polygonal mesh. By default, this is a disc
  124688. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124689. * * 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
  124690. * * 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
  124691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124694. * @param name defines the name of the mesh
  124695. * @param options defines the options used to create the mesh
  124696. * @param scene defines the hosting scene
  124697. * @returns the plane polygonal mesh
  124698. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124699. */
  124700. static CreateDisc(name: string, options: {
  124701. radius?: number;
  124702. tessellation?: number;
  124703. arc?: number;
  124704. updatable?: boolean;
  124705. sideOrientation?: number;
  124706. frontUVs?: Vector4;
  124707. backUVs?: Vector4;
  124708. }, scene?: Nullable<Scene>): Mesh;
  124709. /**
  124710. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124711. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124712. * * 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`)
  124713. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124714. * * 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
  124715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124718. * @param name defines the name of the mesh
  124719. * @param options defines the options used to create the mesh
  124720. * @param scene defines the hosting scene
  124721. * @returns the icosahedron mesh
  124722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124723. */
  124724. static CreateIcoSphere(name: string, options: {
  124725. radius?: number;
  124726. radiusX?: number;
  124727. radiusY?: number;
  124728. radiusZ?: number;
  124729. flat?: boolean;
  124730. subdivisions?: number;
  124731. sideOrientation?: number;
  124732. frontUVs?: Vector4;
  124733. backUVs?: Vector4;
  124734. updatable?: boolean;
  124735. }, scene?: Nullable<Scene>): Mesh;
  124736. /**
  124737. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124738. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124739. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124740. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124741. * * 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
  124742. * * 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
  124743. * * 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
  124744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124747. * * 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
  124748. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124749. * * 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
  124750. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124752. * @param name defines the name of the mesh
  124753. * @param options defines the options used to create the mesh
  124754. * @param scene defines the hosting scene
  124755. * @returns the ribbon mesh
  124756. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124758. */
  124759. static CreateRibbon(name: string, options: {
  124760. pathArray: Vector3[][];
  124761. closeArray?: boolean;
  124762. closePath?: boolean;
  124763. offset?: number;
  124764. updatable?: boolean;
  124765. sideOrientation?: number;
  124766. frontUVs?: Vector4;
  124767. backUVs?: Vector4;
  124768. instance?: Mesh;
  124769. invertUV?: boolean;
  124770. uvs?: Vector2[];
  124771. colors?: Color4[];
  124772. }, scene?: Nullable<Scene>): Mesh;
  124773. /**
  124774. * Creates a cylinder or a cone mesh
  124775. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124776. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124777. * * 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.
  124778. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124779. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124780. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124781. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124782. * * 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).
  124783. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124784. * * 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).
  124785. * * 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
  124786. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124787. * * 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
  124788. * * 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.
  124789. * * If `enclose` is false, a ring surface is one element.
  124790. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124791. * * 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
  124792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124795. * @param name defines the name of the mesh
  124796. * @param options defines the options used to create the mesh
  124797. * @param scene defines the hosting scene
  124798. * @returns the cylinder mesh
  124799. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124800. */
  124801. static CreateCylinder(name: string, options: {
  124802. height?: number;
  124803. diameterTop?: number;
  124804. diameterBottom?: number;
  124805. diameter?: number;
  124806. tessellation?: number;
  124807. subdivisions?: number;
  124808. arc?: number;
  124809. faceColors?: Color4[];
  124810. faceUV?: Vector4[];
  124811. updatable?: boolean;
  124812. hasRings?: boolean;
  124813. enclose?: boolean;
  124814. cap?: number;
  124815. sideOrientation?: number;
  124816. frontUVs?: Vector4;
  124817. backUVs?: Vector4;
  124818. }, scene?: Nullable<Scene>): Mesh;
  124819. /**
  124820. * Creates a torus mesh
  124821. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124822. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124823. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124827. * @param name defines the name of the mesh
  124828. * @param options defines the options used to create the mesh
  124829. * @param scene defines the hosting scene
  124830. * @returns the torus mesh
  124831. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124832. */
  124833. static CreateTorus(name: string, options: {
  124834. diameter?: number;
  124835. thickness?: number;
  124836. tessellation?: number;
  124837. updatable?: boolean;
  124838. sideOrientation?: number;
  124839. frontUVs?: Vector4;
  124840. backUVs?: Vector4;
  124841. }, scene?: Nullable<Scene>): Mesh;
  124842. /**
  124843. * Creates a torus knot mesh
  124844. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124845. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124846. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124847. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124851. * @param name defines the name of the mesh
  124852. * @param options defines the options used to create the mesh
  124853. * @param scene defines the hosting scene
  124854. * @returns the torus knot mesh
  124855. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124856. */
  124857. static CreateTorusKnot(name: string, options: {
  124858. radius?: number;
  124859. tube?: number;
  124860. radialSegments?: number;
  124861. tubularSegments?: number;
  124862. p?: number;
  124863. q?: number;
  124864. updatable?: boolean;
  124865. sideOrientation?: number;
  124866. frontUVs?: Vector4;
  124867. backUVs?: Vector4;
  124868. }, scene?: Nullable<Scene>): Mesh;
  124869. /**
  124870. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124871. * * 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
  124872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124873. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124874. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124875. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124877. * * 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
  124878. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124881. * @param name defines the name of the new line system
  124882. * @param options defines the options used to create the line system
  124883. * @param scene defines the hosting scene
  124884. * @returns a new line system mesh
  124885. */
  124886. static CreateLineSystem(name: string, options: {
  124887. lines: Vector3[][];
  124888. updatable?: boolean;
  124889. instance?: Nullable<LinesMesh>;
  124890. colors?: Nullable<Color4[][]>;
  124891. useVertexAlpha?: boolean;
  124892. }, scene: Nullable<Scene>): LinesMesh;
  124893. /**
  124894. * Creates a line mesh
  124895. * 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
  124896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124897. * * The parameter `points` is an array successive Vector3
  124898. * * 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
  124899. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124900. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124901. * * When updating an instance, remember that only point positions can change, not the number of points
  124902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124904. * @param name defines the name of the new line system
  124905. * @param options defines the options used to create the line system
  124906. * @param scene defines the hosting scene
  124907. * @returns a new line mesh
  124908. */
  124909. static CreateLines(name: string, options: {
  124910. points: Vector3[];
  124911. updatable?: boolean;
  124912. instance?: Nullable<LinesMesh>;
  124913. colors?: Color4[];
  124914. useVertexAlpha?: boolean;
  124915. }, scene?: Nullable<Scene>): LinesMesh;
  124916. /**
  124917. * Creates a dashed line mesh
  124918. * * 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
  124919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124920. * * The parameter `points` is an array successive Vector3
  124921. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124922. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124923. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124924. * * 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
  124925. * * When updating an instance, remember that only point positions can change, not the number of points
  124926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124927. * @param name defines the name of the mesh
  124928. * @param options defines the options used to create the mesh
  124929. * @param scene defines the hosting scene
  124930. * @returns the dashed line mesh
  124931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124932. */
  124933. static CreateDashedLines(name: string, options: {
  124934. points: Vector3[];
  124935. dashSize?: number;
  124936. gapSize?: number;
  124937. dashNb?: number;
  124938. updatable?: boolean;
  124939. instance?: LinesMesh;
  124940. }, scene?: Nullable<Scene>): LinesMesh;
  124941. /**
  124942. * 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.
  124943. * * 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.
  124944. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124945. * * 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.
  124946. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124947. * * 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
  124948. * * 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
  124949. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124952. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124954. * @param name defines the name of the mesh
  124955. * @param options defines the options used to create the mesh
  124956. * @param scene defines the hosting scene
  124957. * @returns the extruded shape mesh
  124958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124960. */
  124961. static ExtrudeShape(name: string, options: {
  124962. shape: Vector3[];
  124963. path: Vector3[];
  124964. scale?: number;
  124965. rotation?: number;
  124966. cap?: number;
  124967. updatable?: boolean;
  124968. sideOrientation?: number;
  124969. frontUVs?: Vector4;
  124970. backUVs?: Vector4;
  124971. instance?: Mesh;
  124972. invertUV?: boolean;
  124973. }, scene?: Nullable<Scene>): Mesh;
  124974. /**
  124975. * Creates an custom extruded shape mesh.
  124976. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124977. * * 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.
  124978. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124979. * * 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
  124980. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124981. * * 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
  124982. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124983. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124984. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124985. * * 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
  124986. * * 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
  124987. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124992. * @param name defines the name of the mesh
  124993. * @param options defines the options used to create the mesh
  124994. * @param scene defines the hosting scene
  124995. * @returns the custom extruded shape mesh
  124996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124999. */
  125000. static ExtrudeShapeCustom(name: string, options: {
  125001. shape: Vector3[];
  125002. path: Vector3[];
  125003. scaleFunction?: any;
  125004. rotationFunction?: any;
  125005. ribbonCloseArray?: boolean;
  125006. ribbonClosePath?: boolean;
  125007. cap?: number;
  125008. updatable?: boolean;
  125009. sideOrientation?: number;
  125010. frontUVs?: Vector4;
  125011. backUVs?: Vector4;
  125012. instance?: Mesh;
  125013. invertUV?: boolean;
  125014. }, scene?: Nullable<Scene>): Mesh;
  125015. /**
  125016. * Creates lathe mesh.
  125017. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125018. * * 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
  125019. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125020. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125021. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125022. * * 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
  125023. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125024. * * 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
  125025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125029. * @param name defines the name of the mesh
  125030. * @param options defines the options used to create the mesh
  125031. * @param scene defines the hosting scene
  125032. * @returns the lathe mesh
  125033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125034. */
  125035. static CreateLathe(name: string, options: {
  125036. shape: Vector3[];
  125037. radius?: number;
  125038. tessellation?: number;
  125039. clip?: number;
  125040. arc?: number;
  125041. closed?: boolean;
  125042. updatable?: boolean;
  125043. sideOrientation?: number;
  125044. frontUVs?: Vector4;
  125045. backUVs?: Vector4;
  125046. cap?: number;
  125047. invertUV?: boolean;
  125048. }, scene?: Nullable<Scene>): Mesh;
  125049. /**
  125050. * Creates a tiled plane mesh
  125051. * * You can set a limited pattern arrangement with the tiles
  125052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125055. * @param name defines the name of the mesh
  125056. * @param options defines the options used to create the mesh
  125057. * @param scene defines the hosting scene
  125058. * @returns the plane mesh
  125059. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125060. */
  125061. static CreateTiledPlane(name: string, options: {
  125062. pattern?: number;
  125063. tileSize?: number;
  125064. tileWidth?: number;
  125065. tileHeight?: number;
  125066. size?: number;
  125067. width?: number;
  125068. height?: number;
  125069. alignHorizontal?: number;
  125070. alignVertical?: number;
  125071. sideOrientation?: number;
  125072. frontUVs?: Vector4;
  125073. backUVs?: Vector4;
  125074. updatable?: boolean;
  125075. }, scene?: Nullable<Scene>): Mesh;
  125076. /**
  125077. * Creates a plane mesh
  125078. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125079. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125080. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125084. * @param name defines the name of the mesh
  125085. * @param options defines the options used to create the mesh
  125086. * @param scene defines the hosting scene
  125087. * @returns the plane mesh
  125088. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125089. */
  125090. static CreatePlane(name: string, options: {
  125091. size?: number;
  125092. width?: number;
  125093. height?: number;
  125094. sideOrientation?: number;
  125095. frontUVs?: Vector4;
  125096. backUVs?: Vector4;
  125097. updatable?: boolean;
  125098. sourcePlane?: Plane;
  125099. }, scene?: Nullable<Scene>): Mesh;
  125100. /**
  125101. * Creates a ground mesh
  125102. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125103. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125105. * @param name defines the name of the mesh
  125106. * @param options defines the options used to create the mesh
  125107. * @param scene defines the hosting scene
  125108. * @returns the ground mesh
  125109. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125110. */
  125111. static CreateGround(name: string, options: {
  125112. width?: number;
  125113. height?: number;
  125114. subdivisions?: number;
  125115. subdivisionsX?: number;
  125116. subdivisionsY?: number;
  125117. updatable?: boolean;
  125118. }, scene?: Nullable<Scene>): Mesh;
  125119. /**
  125120. * Creates a tiled ground mesh
  125121. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125122. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125123. * * 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
  125124. * * 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
  125125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125126. * @param name defines the name of the mesh
  125127. * @param options defines the options used to create the mesh
  125128. * @param scene defines the hosting scene
  125129. * @returns the tiled ground mesh
  125130. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125131. */
  125132. static CreateTiledGround(name: string, options: {
  125133. xmin: number;
  125134. zmin: number;
  125135. xmax: number;
  125136. zmax: number;
  125137. subdivisions?: {
  125138. w: number;
  125139. h: number;
  125140. };
  125141. precision?: {
  125142. w: number;
  125143. h: number;
  125144. };
  125145. updatable?: boolean;
  125146. }, scene?: Nullable<Scene>): Mesh;
  125147. /**
  125148. * Creates a ground mesh from a height map
  125149. * * The parameter `url` sets the URL of the height map image resource.
  125150. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125151. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125152. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125153. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125154. * * 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.
  125155. * * 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).
  125156. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125158. * @param name defines the name of the mesh
  125159. * @param url defines the url to the height map
  125160. * @param options defines the options used to create the mesh
  125161. * @param scene defines the hosting scene
  125162. * @returns the ground mesh
  125163. * @see https://doc.babylonjs.com/babylon101/height_map
  125164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125165. */
  125166. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125167. width?: number;
  125168. height?: number;
  125169. subdivisions?: number;
  125170. minHeight?: number;
  125171. maxHeight?: number;
  125172. colorFilter?: Color3;
  125173. alphaFilter?: number;
  125174. updatable?: boolean;
  125175. onReady?: (mesh: GroundMesh) => void;
  125176. }, scene?: Nullable<Scene>): GroundMesh;
  125177. /**
  125178. * Creates a polygon mesh
  125179. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125180. * * 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
  125181. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125184. * * Remember you can only change the shape positions, not their number when updating a polygon
  125185. * @param name defines the name of the mesh
  125186. * @param options defines the options used to create the mesh
  125187. * @param scene defines the hosting scene
  125188. * @param earcutInjection can be used to inject your own earcut reference
  125189. * @returns the polygon mesh
  125190. */
  125191. static CreatePolygon(name: string, options: {
  125192. shape: Vector3[];
  125193. holes?: Vector3[][];
  125194. depth?: number;
  125195. faceUV?: Vector4[];
  125196. faceColors?: Color4[];
  125197. updatable?: boolean;
  125198. sideOrientation?: number;
  125199. frontUVs?: Vector4;
  125200. backUVs?: Vector4;
  125201. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125202. /**
  125203. * Creates an extruded polygon mesh, with depth in the Y direction.
  125204. * * 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)
  125205. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125206. * @param name defines the name of the mesh
  125207. * @param options defines the options used to create the mesh
  125208. * @param scene defines the hosting scene
  125209. * @param earcutInjection can be used to inject your own earcut reference
  125210. * @returns the polygon mesh
  125211. */
  125212. static ExtrudePolygon(name: string, options: {
  125213. shape: Vector3[];
  125214. holes?: Vector3[][];
  125215. depth?: number;
  125216. faceUV?: Vector4[];
  125217. faceColors?: Color4[];
  125218. updatable?: boolean;
  125219. sideOrientation?: number;
  125220. frontUVs?: Vector4;
  125221. backUVs?: Vector4;
  125222. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125223. /**
  125224. * Creates a tube mesh.
  125225. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125226. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125227. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125228. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125229. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125230. * * 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)
  125231. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125232. * * 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
  125233. * * 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
  125234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125238. * @param name defines the name of the mesh
  125239. * @param options defines the options used to create the mesh
  125240. * @param scene defines the hosting scene
  125241. * @returns the tube mesh
  125242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125243. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125244. */
  125245. static CreateTube(name: string, options: {
  125246. path: Vector3[];
  125247. radius?: number;
  125248. tessellation?: number;
  125249. radiusFunction?: {
  125250. (i: number, distance: number): number;
  125251. };
  125252. cap?: number;
  125253. arc?: number;
  125254. updatable?: boolean;
  125255. sideOrientation?: number;
  125256. frontUVs?: Vector4;
  125257. backUVs?: Vector4;
  125258. instance?: Mesh;
  125259. invertUV?: boolean;
  125260. }, scene?: Nullable<Scene>): Mesh;
  125261. /**
  125262. * Creates a polyhedron mesh
  125263. * * 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
  125264. * * The parameter `size` (positive float, default 1) sets the polygon size
  125265. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125266. * * 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`
  125267. * * 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
  125268. * * 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)`)
  125269. * * 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
  125270. * * 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
  125271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125274. * @param name defines the name of the mesh
  125275. * @param options defines the options used to create the mesh
  125276. * @param scene defines the hosting scene
  125277. * @returns the polyhedron mesh
  125278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125279. */
  125280. static CreatePolyhedron(name: string, options: {
  125281. type?: number;
  125282. size?: number;
  125283. sizeX?: number;
  125284. sizeY?: number;
  125285. sizeZ?: number;
  125286. custom?: any;
  125287. faceUV?: Vector4[];
  125288. faceColors?: Color4[];
  125289. flat?: boolean;
  125290. updatable?: boolean;
  125291. sideOrientation?: number;
  125292. frontUVs?: Vector4;
  125293. backUVs?: Vector4;
  125294. }, scene?: Nullable<Scene>): Mesh;
  125295. /**
  125296. * Creates a decal mesh.
  125297. * 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
  125298. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125299. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125300. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125301. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125302. * @param name defines the name of the mesh
  125303. * @param sourceMesh defines the mesh where the decal must be applied
  125304. * @param options defines the options used to create the mesh
  125305. * @param scene defines the hosting scene
  125306. * @returns the decal mesh
  125307. * @see https://doc.babylonjs.com/how_to/decals
  125308. */
  125309. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125310. position?: Vector3;
  125311. normal?: Vector3;
  125312. size?: Vector3;
  125313. angle?: number;
  125314. }): Mesh;
  125315. }
  125316. }
  125317. declare module BABYLON {
  125318. /**
  125319. * A simplifier interface for future simplification implementations
  125320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125321. */
  125322. export interface ISimplifier {
  125323. /**
  125324. * Simplification of a given mesh according to the given settings.
  125325. * Since this requires computation, it is assumed that the function runs async.
  125326. * @param settings The settings of the simplification, including quality and distance
  125327. * @param successCallback A callback that will be called after the mesh was simplified.
  125328. * @param errorCallback in case of an error, this callback will be called. optional.
  125329. */
  125330. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125331. }
  125332. /**
  125333. * Expected simplification settings.
  125334. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125336. */
  125337. export interface ISimplificationSettings {
  125338. /**
  125339. * Gets or sets the expected quality
  125340. */
  125341. quality: number;
  125342. /**
  125343. * Gets or sets the distance when this optimized version should be used
  125344. */
  125345. distance: number;
  125346. /**
  125347. * Gets an already optimized mesh
  125348. */
  125349. optimizeMesh?: boolean;
  125350. }
  125351. /**
  125352. * Class used to specify simplification options
  125353. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125354. */
  125355. export class SimplificationSettings implements ISimplificationSettings {
  125356. /** expected quality */
  125357. quality: number;
  125358. /** distance when this optimized version should be used */
  125359. distance: number;
  125360. /** already optimized mesh */
  125361. optimizeMesh?: boolean | undefined;
  125362. /**
  125363. * Creates a SimplificationSettings
  125364. * @param quality expected quality
  125365. * @param distance distance when this optimized version should be used
  125366. * @param optimizeMesh already optimized mesh
  125367. */
  125368. constructor(
  125369. /** expected quality */
  125370. quality: number,
  125371. /** distance when this optimized version should be used */
  125372. distance: number,
  125373. /** already optimized mesh */
  125374. optimizeMesh?: boolean | undefined);
  125375. }
  125376. /**
  125377. * Interface used to define a simplification task
  125378. */
  125379. export interface ISimplificationTask {
  125380. /**
  125381. * Array of settings
  125382. */
  125383. settings: Array<ISimplificationSettings>;
  125384. /**
  125385. * Simplification type
  125386. */
  125387. simplificationType: SimplificationType;
  125388. /**
  125389. * Mesh to simplify
  125390. */
  125391. mesh: Mesh;
  125392. /**
  125393. * Callback called on success
  125394. */
  125395. successCallback?: () => void;
  125396. /**
  125397. * Defines if parallel processing can be used
  125398. */
  125399. parallelProcessing: boolean;
  125400. }
  125401. /**
  125402. * Queue used to order the simplification tasks
  125403. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125404. */
  125405. export class SimplificationQueue {
  125406. private _simplificationArray;
  125407. /**
  125408. * Gets a boolean indicating that the process is still running
  125409. */
  125410. running: boolean;
  125411. /**
  125412. * Creates a new queue
  125413. */
  125414. constructor();
  125415. /**
  125416. * Adds a new simplification task
  125417. * @param task defines a task to add
  125418. */
  125419. addTask(task: ISimplificationTask): void;
  125420. /**
  125421. * Execute next task
  125422. */
  125423. executeNext(): void;
  125424. /**
  125425. * Execute a simplification task
  125426. * @param task defines the task to run
  125427. */
  125428. runSimplification(task: ISimplificationTask): void;
  125429. private getSimplifier;
  125430. }
  125431. /**
  125432. * The implemented types of simplification
  125433. * At the moment only Quadratic Error Decimation is implemented
  125434. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125435. */
  125436. export enum SimplificationType {
  125437. /** Quadratic error decimation */
  125438. QUADRATIC = 0
  125439. }
  125440. }
  125441. declare module BABYLON {
  125442. interface Scene {
  125443. /** @hidden (Backing field) */
  125444. _simplificationQueue: SimplificationQueue;
  125445. /**
  125446. * Gets or sets the simplification queue attached to the scene
  125447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125448. */
  125449. simplificationQueue: SimplificationQueue;
  125450. }
  125451. interface Mesh {
  125452. /**
  125453. * Simplify the mesh according to the given array of settings.
  125454. * Function will return immediately and will simplify async
  125455. * @param settings a collection of simplification settings
  125456. * @param parallelProcessing should all levels calculate parallel or one after the other
  125457. * @param simplificationType the type of simplification to run
  125458. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125459. * @returns the current mesh
  125460. */
  125461. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125462. }
  125463. /**
  125464. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125465. * created in a scene
  125466. */
  125467. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125468. /**
  125469. * The component name helpfull to identify the component in the list of scene components.
  125470. */
  125471. readonly name: string;
  125472. /**
  125473. * The scene the component belongs to.
  125474. */
  125475. scene: Scene;
  125476. /**
  125477. * Creates a new instance of the component for the given scene
  125478. * @param scene Defines the scene to register the component in
  125479. */
  125480. constructor(scene: Scene);
  125481. /**
  125482. * Registers the component in a given scene
  125483. */
  125484. register(): void;
  125485. /**
  125486. * Rebuilds the elements related to this component in case of
  125487. * context lost for instance.
  125488. */
  125489. rebuild(): void;
  125490. /**
  125491. * Disposes the component and the associated ressources
  125492. */
  125493. dispose(): void;
  125494. private _beforeCameraUpdate;
  125495. }
  125496. }
  125497. declare module BABYLON {
  125498. /**
  125499. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125500. */
  125501. export interface INavigationEnginePlugin {
  125502. /**
  125503. * plugin name
  125504. */
  125505. name: string;
  125506. /**
  125507. * Creates a navigation mesh
  125508. * @param meshes array of all the geometry used to compute the navigatio mesh
  125509. * @param parameters bunch of parameters used to filter geometry
  125510. */
  125511. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125512. /**
  125513. * Create a navigation mesh debug mesh
  125514. * @param scene is where the mesh will be added
  125515. * @returns debug display mesh
  125516. */
  125517. createDebugNavMesh(scene: Scene): Mesh;
  125518. /**
  125519. * Get a navigation mesh constrained position, closest to the parameter position
  125520. * @param position world position
  125521. * @returns the closest point to position constrained by the navigation mesh
  125522. */
  125523. getClosestPoint(position: Vector3): Vector3;
  125524. /**
  125525. * Get a navigation mesh constrained position, within a particular radius
  125526. * @param position world position
  125527. * @param maxRadius the maximum distance to the constrained world position
  125528. * @returns the closest point to position constrained by the navigation mesh
  125529. */
  125530. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125531. /**
  125532. * Compute the final position from a segment made of destination-position
  125533. * @param position world position
  125534. * @param destination world position
  125535. * @returns the resulting point along the navmesh
  125536. */
  125537. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125538. /**
  125539. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125540. * @param start world position
  125541. * @param end world position
  125542. * @returns array containing world position composing the path
  125543. */
  125544. computePath(start: Vector3, end: Vector3): Vector3[];
  125545. /**
  125546. * If this plugin is supported
  125547. * @returns true if plugin is supported
  125548. */
  125549. isSupported(): boolean;
  125550. /**
  125551. * Create a new Crowd so you can add agents
  125552. * @param maxAgents the maximum agent count in the crowd
  125553. * @param maxAgentRadius the maximum radius an agent can have
  125554. * @param scene to attach the crowd to
  125555. * @returns the crowd you can add agents to
  125556. */
  125557. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125558. /**
  125559. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125560. * The queries will try to find a solution within those bounds
  125561. * default is (1,1,1)
  125562. * @param extent x,y,z value that define the extent around the queries point of reference
  125563. */
  125564. setDefaultQueryExtent(extent: Vector3): void;
  125565. /**
  125566. * Get the Bounding box extent specified by setDefaultQueryExtent
  125567. * @returns the box extent values
  125568. */
  125569. getDefaultQueryExtent(): Vector3;
  125570. /**
  125571. * Release all resources
  125572. */
  125573. dispose(): void;
  125574. }
  125575. /**
  125576. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  125577. */
  125578. export interface ICrowd {
  125579. /**
  125580. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125581. * You can attach anything to that node. The node position is updated in the scene update tick.
  125582. * @param pos world position that will be constrained by the navigation mesh
  125583. * @param parameters agent parameters
  125584. * @param transform hooked to the agent that will be update by the scene
  125585. * @returns agent index
  125586. */
  125587. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125588. /**
  125589. * Returns the agent position in world space
  125590. * @param index agent index returned by addAgent
  125591. * @returns world space position
  125592. */
  125593. getAgentPosition(index: number): Vector3;
  125594. /**
  125595. * Gets the agent velocity in world space
  125596. * @param index agent index returned by addAgent
  125597. * @returns world space velocity
  125598. */
  125599. getAgentVelocity(index: number): Vector3;
  125600. /**
  125601. * remove a particular agent previously created
  125602. * @param index agent index returned by addAgent
  125603. */
  125604. removeAgent(index: number): void;
  125605. /**
  125606. * get the list of all agents attached to this crowd
  125607. * @returns list of agent indices
  125608. */
  125609. getAgents(): number[];
  125610. /**
  125611. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125612. * @param deltaTime in seconds
  125613. */
  125614. update(deltaTime: number): void;
  125615. /**
  125616. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125617. * @param index agent index returned by addAgent
  125618. * @param destination targeted world position
  125619. */
  125620. agentGoto(index: number, destination: Vector3): void;
  125621. /**
  125622. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125623. * The queries will try to find a solution within those bounds
  125624. * default is (1,1,1)
  125625. * @param extent x,y,z value that define the extent around the queries point of reference
  125626. */
  125627. setDefaultQueryExtent(extent: Vector3): void;
  125628. /**
  125629. * Get the Bounding box extent specified by setDefaultQueryExtent
  125630. * @returns the box extent values
  125631. */
  125632. getDefaultQueryExtent(): Vector3;
  125633. /**
  125634. * Release all resources
  125635. */
  125636. dispose(): void;
  125637. }
  125638. /**
  125639. * Configures an agent
  125640. */
  125641. export interface IAgentParameters {
  125642. /**
  125643. * Agent radius. [Limit: >= 0]
  125644. */
  125645. radius: number;
  125646. /**
  125647. * Agent height. [Limit: > 0]
  125648. */
  125649. height: number;
  125650. /**
  125651. * Maximum allowed acceleration. [Limit: >= 0]
  125652. */
  125653. maxAcceleration: number;
  125654. /**
  125655. * Maximum allowed speed. [Limit: >= 0]
  125656. */
  125657. maxSpeed: number;
  125658. /**
  125659. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125660. */
  125661. collisionQueryRange: number;
  125662. /**
  125663. * The path visibility optimization range. [Limit: > 0]
  125664. */
  125665. pathOptimizationRange: number;
  125666. /**
  125667. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125668. */
  125669. separationWeight: number;
  125670. }
  125671. /**
  125672. * Configures the navigation mesh creation
  125673. */
  125674. export interface INavMeshParameters {
  125675. /**
  125676. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125677. */
  125678. cs: number;
  125679. /**
  125680. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125681. */
  125682. ch: number;
  125683. /**
  125684. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125685. */
  125686. walkableSlopeAngle: number;
  125687. /**
  125688. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125689. * be considered walkable. [Limit: >= 3] [Units: vx]
  125690. */
  125691. walkableHeight: number;
  125692. /**
  125693. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125694. */
  125695. walkableClimb: number;
  125696. /**
  125697. * The distance to erode/shrink the walkable area of the heightfield away from
  125698. * obstructions. [Limit: >=0] [Units: vx]
  125699. */
  125700. walkableRadius: number;
  125701. /**
  125702. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125703. */
  125704. maxEdgeLen: number;
  125705. /**
  125706. * The maximum distance a simplfied contour's border edges should deviate
  125707. * the original raw contour. [Limit: >=0] [Units: vx]
  125708. */
  125709. maxSimplificationError: number;
  125710. /**
  125711. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125712. */
  125713. minRegionArea: number;
  125714. /**
  125715. * Any regions with a span count smaller than this value will, if possible,
  125716. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125717. */
  125718. mergeRegionArea: number;
  125719. /**
  125720. * The maximum number of vertices allowed for polygons generated during the
  125721. * contour to polygon conversion process. [Limit: >= 3]
  125722. */
  125723. maxVertsPerPoly: number;
  125724. /**
  125725. * Sets the sampling distance to use when generating the detail mesh.
  125726. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125727. */
  125728. detailSampleDist: number;
  125729. /**
  125730. * The maximum distance the detail mesh surface should deviate from heightfield
  125731. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125732. */
  125733. detailSampleMaxError: number;
  125734. }
  125735. }
  125736. declare module BABYLON {
  125737. /**
  125738. * RecastJS navigation plugin
  125739. */
  125740. export class RecastJSPlugin implements INavigationEnginePlugin {
  125741. /**
  125742. * Reference to the Recast library
  125743. */
  125744. bjsRECAST: any;
  125745. /**
  125746. * plugin name
  125747. */
  125748. name: string;
  125749. /**
  125750. * the first navmesh created. We might extend this to support multiple navmeshes
  125751. */
  125752. navMesh: any;
  125753. /**
  125754. * Initializes the recastJS plugin
  125755. * @param recastInjection can be used to inject your own recast reference
  125756. */
  125757. constructor(recastInjection?: any);
  125758. /**
  125759. * Creates a navigation mesh
  125760. * @param meshes array of all the geometry used to compute the navigatio mesh
  125761. * @param parameters bunch of parameters used to filter geometry
  125762. */
  125763. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125764. /**
  125765. * Create a navigation mesh debug mesh
  125766. * @param scene is where the mesh will be added
  125767. * @returns debug display mesh
  125768. */
  125769. createDebugNavMesh(scene: Scene): Mesh;
  125770. /**
  125771. * Get a navigation mesh constrained position, closest to the parameter position
  125772. * @param position world position
  125773. * @returns the closest point to position constrained by the navigation mesh
  125774. */
  125775. getClosestPoint(position: Vector3): Vector3;
  125776. /**
  125777. * Get a navigation mesh constrained position, within a particular radius
  125778. * @param position world position
  125779. * @param maxRadius the maximum distance to the constrained world position
  125780. * @returns the closest point to position constrained by the navigation mesh
  125781. */
  125782. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125783. /**
  125784. * Compute the final position from a segment made of destination-position
  125785. * @param position world position
  125786. * @param destination world position
  125787. * @returns the resulting point along the navmesh
  125788. */
  125789. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125790. /**
  125791. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125792. * @param start world position
  125793. * @param end world position
  125794. * @returns array containing world position composing the path
  125795. */
  125796. computePath(start: Vector3, end: Vector3): Vector3[];
  125797. /**
  125798. * Create a new Crowd so you can add agents
  125799. * @param maxAgents the maximum agent count in the crowd
  125800. * @param maxAgentRadius the maximum radius an agent can have
  125801. * @param scene to attach the crowd to
  125802. * @returns the crowd you can add agents to
  125803. */
  125804. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125805. /**
  125806. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125807. * The queries will try to find a solution within those bounds
  125808. * default is (1,1,1)
  125809. * @param extent x,y,z value that define the extent around the queries point of reference
  125810. */
  125811. setDefaultQueryExtent(extent: Vector3): void;
  125812. /**
  125813. * Get the Bounding box extent specified by setDefaultQueryExtent
  125814. * @returns the box extent values
  125815. */
  125816. getDefaultQueryExtent(): Vector3;
  125817. /**
  125818. * Disposes
  125819. */
  125820. dispose(): void;
  125821. /**
  125822. * If this plugin is supported
  125823. * @returns true if plugin is supported
  125824. */
  125825. isSupported(): boolean;
  125826. }
  125827. /**
  125828. * Recast detour crowd implementation
  125829. */
  125830. export class RecastJSCrowd implements ICrowd {
  125831. /**
  125832. * Recast/detour plugin
  125833. */
  125834. bjsRECASTPlugin: RecastJSPlugin;
  125835. /**
  125836. * Link to the detour crowd
  125837. */
  125838. recastCrowd: any;
  125839. /**
  125840. * One transform per agent
  125841. */
  125842. transforms: TransformNode[];
  125843. /**
  125844. * All agents created
  125845. */
  125846. agents: number[];
  125847. /**
  125848. * Link to the scene is kept to unregister the crowd from the scene
  125849. */
  125850. private _scene;
  125851. /**
  125852. * Observer for crowd updates
  125853. */
  125854. private _onBeforeAnimationsObserver;
  125855. /**
  125856. * Constructor
  125857. * @param plugin recastJS plugin
  125858. * @param maxAgents the maximum agent count in the crowd
  125859. * @param maxAgentRadius the maximum radius an agent can have
  125860. * @param scene to attach the crowd to
  125861. * @returns the crowd you can add agents to
  125862. */
  125863. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125864. /**
  125865. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125866. * You can attach anything to that node. The node position is updated in the scene update tick.
  125867. * @param pos world position that will be constrained by the navigation mesh
  125868. * @param parameters agent parameters
  125869. * @param transform hooked to the agent that will be update by the scene
  125870. * @returns agent index
  125871. */
  125872. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125873. /**
  125874. * Returns the agent position in world space
  125875. * @param index agent index returned by addAgent
  125876. * @returns world space position
  125877. */
  125878. getAgentPosition(index: number): Vector3;
  125879. /**
  125880. * Returns the agent velocity in world space
  125881. * @param index agent index returned by addAgent
  125882. * @returns world space velocity
  125883. */
  125884. getAgentVelocity(index: number): Vector3;
  125885. /**
  125886. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125887. * @param index agent index returned by addAgent
  125888. * @param destination targeted world position
  125889. */
  125890. agentGoto(index: number, destination: Vector3): void;
  125891. /**
  125892. * remove a particular agent previously created
  125893. * @param index agent index returned by addAgent
  125894. */
  125895. removeAgent(index: number): void;
  125896. /**
  125897. * get the list of all agents attached to this crowd
  125898. * @returns list of agent indices
  125899. */
  125900. getAgents(): number[];
  125901. /**
  125902. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125903. * @param deltaTime in seconds
  125904. */
  125905. update(deltaTime: number): void;
  125906. /**
  125907. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125908. * The queries will try to find a solution within those bounds
  125909. * default is (1,1,1)
  125910. * @param extent x,y,z value that define the extent around the queries point of reference
  125911. */
  125912. setDefaultQueryExtent(extent: Vector3): void;
  125913. /**
  125914. * Get the Bounding box extent specified by setDefaultQueryExtent
  125915. * @returns the box extent values
  125916. */
  125917. getDefaultQueryExtent(): Vector3;
  125918. /**
  125919. * Release all resources
  125920. */
  125921. dispose(): void;
  125922. }
  125923. }
  125924. declare module BABYLON {
  125925. /**
  125926. * Class used to enable access to IndexedDB
  125927. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125928. */
  125929. export class Database implements IOfflineProvider {
  125930. private _callbackManifestChecked;
  125931. private _currentSceneUrl;
  125932. private _db;
  125933. private _enableSceneOffline;
  125934. private _enableTexturesOffline;
  125935. private _manifestVersionFound;
  125936. private _mustUpdateRessources;
  125937. private _hasReachedQuota;
  125938. private _isSupported;
  125939. private _idbFactory;
  125940. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125941. private static IsUASupportingBlobStorage;
  125942. /**
  125943. * Gets a boolean indicating if Database storate is enabled (off by default)
  125944. */
  125945. static IDBStorageEnabled: boolean;
  125946. /**
  125947. * Gets a boolean indicating if scene must be saved in the database
  125948. */
  125949. readonly enableSceneOffline: boolean;
  125950. /**
  125951. * Gets a boolean indicating if textures must be saved in the database
  125952. */
  125953. readonly enableTexturesOffline: boolean;
  125954. /**
  125955. * Creates a new Database
  125956. * @param urlToScene defines the url to load the scene
  125957. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125958. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125959. */
  125960. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125961. private static _ParseURL;
  125962. private static _ReturnFullUrlLocation;
  125963. private _checkManifestFile;
  125964. /**
  125965. * Open the database and make it available
  125966. * @param successCallback defines the callback to call on success
  125967. * @param errorCallback defines the callback to call on error
  125968. */
  125969. open(successCallback: () => void, errorCallback: () => void): void;
  125970. /**
  125971. * Loads an image from the database
  125972. * @param url defines the url to load from
  125973. * @param image defines the target DOM image
  125974. */
  125975. loadImage(url: string, image: HTMLImageElement): void;
  125976. private _loadImageFromDBAsync;
  125977. private _saveImageIntoDBAsync;
  125978. private _checkVersionFromDB;
  125979. private _loadVersionFromDBAsync;
  125980. private _saveVersionIntoDBAsync;
  125981. /**
  125982. * Loads a file from database
  125983. * @param url defines the URL to load from
  125984. * @param sceneLoaded defines a callback to call on success
  125985. * @param progressCallBack defines a callback to call when progress changed
  125986. * @param errorCallback defines a callback to call on error
  125987. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125988. */
  125989. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125990. private _loadFileAsync;
  125991. private _saveFileAsync;
  125992. /**
  125993. * Validates if xhr data is correct
  125994. * @param xhr defines the request to validate
  125995. * @param dataType defines the expected data type
  125996. * @returns true if data is correct
  125997. */
  125998. private static _ValidateXHRData;
  125999. }
  126000. }
  126001. declare module BABYLON {
  126002. /** @hidden */
  126003. export var gpuUpdateParticlesPixelShader: {
  126004. name: string;
  126005. shader: string;
  126006. };
  126007. }
  126008. declare module BABYLON {
  126009. /** @hidden */
  126010. export var gpuUpdateParticlesVertexShader: {
  126011. name: string;
  126012. shader: string;
  126013. };
  126014. }
  126015. declare module BABYLON {
  126016. /** @hidden */
  126017. export var clipPlaneFragmentDeclaration2: {
  126018. name: string;
  126019. shader: string;
  126020. };
  126021. }
  126022. declare module BABYLON {
  126023. /** @hidden */
  126024. export var gpuRenderParticlesPixelShader: {
  126025. name: string;
  126026. shader: string;
  126027. };
  126028. }
  126029. declare module BABYLON {
  126030. /** @hidden */
  126031. export var clipPlaneVertexDeclaration2: {
  126032. name: string;
  126033. shader: string;
  126034. };
  126035. }
  126036. declare module BABYLON {
  126037. /** @hidden */
  126038. export var gpuRenderParticlesVertexShader: {
  126039. name: string;
  126040. shader: string;
  126041. };
  126042. }
  126043. declare module BABYLON {
  126044. /**
  126045. * This represents a GPU particle system in Babylon
  126046. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126047. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126048. */
  126049. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126050. /**
  126051. * The layer mask we are rendering the particles through.
  126052. */
  126053. layerMask: number;
  126054. private _capacity;
  126055. private _activeCount;
  126056. private _currentActiveCount;
  126057. private _accumulatedCount;
  126058. private _renderEffect;
  126059. private _updateEffect;
  126060. private _buffer0;
  126061. private _buffer1;
  126062. private _spriteBuffer;
  126063. private _updateVAO;
  126064. private _renderVAO;
  126065. private _targetIndex;
  126066. private _sourceBuffer;
  126067. private _targetBuffer;
  126068. private _engine;
  126069. private _currentRenderId;
  126070. private _started;
  126071. private _stopped;
  126072. private _timeDelta;
  126073. private _randomTexture;
  126074. private _randomTexture2;
  126075. private _attributesStrideSize;
  126076. private _updateEffectOptions;
  126077. private _randomTextureSize;
  126078. private _actualFrame;
  126079. private readonly _rawTextureWidth;
  126080. /**
  126081. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126082. */
  126083. static readonly IsSupported: boolean;
  126084. /**
  126085. * An event triggered when the system is disposed.
  126086. */
  126087. onDisposeObservable: Observable<GPUParticleSystem>;
  126088. /**
  126089. * Gets the maximum number of particles active at the same time.
  126090. * @returns The max number of active particles.
  126091. */
  126092. getCapacity(): number;
  126093. /**
  126094. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126095. * to override the particles.
  126096. */
  126097. forceDepthWrite: boolean;
  126098. /**
  126099. * Gets or set the number of active particles
  126100. */
  126101. activeParticleCount: number;
  126102. private _preWarmDone;
  126103. /**
  126104. * Is this system ready to be used/rendered
  126105. * @return true if the system is ready
  126106. */
  126107. isReady(): boolean;
  126108. /**
  126109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126110. * @returns True if it has been started, otherwise false.
  126111. */
  126112. isStarted(): boolean;
  126113. /**
  126114. * Starts the particle system and begins to emit
  126115. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126116. */
  126117. start(delay?: number): void;
  126118. /**
  126119. * Stops the particle system.
  126120. */
  126121. stop(): void;
  126122. /**
  126123. * Remove all active particles
  126124. */
  126125. reset(): void;
  126126. /**
  126127. * Returns the string "GPUParticleSystem"
  126128. * @returns a string containing the class name
  126129. */
  126130. getClassName(): string;
  126131. private _colorGradientsTexture;
  126132. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126133. /**
  126134. * Adds a new color gradient
  126135. * @param gradient defines the gradient to use (between 0 and 1)
  126136. * @param color1 defines the color to affect to the specified gradient
  126137. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126138. * @returns the current particle system
  126139. */
  126140. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126141. /**
  126142. * Remove a specific color gradient
  126143. * @param gradient defines the gradient to remove
  126144. * @returns the current particle system
  126145. */
  126146. removeColorGradient(gradient: number): GPUParticleSystem;
  126147. private _angularSpeedGradientsTexture;
  126148. private _sizeGradientsTexture;
  126149. private _velocityGradientsTexture;
  126150. private _limitVelocityGradientsTexture;
  126151. private _dragGradientsTexture;
  126152. private _addFactorGradient;
  126153. /**
  126154. * Adds a new size gradient
  126155. * @param gradient defines the gradient to use (between 0 and 1)
  126156. * @param factor defines the size factor to affect to the specified gradient
  126157. * @returns the current particle system
  126158. */
  126159. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126160. /**
  126161. * Remove a specific size gradient
  126162. * @param gradient defines the gradient to remove
  126163. * @returns the current particle system
  126164. */
  126165. removeSizeGradient(gradient: number): GPUParticleSystem;
  126166. /**
  126167. * Adds a new angular speed gradient
  126168. * @param gradient defines the gradient to use (between 0 and 1)
  126169. * @param factor defines the angular speed to affect to the specified gradient
  126170. * @returns the current particle system
  126171. */
  126172. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126173. /**
  126174. * Remove a specific angular speed gradient
  126175. * @param gradient defines the gradient to remove
  126176. * @returns the current particle system
  126177. */
  126178. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126179. /**
  126180. * Adds a new velocity gradient
  126181. * @param gradient defines the gradient to use (between 0 and 1)
  126182. * @param factor defines the velocity to affect to the specified gradient
  126183. * @returns the current particle system
  126184. */
  126185. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126186. /**
  126187. * Remove a specific velocity gradient
  126188. * @param gradient defines the gradient to remove
  126189. * @returns the current particle system
  126190. */
  126191. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126192. /**
  126193. * Adds a new limit velocity gradient
  126194. * @param gradient defines the gradient to use (between 0 and 1)
  126195. * @param factor defines the limit velocity value to affect to the specified gradient
  126196. * @returns the current particle system
  126197. */
  126198. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126199. /**
  126200. * Remove a specific limit velocity gradient
  126201. * @param gradient defines the gradient to remove
  126202. * @returns the current particle system
  126203. */
  126204. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126205. /**
  126206. * Adds a new drag gradient
  126207. * @param gradient defines the gradient to use (between 0 and 1)
  126208. * @param factor defines the drag value to affect to the specified gradient
  126209. * @returns the current particle system
  126210. */
  126211. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126212. /**
  126213. * Remove a specific drag gradient
  126214. * @param gradient defines the gradient to remove
  126215. * @returns the current particle system
  126216. */
  126217. removeDragGradient(gradient: number): GPUParticleSystem;
  126218. /**
  126219. * Not supported by GPUParticleSystem
  126220. * @param gradient defines the gradient to use (between 0 and 1)
  126221. * @param factor defines the emit rate value to affect to the specified gradient
  126222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126223. * @returns the current particle system
  126224. */
  126225. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126226. /**
  126227. * Not supported by GPUParticleSystem
  126228. * @param gradient defines the gradient to remove
  126229. * @returns the current particle system
  126230. */
  126231. removeEmitRateGradient(gradient: number): IParticleSystem;
  126232. /**
  126233. * Not supported by GPUParticleSystem
  126234. * @param gradient defines the gradient to use (between 0 and 1)
  126235. * @param factor defines the start size value to affect to the specified gradient
  126236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126237. * @returns the current particle system
  126238. */
  126239. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126240. /**
  126241. * Not supported by GPUParticleSystem
  126242. * @param gradient defines the gradient to remove
  126243. * @returns the current particle system
  126244. */
  126245. removeStartSizeGradient(gradient: number): IParticleSystem;
  126246. /**
  126247. * Not supported by GPUParticleSystem
  126248. * @param gradient defines the gradient to use (between 0 and 1)
  126249. * @param min defines the color remap minimal range
  126250. * @param max defines the color remap maximal range
  126251. * @returns the current particle system
  126252. */
  126253. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126254. /**
  126255. * Not supported by GPUParticleSystem
  126256. * @param gradient defines the gradient to remove
  126257. * @returns the current particle system
  126258. */
  126259. removeColorRemapGradient(): IParticleSystem;
  126260. /**
  126261. * Not supported by GPUParticleSystem
  126262. * @param gradient defines the gradient to use (between 0 and 1)
  126263. * @param min defines the alpha remap minimal range
  126264. * @param max defines the alpha remap maximal range
  126265. * @returns the current particle system
  126266. */
  126267. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126268. /**
  126269. * Not supported by GPUParticleSystem
  126270. * @param gradient defines the gradient to remove
  126271. * @returns the current particle system
  126272. */
  126273. removeAlphaRemapGradient(): IParticleSystem;
  126274. /**
  126275. * Not supported by GPUParticleSystem
  126276. * @param gradient defines the gradient to use (between 0 and 1)
  126277. * @param color defines the color to affect to the specified gradient
  126278. * @returns the current particle system
  126279. */
  126280. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126281. /**
  126282. * Not supported by GPUParticleSystem
  126283. * @param gradient defines the gradient to remove
  126284. * @returns the current particle system
  126285. */
  126286. removeRampGradient(): IParticleSystem;
  126287. /**
  126288. * Not supported by GPUParticleSystem
  126289. * @returns the list of ramp gradients
  126290. */
  126291. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126292. /**
  126293. * Not supported by GPUParticleSystem
  126294. * Gets or sets a boolean indicating that ramp gradients must be used
  126295. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126296. */
  126297. useRampGradients: boolean;
  126298. /**
  126299. * Not supported by GPUParticleSystem
  126300. * @param gradient defines the gradient to use (between 0 and 1)
  126301. * @param factor defines the life time factor to affect to the specified gradient
  126302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126303. * @returns the current particle system
  126304. */
  126305. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126306. /**
  126307. * Not supported by GPUParticleSystem
  126308. * @param gradient defines the gradient to remove
  126309. * @returns the current particle system
  126310. */
  126311. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126312. /**
  126313. * Instantiates a GPU particle system.
  126314. * 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.
  126315. * @param name The name of the particle system
  126316. * @param options The options used to create the system
  126317. * @param scene The scene the particle system belongs to
  126318. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126319. */
  126320. constructor(name: string, options: Partial<{
  126321. capacity: number;
  126322. randomTextureSize: number;
  126323. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126324. protected _reset(): void;
  126325. private _createUpdateVAO;
  126326. private _createRenderVAO;
  126327. private _initialize;
  126328. /** @hidden */
  126329. _recreateUpdateEffect(): void;
  126330. /** @hidden */
  126331. _recreateRenderEffect(): void;
  126332. /**
  126333. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126334. * @param preWarm defines if we are in the pre-warmimg phase
  126335. */
  126336. animate(preWarm?: boolean): void;
  126337. private _createFactorGradientTexture;
  126338. private _createSizeGradientTexture;
  126339. private _createAngularSpeedGradientTexture;
  126340. private _createVelocityGradientTexture;
  126341. private _createLimitVelocityGradientTexture;
  126342. private _createDragGradientTexture;
  126343. private _createColorGradientTexture;
  126344. /**
  126345. * Renders the particle system in its current state
  126346. * @param preWarm defines if the system should only update the particles but not render them
  126347. * @returns the current number of particles
  126348. */
  126349. render(preWarm?: boolean): number;
  126350. /**
  126351. * Rebuilds the particle system
  126352. */
  126353. rebuild(): void;
  126354. private _releaseBuffers;
  126355. private _releaseVAOs;
  126356. /**
  126357. * Disposes the particle system and free the associated resources
  126358. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126359. */
  126360. dispose(disposeTexture?: boolean): void;
  126361. /**
  126362. * Clones the particle system.
  126363. * @param name The name of the cloned object
  126364. * @param newEmitter The new emitter to use
  126365. * @returns the cloned particle system
  126366. */
  126367. clone(name: string, newEmitter: any): GPUParticleSystem;
  126368. /**
  126369. * Serializes the particle system to a JSON object.
  126370. * @returns the JSON object
  126371. */
  126372. serialize(): any;
  126373. /**
  126374. * Parses a JSON object to create a GPU particle system.
  126375. * @param parsedParticleSystem The JSON object to parse
  126376. * @param scene The scene to create the particle system in
  126377. * @param rootUrl The root url to use to load external dependencies like texture
  126378. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126379. * @returns the parsed GPU particle system
  126380. */
  126381. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126382. }
  126383. }
  126384. declare module BABYLON {
  126385. /**
  126386. * Represents a set of particle systems working together to create a specific effect
  126387. */
  126388. export class ParticleSystemSet implements IDisposable {
  126389. /**
  126390. * Gets or sets base Assets URL
  126391. */
  126392. static BaseAssetsUrl: string;
  126393. private _emitterCreationOptions;
  126394. private _emitterNode;
  126395. /**
  126396. * Gets the particle system list
  126397. */
  126398. systems: IParticleSystem[];
  126399. /**
  126400. * Gets the emitter node used with this set
  126401. */
  126402. readonly emitterNode: Nullable<TransformNode>;
  126403. /**
  126404. * Creates a new emitter mesh as a sphere
  126405. * @param options defines the options used to create the sphere
  126406. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126407. * @param scene defines the hosting scene
  126408. */
  126409. setEmitterAsSphere(options: {
  126410. diameter: number;
  126411. segments: number;
  126412. color: Color3;
  126413. }, renderingGroupId: number, scene: Scene): void;
  126414. /**
  126415. * Starts all particle systems of the set
  126416. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126417. */
  126418. start(emitter?: AbstractMesh): void;
  126419. /**
  126420. * Release all associated resources
  126421. */
  126422. dispose(): void;
  126423. /**
  126424. * Serialize the set into a JSON compatible object
  126425. * @returns a JSON compatible representation of the set
  126426. */
  126427. serialize(): any;
  126428. /**
  126429. * Parse a new ParticleSystemSet from a serialized source
  126430. * @param data defines a JSON compatible representation of the set
  126431. * @param scene defines the hosting scene
  126432. * @param gpu defines if we want GPU particles or CPU particles
  126433. * @returns a new ParticleSystemSet
  126434. */
  126435. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126436. }
  126437. }
  126438. declare module BABYLON {
  126439. /**
  126440. * This class is made for on one-liner static method to help creating particle system set.
  126441. */
  126442. export class ParticleHelper {
  126443. /**
  126444. * Gets or sets base Assets URL
  126445. */
  126446. static BaseAssetsUrl: string;
  126447. /**
  126448. * Create a default particle system that you can tweak
  126449. * @param emitter defines the emitter to use
  126450. * @param capacity defines the system capacity (default is 500 particles)
  126451. * @param scene defines the hosting scene
  126452. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126453. * @returns the new Particle system
  126454. */
  126455. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126456. /**
  126457. * This is the main static method (one-liner) of this helper to create different particle systems
  126458. * @param type This string represents the type to the particle system to create
  126459. * @param scene The scene where the particle system should live
  126460. * @param gpu If the system will use gpu
  126461. * @returns the ParticleSystemSet created
  126462. */
  126463. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126464. /**
  126465. * Static function used to export a particle system to a ParticleSystemSet variable.
  126466. * Please note that the emitter shape is not exported
  126467. * @param systems defines the particle systems to export
  126468. * @returns the created particle system set
  126469. */
  126470. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126471. }
  126472. }
  126473. declare module BABYLON {
  126474. interface Engine {
  126475. /**
  126476. * Create an effect to use with particle systems.
  126477. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126478. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126479. * @param uniformsNames defines a list of attribute names
  126480. * @param samplers defines an array of string used to represent textures
  126481. * @param defines defines the string containing the defines to use to compile the shaders
  126482. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126483. * @param onCompiled defines a function to call when the effect creation is successful
  126484. * @param onError defines a function to call when the effect creation has failed
  126485. * @returns the new Effect
  126486. */
  126487. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126488. }
  126489. interface Mesh {
  126490. /**
  126491. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126492. * @returns an array of IParticleSystem
  126493. */
  126494. getEmittedParticleSystems(): IParticleSystem[];
  126495. /**
  126496. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126497. * @returns an array of IParticleSystem
  126498. */
  126499. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126500. }
  126501. /**
  126502. * @hidden
  126503. */
  126504. export var _IDoNeedToBeInTheBuild: number;
  126505. }
  126506. declare module BABYLON {
  126507. /** Defines the 4 color options */
  126508. export enum PointColor {
  126509. /** color value */
  126510. Color = 2,
  126511. /** uv value */
  126512. UV = 1,
  126513. /** random value */
  126514. Random = 0,
  126515. /** stated value */
  126516. Stated = 3
  126517. }
  126518. /**
  126519. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  126520. * 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.
  126521. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  126522. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  126523. *
  126524. * Full documentation here : TO BE ENTERED
  126525. */
  126526. export class PointsCloudSystem implements IDisposable {
  126527. /**
  126528. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  126529. * Example : var p = SPS.particles[i];
  126530. */
  126531. particles: CloudPoint[];
  126532. /**
  126533. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  126534. */
  126535. nbParticles: number;
  126536. /**
  126537. * This a counter for your own usage. It's not set by any SPS functions.
  126538. */
  126539. counter: number;
  126540. /**
  126541. * The PCS name. This name is also given to the underlying mesh.
  126542. */
  126543. name: string;
  126544. /**
  126545. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  126546. */
  126547. mesh: Mesh;
  126548. /**
  126549. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  126550. * Please read :
  126551. */
  126552. vars: any;
  126553. /**
  126554. * @hidden
  126555. */
  126556. _size: number;
  126557. private _scene;
  126558. private _promises;
  126559. private _positions;
  126560. private _indices;
  126561. private _normals;
  126562. private _colors;
  126563. private _uvs;
  126564. private _indices32;
  126565. private _positions32;
  126566. private _colors32;
  126567. private _uvs32;
  126568. private _updatable;
  126569. private _isVisibilityBoxLocked;
  126570. private _alwaysVisible;
  126571. private _groups;
  126572. private _groupCounter;
  126573. private _computeParticleColor;
  126574. private _computeParticleTexture;
  126575. private _computeParticleRotation;
  126576. private _computeBoundingBox;
  126577. private _isReady;
  126578. /**
  126579. * Creates a PCS (Points Cloud System) object
  126580. * @param name (String) is the PCS name, this will be the underlying mesh name
  126581. * @param pointSize (number) is the size for each point
  126582. * @param scene (Scene) is the scene in which the PCS is added
  126583. * @param options defines the options of the PCS e.g.
  126584. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  126585. */
  126586. constructor(name: string, pointSize: number, scene: Scene, options?: {
  126587. updatable?: boolean;
  126588. });
  126589. /**
  126590. * Builds the PCS underlying mesh. Returns a standard Mesh.
  126591. * If no points were added to the PCS, the returned mesh is just a single point.
  126592. * @returns a promise for the created mesh
  126593. */
  126594. buildMeshAsync(): Promise<Mesh>;
  126595. /**
  126596. * @hidden
  126597. */
  126598. private _buildMesh;
  126599. private _addParticle;
  126600. private _randomUnitVector;
  126601. private _getColorIndicesForCoord;
  126602. private _setPointsColorOrUV;
  126603. private _colorFromTexture;
  126604. private _calculateDensity;
  126605. /**
  126606. * Adds points to the PCS in random positions within a unit sphere
  126607. * @param nb (positive integer) the number of particles to be created from this model
  126608. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  126609. * @returns the number of groups in the system
  126610. */
  126611. addPoints(nb: number, pointFunction?: any): number;
  126612. /**
  126613. * Adds points to the PCS from the surface of the model shape
  126614. * @param mesh is any Mesh object that will be used as a surface model for the points
  126615. * @param nb (positive integer) the number of particles to be created from this model
  126616. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  126617. * @param color (color3) to be used when colorWith is stated
  126618. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126619. * @returns the number of groups in the system
  126620. */
  126621. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126622. /**
  126623. * Adds points to the PCS inside the model shape
  126624. * @param mesh is any Mesh object that will be used as a surface model for the points
  126625. * @param nb (positive integer) the number of particles to be created from this model
  126626. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  126627. * @param color (color4) to be used when colorWith is stated
  126628. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126629. * @returns the number of groups in the system
  126630. */
  126631. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126632. /**
  126633. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  126634. * This method calls `updateParticle()` for each particle of the SPS.
  126635. * For an animated SPS, it is usually called within the render loop.
  126636. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  126637. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  126638. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  126639. * @returns the PCS.
  126640. */
  126641. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  126642. /**
  126643. * Disposes the PCS.
  126644. */
  126645. dispose(): void;
  126646. /**
  126647. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  126648. * doc :
  126649. * @returns the PCS.
  126650. */
  126651. refreshVisibleSize(): PointsCloudSystem;
  126652. /**
  126653. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126654. * @param size the size (float) of the visibility box
  126655. * note : this doesn't lock the PCS mesh bounding box.
  126656. * doc :
  126657. */
  126658. setVisibilityBox(size: number): void;
  126659. /**
  126660. * Gets whether the PCS is always visible or not
  126661. * doc :
  126662. */
  126663. /**
  126664. * Sets the PCS as always visible or not
  126665. * doc :
  126666. */
  126667. isAlwaysVisible: boolean;
  126668. /**
  126669. * Tells to `setParticles()` to compute the particle rotations or not
  126670. * Default value : false. The PCS is faster when it's set to false
  126671. * Note : particle rotations are only applied to parent particles
  126672. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126673. */
  126674. computeParticleRotation: boolean;
  126675. /**
  126676. * Tells to `setParticles()` to compute the particle colors or not.
  126677. * Default value : true. The PCS is faster when it's set to false.
  126678. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126679. */
  126680. /**
  126681. * Gets if `setParticles()` computes the particle colors or not.
  126682. * Default value : false. The PCS is faster when it's set to false.
  126683. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126684. */
  126685. computeParticleColor: boolean;
  126686. /**
  126687. * Gets if `setParticles()` computes the particle textures or not.
  126688. * Default value : false. The PCS is faster when it's set to false.
  126689. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126690. */
  126691. computeParticleTexture: boolean;
  126692. /**
  126693. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126694. */
  126695. /**
  126696. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126697. */
  126698. computeBoundingBox: boolean;
  126699. /**
  126700. * This function does nothing. It may be overwritten to set all the particle first values.
  126701. * The PCS doesn't call this function, you may have to call it by your own.
  126702. * doc :
  126703. */
  126704. initParticles(): void;
  126705. /**
  126706. * This function does nothing. It may be overwritten to recycle a particle
  126707. * The PCS doesn't call this function, you can to call it
  126708. * doc :
  126709. * @param particle The particle to recycle
  126710. * @returns the recycled particle
  126711. */
  126712. recycleParticle(particle: CloudPoint): CloudPoint;
  126713. /**
  126714. * Updates a particle : this function should be overwritten by the user.
  126715. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126716. * doc :
  126717. * @example : just set a particle position or velocity and recycle conditions
  126718. * @param particle The particle to update
  126719. * @returns the updated particle
  126720. */
  126721. updateParticle(particle: CloudPoint): CloudPoint;
  126722. /**
  126723. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126724. * This does nothing and may be overwritten by the user.
  126725. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126726. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126727. * @param update the boolean update value actually passed to setParticles()
  126728. */
  126729. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126730. /**
  126731. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126732. * This will be passed three parameters.
  126733. * This does nothing and may be overwritten by the user.
  126734. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126735. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126736. * @param update the boolean update value actually passed to setParticles()
  126737. */
  126738. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126739. }
  126740. }
  126741. declare module BABYLON {
  126742. /**
  126743. * Represents one particle of a points cloud system.
  126744. */
  126745. export class CloudPoint {
  126746. /**
  126747. * particle global index
  126748. */
  126749. idx: number;
  126750. /**
  126751. * The color of the particle
  126752. */
  126753. color: Nullable<Color4>;
  126754. /**
  126755. * The world space position of the particle.
  126756. */
  126757. position: Vector3;
  126758. /**
  126759. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126760. */
  126761. rotation: Vector3;
  126762. /**
  126763. * The world space rotation quaternion of the particle.
  126764. */
  126765. rotationQuaternion: Nullable<Quaternion>;
  126766. /**
  126767. * The uv of the particle.
  126768. */
  126769. uv: Nullable<Vector2>;
  126770. /**
  126771. * The current speed of the particle.
  126772. */
  126773. velocity: Vector3;
  126774. /**
  126775. * The pivot point in the particle local space.
  126776. */
  126777. pivot: Vector3;
  126778. /**
  126779. * Must the particle be translated from its pivot point in its local space ?
  126780. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126781. * Default : false
  126782. */
  126783. translateFromPivot: boolean;
  126784. /**
  126785. * Index of this particle in the global "positions" array (Internal use)
  126786. * @hidden
  126787. */
  126788. _pos: number;
  126789. /**
  126790. * @hidden Index of this particle in the global "indices" array (Internal use)
  126791. */
  126792. _ind: number;
  126793. /**
  126794. * Group this particle belongs to
  126795. */
  126796. _group: PointsGroup;
  126797. /**
  126798. * Group id of this particle
  126799. */
  126800. groupId: number;
  126801. /**
  126802. * Index of the particle in its group id (Internal use)
  126803. */
  126804. idxInGroup: number;
  126805. /**
  126806. * @hidden Particle BoundingInfo object (Internal use)
  126807. */
  126808. _boundingInfo: BoundingInfo;
  126809. /**
  126810. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126811. */
  126812. _pcs: PointsCloudSystem;
  126813. /**
  126814. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126815. */
  126816. _stillInvisible: boolean;
  126817. /**
  126818. * @hidden Last computed particle rotation matrix
  126819. */
  126820. _rotationMatrix: number[];
  126821. /**
  126822. * Parent particle Id, if any.
  126823. * Default null.
  126824. */
  126825. parentId: Nullable<number>;
  126826. /**
  126827. * @hidden Internal global position in the PCS.
  126828. */
  126829. _globalPosition: Vector3;
  126830. /**
  126831. * Creates a Point Cloud object.
  126832. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126833. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126834. * @param group (PointsGroup) is the group the particle belongs to
  126835. * @param groupId (integer) is the group identifier in the PCS.
  126836. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126837. * @param pcs defines the PCS it is associated to
  126838. */
  126839. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126840. /**
  126841. * get point size
  126842. */
  126843. /**
  126844. * Set point size
  126845. */
  126846. size: Vector3;
  126847. /**
  126848. * Legacy support, changed quaternion to rotationQuaternion
  126849. */
  126850. /**
  126851. * Legacy support, changed quaternion to rotationQuaternion
  126852. */
  126853. quaternion: Nullable<Quaternion>;
  126854. /**
  126855. * Returns a boolean. True if the particle intersects a mesh, else false
  126856. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126857. * @param target is the object (point or mesh) what the intersection is computed against
  126858. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126859. * @returns true if it intersects
  126860. */
  126861. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126862. /**
  126863. * get the rotation matrix of the particle
  126864. * @hidden
  126865. */
  126866. getRotationMatrix(m: Matrix): void;
  126867. }
  126868. /**
  126869. * Represents a group of points in a points cloud system
  126870. * * PCS internal tool, don't use it manually.
  126871. */
  126872. export class PointsGroup {
  126873. /**
  126874. * The group id
  126875. * @hidden
  126876. */
  126877. groupID: number;
  126878. /**
  126879. * image data for group (internal use)
  126880. * @hidden
  126881. */
  126882. _groupImageData: Nullable<ArrayBufferView>;
  126883. /**
  126884. * Image Width (internal use)
  126885. * @hidden
  126886. */
  126887. _groupImgWidth: number;
  126888. /**
  126889. * Image Height (internal use)
  126890. * @hidden
  126891. */
  126892. _groupImgHeight: number;
  126893. /**
  126894. * Custom position function (internal use)
  126895. * @hidden
  126896. */
  126897. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126898. /**
  126899. * density per facet for surface points
  126900. * @hidden
  126901. */
  126902. _groupDensity: number[];
  126903. /**
  126904. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126905. * PCS internal tool, don't use it manually.
  126906. * @hidden
  126907. */
  126908. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. interface Scene {
  126913. /** @hidden (Backing field) */
  126914. _physicsEngine: Nullable<IPhysicsEngine>;
  126915. /**
  126916. * Gets the current physics engine
  126917. * @returns a IPhysicsEngine or null if none attached
  126918. */
  126919. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126920. /**
  126921. * Enables physics to the current scene
  126922. * @param gravity defines the scene's gravity for the physics engine
  126923. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126924. * @return a boolean indicating if the physics engine was initialized
  126925. */
  126926. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126927. /**
  126928. * Disables and disposes the physics engine associated with the scene
  126929. */
  126930. disablePhysicsEngine(): void;
  126931. /**
  126932. * Gets a boolean indicating if there is an active physics engine
  126933. * @returns a boolean indicating if there is an active physics engine
  126934. */
  126935. isPhysicsEnabled(): boolean;
  126936. /**
  126937. * Deletes a physics compound impostor
  126938. * @param compound defines the compound to delete
  126939. */
  126940. deleteCompoundImpostor(compound: any): void;
  126941. /**
  126942. * An event triggered when physic simulation is about to be run
  126943. */
  126944. onBeforePhysicsObservable: Observable<Scene>;
  126945. /**
  126946. * An event triggered when physic simulation has been done
  126947. */
  126948. onAfterPhysicsObservable: Observable<Scene>;
  126949. }
  126950. interface AbstractMesh {
  126951. /** @hidden */
  126952. _physicsImpostor: Nullable<PhysicsImpostor>;
  126953. /**
  126954. * Gets or sets impostor used for physic simulation
  126955. * @see http://doc.babylonjs.com/features/physics_engine
  126956. */
  126957. physicsImpostor: Nullable<PhysicsImpostor>;
  126958. /**
  126959. * Gets the current physics impostor
  126960. * @see http://doc.babylonjs.com/features/physics_engine
  126961. * @returns a physics impostor or null
  126962. */
  126963. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126964. /** Apply a physic impulse to the mesh
  126965. * @param force defines the force to apply
  126966. * @param contactPoint defines where to apply the force
  126967. * @returns the current mesh
  126968. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126969. */
  126970. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126971. /**
  126972. * Creates a physic joint between two meshes
  126973. * @param otherMesh defines the other mesh to use
  126974. * @param pivot1 defines the pivot to use on this mesh
  126975. * @param pivot2 defines the pivot to use on the other mesh
  126976. * @param options defines additional options (can be plugin dependent)
  126977. * @returns the current mesh
  126978. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126979. */
  126980. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126981. /** @hidden */
  126982. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126983. }
  126984. /**
  126985. * Defines the physics engine scene component responsible to manage a physics engine
  126986. */
  126987. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126988. /**
  126989. * The component name helpful to identify the component in the list of scene components.
  126990. */
  126991. readonly name: string;
  126992. /**
  126993. * The scene the component belongs to.
  126994. */
  126995. scene: Scene;
  126996. /**
  126997. * Creates a new instance of the component for the given scene
  126998. * @param scene Defines the scene to register the component in
  126999. */
  127000. constructor(scene: Scene);
  127001. /**
  127002. * Registers the component in a given scene
  127003. */
  127004. register(): void;
  127005. /**
  127006. * Rebuilds the elements related to this component in case of
  127007. * context lost for instance.
  127008. */
  127009. rebuild(): void;
  127010. /**
  127011. * Disposes the component and the associated ressources
  127012. */
  127013. dispose(): void;
  127014. }
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * A helper for physics simulations
  127019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127020. */
  127021. export class PhysicsHelper {
  127022. private _scene;
  127023. private _physicsEngine;
  127024. /**
  127025. * Initializes the Physics helper
  127026. * @param scene Babylon.js scene
  127027. */
  127028. constructor(scene: Scene);
  127029. /**
  127030. * Applies a radial explosion impulse
  127031. * @param origin the origin of the explosion
  127032. * @param radiusOrEventOptions the radius or the options of radial explosion
  127033. * @param strength the explosion strength
  127034. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127035. * @returns A physics radial explosion event, or null
  127036. */
  127037. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127038. /**
  127039. * Applies a radial explosion force
  127040. * @param origin the origin of the explosion
  127041. * @param radiusOrEventOptions the radius or the options of radial explosion
  127042. * @param strength the explosion strength
  127043. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127044. * @returns A physics radial explosion event, or null
  127045. */
  127046. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127047. /**
  127048. * Creates a gravitational field
  127049. * @param origin the origin of the explosion
  127050. * @param radiusOrEventOptions the radius or the options of radial explosion
  127051. * @param strength the explosion strength
  127052. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127053. * @returns A physics gravitational field event, or null
  127054. */
  127055. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127056. /**
  127057. * Creates a physics updraft event
  127058. * @param origin the origin of the updraft
  127059. * @param radiusOrEventOptions the radius or the options of the updraft
  127060. * @param strength the strength of the updraft
  127061. * @param height the height of the updraft
  127062. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127063. * @returns A physics updraft event, or null
  127064. */
  127065. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127066. /**
  127067. * Creates a physics vortex event
  127068. * @param origin the of the vortex
  127069. * @param radiusOrEventOptions the radius or the options of the vortex
  127070. * @param strength the strength of the vortex
  127071. * @param height the height of the vortex
  127072. * @returns a Physics vortex event, or null
  127073. * A physics vortex event or null
  127074. */
  127075. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127076. }
  127077. /**
  127078. * Represents a physics radial explosion event
  127079. */
  127080. class PhysicsRadialExplosionEvent {
  127081. private _scene;
  127082. private _options;
  127083. private _sphere;
  127084. private _dataFetched;
  127085. /**
  127086. * Initializes a radial explosioin event
  127087. * @param _scene BabylonJS scene
  127088. * @param _options The options for the vortex event
  127089. */
  127090. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127091. /**
  127092. * Returns the data related to the radial explosion event (sphere).
  127093. * @returns The radial explosion event data
  127094. */
  127095. getData(): PhysicsRadialExplosionEventData;
  127096. /**
  127097. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127098. * @param impostor A physics imposter
  127099. * @param origin the origin of the explosion
  127100. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127101. */
  127102. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127103. /**
  127104. * Triggers affecterd impostors callbacks
  127105. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127106. */
  127107. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127108. /**
  127109. * Disposes the sphere.
  127110. * @param force Specifies if the sphere should be disposed by force
  127111. */
  127112. dispose(force?: boolean): void;
  127113. /*** Helpers ***/
  127114. private _prepareSphere;
  127115. private _intersectsWithSphere;
  127116. }
  127117. /**
  127118. * Represents a gravitational field event
  127119. */
  127120. class PhysicsGravitationalFieldEvent {
  127121. private _physicsHelper;
  127122. private _scene;
  127123. private _origin;
  127124. private _options;
  127125. private _tickCallback;
  127126. private _sphere;
  127127. private _dataFetched;
  127128. /**
  127129. * Initializes the physics gravitational field event
  127130. * @param _physicsHelper A physics helper
  127131. * @param _scene BabylonJS scene
  127132. * @param _origin The origin position of the gravitational field event
  127133. * @param _options The options for the vortex event
  127134. */
  127135. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127136. /**
  127137. * Returns the data related to the gravitational field event (sphere).
  127138. * @returns A gravitational field event
  127139. */
  127140. getData(): PhysicsGravitationalFieldEventData;
  127141. /**
  127142. * Enables the gravitational field.
  127143. */
  127144. enable(): void;
  127145. /**
  127146. * Disables the gravitational field.
  127147. */
  127148. disable(): void;
  127149. /**
  127150. * Disposes the sphere.
  127151. * @param force The force to dispose from the gravitational field event
  127152. */
  127153. dispose(force?: boolean): void;
  127154. private _tick;
  127155. }
  127156. /**
  127157. * Represents a physics updraft event
  127158. */
  127159. class PhysicsUpdraftEvent {
  127160. private _scene;
  127161. private _origin;
  127162. private _options;
  127163. private _physicsEngine;
  127164. private _originTop;
  127165. private _originDirection;
  127166. private _tickCallback;
  127167. private _cylinder;
  127168. private _cylinderPosition;
  127169. private _dataFetched;
  127170. /**
  127171. * Initializes the physics updraft event
  127172. * @param _scene BabylonJS scene
  127173. * @param _origin The origin position of the updraft
  127174. * @param _options The options for the updraft event
  127175. */
  127176. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127177. /**
  127178. * Returns the data related to the updraft event (cylinder).
  127179. * @returns A physics updraft event
  127180. */
  127181. getData(): PhysicsUpdraftEventData;
  127182. /**
  127183. * Enables the updraft.
  127184. */
  127185. enable(): void;
  127186. /**
  127187. * Disables the updraft.
  127188. */
  127189. disable(): void;
  127190. /**
  127191. * Disposes the cylinder.
  127192. * @param force Specifies if the updraft should be disposed by force
  127193. */
  127194. dispose(force?: boolean): void;
  127195. private getImpostorHitData;
  127196. private _tick;
  127197. /*** Helpers ***/
  127198. private _prepareCylinder;
  127199. private _intersectsWithCylinder;
  127200. }
  127201. /**
  127202. * Represents a physics vortex event
  127203. */
  127204. class PhysicsVortexEvent {
  127205. private _scene;
  127206. private _origin;
  127207. private _options;
  127208. private _physicsEngine;
  127209. private _originTop;
  127210. private _tickCallback;
  127211. private _cylinder;
  127212. private _cylinderPosition;
  127213. private _dataFetched;
  127214. /**
  127215. * Initializes the physics vortex event
  127216. * @param _scene The BabylonJS scene
  127217. * @param _origin The origin position of the vortex
  127218. * @param _options The options for the vortex event
  127219. */
  127220. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127221. /**
  127222. * Returns the data related to the vortex event (cylinder).
  127223. * @returns The physics vortex event data
  127224. */
  127225. getData(): PhysicsVortexEventData;
  127226. /**
  127227. * Enables the vortex.
  127228. */
  127229. enable(): void;
  127230. /**
  127231. * Disables the cortex.
  127232. */
  127233. disable(): void;
  127234. /**
  127235. * Disposes the sphere.
  127236. * @param force
  127237. */
  127238. dispose(force?: boolean): void;
  127239. private getImpostorHitData;
  127240. private _tick;
  127241. /*** Helpers ***/
  127242. private _prepareCylinder;
  127243. private _intersectsWithCylinder;
  127244. }
  127245. /**
  127246. * Options fot the radial explosion event
  127247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127248. */
  127249. export class PhysicsRadialExplosionEventOptions {
  127250. /**
  127251. * The radius of the sphere for the radial explosion.
  127252. */
  127253. radius: number;
  127254. /**
  127255. * The strenth of the explosion.
  127256. */
  127257. strength: number;
  127258. /**
  127259. * The strenght of the force in correspondence to the distance of the affected object
  127260. */
  127261. falloff: PhysicsRadialImpulseFalloff;
  127262. /**
  127263. * Sphere options for the radial explosion.
  127264. */
  127265. sphere: {
  127266. segments: number;
  127267. diameter: number;
  127268. };
  127269. /**
  127270. * Sphere options for the radial explosion.
  127271. */
  127272. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127273. }
  127274. /**
  127275. * Options fot the updraft event
  127276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127277. */
  127278. export class PhysicsUpdraftEventOptions {
  127279. /**
  127280. * The radius of the cylinder for the vortex
  127281. */
  127282. radius: number;
  127283. /**
  127284. * The strenth of the updraft.
  127285. */
  127286. strength: number;
  127287. /**
  127288. * The height of the cylinder for the updraft.
  127289. */
  127290. height: number;
  127291. /**
  127292. * The mode for the the updraft.
  127293. */
  127294. updraftMode: PhysicsUpdraftMode;
  127295. }
  127296. /**
  127297. * Options fot the vortex event
  127298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127299. */
  127300. export class PhysicsVortexEventOptions {
  127301. /**
  127302. * The radius of the cylinder for the vortex
  127303. */
  127304. radius: number;
  127305. /**
  127306. * The strenth of the vortex.
  127307. */
  127308. strength: number;
  127309. /**
  127310. * The height of the cylinder for the vortex.
  127311. */
  127312. height: number;
  127313. /**
  127314. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127315. */
  127316. centripetalForceThreshold: number;
  127317. /**
  127318. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127319. */
  127320. centripetalForceMultiplier: number;
  127321. /**
  127322. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127323. */
  127324. centrifugalForceMultiplier: number;
  127325. /**
  127326. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127327. */
  127328. updraftForceMultiplier: number;
  127329. }
  127330. /**
  127331. * The strenght of the force in correspondence to the distance of the affected object
  127332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127333. */
  127334. export enum PhysicsRadialImpulseFalloff {
  127335. /** Defines that impulse is constant in strength across it's whole radius */
  127336. Constant = 0,
  127337. /** Defines that impulse gets weaker if it's further from the origin */
  127338. Linear = 1
  127339. }
  127340. /**
  127341. * The strength of the force in correspondence to the distance of the affected object
  127342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127343. */
  127344. export enum PhysicsUpdraftMode {
  127345. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127346. Center = 0,
  127347. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127348. Perpendicular = 1
  127349. }
  127350. /**
  127351. * Interface for a physics hit data
  127352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127353. */
  127354. export interface PhysicsHitData {
  127355. /**
  127356. * The force applied at the contact point
  127357. */
  127358. force: Vector3;
  127359. /**
  127360. * The contact point
  127361. */
  127362. contactPoint: Vector3;
  127363. /**
  127364. * The distance from the origin to the contact point
  127365. */
  127366. distanceFromOrigin: number;
  127367. }
  127368. /**
  127369. * Interface for radial explosion event data
  127370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127371. */
  127372. export interface PhysicsRadialExplosionEventData {
  127373. /**
  127374. * A sphere used for the radial explosion event
  127375. */
  127376. sphere: Mesh;
  127377. }
  127378. /**
  127379. * Interface for gravitational field event data
  127380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127381. */
  127382. export interface PhysicsGravitationalFieldEventData {
  127383. /**
  127384. * A sphere mesh used for the gravitational field event
  127385. */
  127386. sphere: Mesh;
  127387. }
  127388. /**
  127389. * Interface for updraft event data
  127390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127391. */
  127392. export interface PhysicsUpdraftEventData {
  127393. /**
  127394. * A cylinder used for the updraft event
  127395. */
  127396. cylinder: Mesh;
  127397. }
  127398. /**
  127399. * Interface for vortex event data
  127400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127401. */
  127402. export interface PhysicsVortexEventData {
  127403. /**
  127404. * A cylinder used for the vortex event
  127405. */
  127406. cylinder: Mesh;
  127407. }
  127408. /**
  127409. * Interface for an affected physics impostor
  127410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127411. */
  127412. export interface PhysicsAffectedImpostorWithData {
  127413. /**
  127414. * The impostor affected by the effect
  127415. */
  127416. impostor: PhysicsImpostor;
  127417. /**
  127418. * The data about the hit/horce from the explosion
  127419. */
  127420. hitData: PhysicsHitData;
  127421. }
  127422. }
  127423. declare module BABYLON {
  127424. /** @hidden */
  127425. export var blackAndWhitePixelShader: {
  127426. name: string;
  127427. shader: string;
  127428. };
  127429. }
  127430. declare module BABYLON {
  127431. /**
  127432. * Post process used to render in black and white
  127433. */
  127434. export class BlackAndWhitePostProcess extends PostProcess {
  127435. /**
  127436. * Linear about to convert he result to black and white (default: 1)
  127437. */
  127438. degree: number;
  127439. /**
  127440. * Creates a black and white post process
  127441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127442. * @param name The name of the effect.
  127443. * @param options The required width/height ratio to downsize to before computing the render pass.
  127444. * @param camera The camera to apply the render pass to.
  127445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127446. * @param engine The engine which the post process will be applied. (default: current engine)
  127447. * @param reusable If the post process can be reused on the same frame. (default: false)
  127448. */
  127449. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * This represents a set of one or more post processes in Babylon.
  127455. * A post process can be used to apply a shader to a texture after it is rendered.
  127456. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127457. */
  127458. export class PostProcessRenderEffect {
  127459. private _postProcesses;
  127460. private _getPostProcesses;
  127461. private _singleInstance;
  127462. private _cameras;
  127463. private _indicesForCamera;
  127464. /**
  127465. * Name of the effect
  127466. * @hidden
  127467. */
  127468. _name: string;
  127469. /**
  127470. * Instantiates a post process render effect.
  127471. * A post process can be used to apply a shader to a texture after it is rendered.
  127472. * @param engine The engine the effect is tied to
  127473. * @param name The name of the effect
  127474. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127475. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127476. */
  127477. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127478. /**
  127479. * Checks if all the post processes in the effect are supported.
  127480. */
  127481. readonly isSupported: boolean;
  127482. /**
  127483. * Updates the current state of the effect
  127484. * @hidden
  127485. */
  127486. _update(): void;
  127487. /**
  127488. * Attaches the effect on cameras
  127489. * @param cameras The camera to attach to.
  127490. * @hidden
  127491. */
  127492. _attachCameras(cameras: Camera): void;
  127493. /**
  127494. * Attaches the effect on cameras
  127495. * @param cameras The camera to attach to.
  127496. * @hidden
  127497. */
  127498. _attachCameras(cameras: Camera[]): void;
  127499. /**
  127500. * Detaches the effect on cameras
  127501. * @param cameras The camera to detatch from.
  127502. * @hidden
  127503. */
  127504. _detachCameras(cameras: Camera): void;
  127505. /**
  127506. * Detatches the effect on cameras
  127507. * @param cameras The camera to detatch from.
  127508. * @hidden
  127509. */
  127510. _detachCameras(cameras: Camera[]): void;
  127511. /**
  127512. * Enables the effect on given cameras
  127513. * @param cameras The camera to enable.
  127514. * @hidden
  127515. */
  127516. _enable(cameras: Camera): void;
  127517. /**
  127518. * Enables the effect on given cameras
  127519. * @param cameras The camera to enable.
  127520. * @hidden
  127521. */
  127522. _enable(cameras: Nullable<Camera[]>): void;
  127523. /**
  127524. * Disables the effect on the given cameras
  127525. * @param cameras The camera to disable.
  127526. * @hidden
  127527. */
  127528. _disable(cameras: Camera): void;
  127529. /**
  127530. * Disables the effect on the given cameras
  127531. * @param cameras The camera to disable.
  127532. * @hidden
  127533. */
  127534. _disable(cameras: Nullable<Camera[]>): void;
  127535. /**
  127536. * Gets a list of the post processes contained in the effect.
  127537. * @param camera The camera to get the post processes on.
  127538. * @returns The list of the post processes in the effect.
  127539. */
  127540. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  127541. }
  127542. }
  127543. declare module BABYLON {
  127544. /** @hidden */
  127545. export var extractHighlightsPixelShader: {
  127546. name: string;
  127547. shader: string;
  127548. };
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * 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.
  127553. */
  127554. export class ExtractHighlightsPostProcess extends PostProcess {
  127555. /**
  127556. * The luminance threshold, pixels below this value will be set to black.
  127557. */
  127558. threshold: number;
  127559. /** @hidden */
  127560. _exposure: number;
  127561. /**
  127562. * Post process which has the input texture to be used when performing highlight extraction
  127563. * @hidden
  127564. */
  127565. _inputPostProcess: Nullable<PostProcess>;
  127566. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127567. }
  127568. }
  127569. declare module BABYLON {
  127570. /** @hidden */
  127571. export var bloomMergePixelShader: {
  127572. name: string;
  127573. shader: string;
  127574. };
  127575. }
  127576. declare module BABYLON {
  127577. /**
  127578. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127579. */
  127580. export class BloomMergePostProcess extends PostProcess {
  127581. /** Weight of the bloom to be added to the original input. */
  127582. weight: number;
  127583. /**
  127584. * Creates a new instance of @see BloomMergePostProcess
  127585. * @param name The name of the effect.
  127586. * @param originalFromInput Post process which's input will be used for the merge.
  127587. * @param blurred Blurred highlights post process which's output will be used.
  127588. * @param weight Weight of the bloom to be added to the original input.
  127589. * @param options The required width/height ratio to downsize to before computing the render pass.
  127590. * @param camera The camera to apply the render pass to.
  127591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127592. * @param engine The engine which the post process will be applied. (default: current engine)
  127593. * @param reusable If the post process can be reused on the same frame. (default: false)
  127594. * @param textureType Type of textures used when performing the post process. (default: 0)
  127595. * @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)
  127596. */
  127597. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  127598. /** Weight of the bloom to be added to the original input. */
  127599. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127600. }
  127601. }
  127602. declare module BABYLON {
  127603. /**
  127604. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  127605. */
  127606. export class BloomEffect extends PostProcessRenderEffect {
  127607. private bloomScale;
  127608. /**
  127609. * @hidden Internal
  127610. */
  127611. _effects: Array<PostProcess>;
  127612. /**
  127613. * @hidden Internal
  127614. */
  127615. _downscale: ExtractHighlightsPostProcess;
  127616. private _blurX;
  127617. private _blurY;
  127618. private _merge;
  127619. /**
  127620. * The luminance threshold to find bright areas of the image to bloom.
  127621. */
  127622. threshold: number;
  127623. /**
  127624. * The strength of the bloom.
  127625. */
  127626. weight: number;
  127627. /**
  127628. * Specifies the size of the bloom blur kernel, relative to the final output size
  127629. */
  127630. kernel: number;
  127631. /**
  127632. * Creates a new instance of @see BloomEffect
  127633. * @param scene The scene the effect belongs to.
  127634. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  127635. * @param bloomKernel The size of the kernel to be used when applying the blur.
  127636. * @param bloomWeight The the strength of bloom.
  127637. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127638. * @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)
  127639. */
  127640. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  127641. /**
  127642. * Disposes each of the internal effects for a given camera.
  127643. * @param camera The camera to dispose the effect on.
  127644. */
  127645. disposeEffects(camera: Camera): void;
  127646. /**
  127647. * @hidden Internal
  127648. */
  127649. _updateEffects(): void;
  127650. /**
  127651. * Internal
  127652. * @returns if all the contained post processes are ready.
  127653. * @hidden
  127654. */
  127655. _isReady(): boolean;
  127656. }
  127657. }
  127658. declare module BABYLON {
  127659. /** @hidden */
  127660. export var chromaticAberrationPixelShader: {
  127661. name: string;
  127662. shader: string;
  127663. };
  127664. }
  127665. declare module BABYLON {
  127666. /**
  127667. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127668. */
  127669. export class ChromaticAberrationPostProcess extends PostProcess {
  127670. /**
  127671. * The amount of seperation of rgb channels (default: 30)
  127672. */
  127673. aberrationAmount: number;
  127674. /**
  127675. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127676. */
  127677. radialIntensity: number;
  127678. /**
  127679. * 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))
  127680. */
  127681. direction: Vector2;
  127682. /**
  127683. * 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))
  127684. */
  127685. centerPosition: Vector2;
  127686. /**
  127687. * Creates a new instance ChromaticAberrationPostProcess
  127688. * @param name The name of the effect.
  127689. * @param screenWidth The width of the screen to apply the effect on.
  127690. * @param screenHeight The height of the screen to apply the effect on.
  127691. * @param options The required width/height ratio to downsize to before computing the render pass.
  127692. * @param camera The camera to apply the render pass to.
  127693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127694. * @param engine The engine which the post process will be applied. (default: current engine)
  127695. * @param reusable If the post process can be reused on the same frame. (default: false)
  127696. * @param textureType Type of textures used when performing the post process. (default: 0)
  127697. * @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)
  127698. */
  127699. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127700. }
  127701. }
  127702. declare module BABYLON {
  127703. /** @hidden */
  127704. export var circleOfConfusionPixelShader: {
  127705. name: string;
  127706. shader: string;
  127707. };
  127708. }
  127709. declare module BABYLON {
  127710. /**
  127711. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127712. */
  127713. export class CircleOfConfusionPostProcess extends PostProcess {
  127714. /**
  127715. * 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.
  127716. */
  127717. lensSize: number;
  127718. /**
  127719. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127720. */
  127721. fStop: number;
  127722. /**
  127723. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127724. */
  127725. focusDistance: number;
  127726. /**
  127727. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127728. */
  127729. focalLength: number;
  127730. private _depthTexture;
  127731. /**
  127732. * Creates a new instance CircleOfConfusionPostProcess
  127733. * @param name The name of the effect.
  127734. * @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.
  127735. * @param options The required width/height ratio to downsize to before computing the render pass.
  127736. * @param camera The camera to apply the render pass to.
  127737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127738. * @param engine The engine which the post process will be applied. (default: current engine)
  127739. * @param reusable If the post process can be reused on the same frame. (default: false)
  127740. * @param textureType Type of textures used when performing the post process. (default: 0)
  127741. * @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)
  127742. */
  127743. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127744. /**
  127745. * 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.
  127746. */
  127747. depthTexture: RenderTargetTexture;
  127748. }
  127749. }
  127750. declare module BABYLON {
  127751. /** @hidden */
  127752. export var colorCorrectionPixelShader: {
  127753. name: string;
  127754. shader: string;
  127755. };
  127756. }
  127757. declare module BABYLON {
  127758. /**
  127759. *
  127760. * This post-process allows the modification of rendered colors by using
  127761. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127762. *
  127763. * The object needs to be provided an url to a texture containing the color
  127764. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127765. * Use an image editing software to tweak the LUT to match your needs.
  127766. *
  127767. * For an example of a color LUT, see here:
  127768. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127769. * For explanations on color grading, see here:
  127770. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127771. *
  127772. */
  127773. export class ColorCorrectionPostProcess extends PostProcess {
  127774. private _colorTableTexture;
  127775. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127776. }
  127777. }
  127778. declare module BABYLON {
  127779. /** @hidden */
  127780. export var convolutionPixelShader: {
  127781. name: string;
  127782. shader: string;
  127783. };
  127784. }
  127785. declare module BABYLON {
  127786. /**
  127787. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127788. * input texture to perform effects such as edge detection or sharpening
  127789. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127790. */
  127791. export class ConvolutionPostProcess extends PostProcess {
  127792. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127793. kernel: number[];
  127794. /**
  127795. * Creates a new instance ConvolutionPostProcess
  127796. * @param name The name of the effect.
  127797. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127798. * @param options The required width/height ratio to downsize to before computing the render pass.
  127799. * @param camera The camera to apply the render pass to.
  127800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127801. * @param engine The engine which the post process will be applied. (default: current engine)
  127802. * @param reusable If the post process can be reused on the same frame. (default: false)
  127803. * @param textureType Type of textures used when performing the post process. (default: 0)
  127804. */
  127805. constructor(name: string,
  127806. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127807. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127808. /**
  127809. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127810. */
  127811. static EdgeDetect0Kernel: number[];
  127812. /**
  127813. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127814. */
  127815. static EdgeDetect1Kernel: number[];
  127816. /**
  127817. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127818. */
  127819. static EdgeDetect2Kernel: number[];
  127820. /**
  127821. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127822. */
  127823. static SharpenKernel: number[];
  127824. /**
  127825. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127826. */
  127827. static EmbossKernel: number[];
  127828. /**
  127829. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127830. */
  127831. static GaussianKernel: number[];
  127832. }
  127833. }
  127834. declare module BABYLON {
  127835. /**
  127836. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127837. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127838. * based on samples that have a large difference in distance than the center pixel.
  127839. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127840. */
  127841. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127842. direction: Vector2;
  127843. /**
  127844. * Creates a new instance CircleOfConfusionPostProcess
  127845. * @param name The name of the effect.
  127846. * @param scene The scene the effect belongs to.
  127847. * @param direction The direction the blur should be applied.
  127848. * @param kernel The size of the kernel used to blur.
  127849. * @param options The required width/height ratio to downsize to before computing the render pass.
  127850. * @param camera The camera to apply the render pass to.
  127851. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127852. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127854. * @param engine The engine which the post process will be applied. (default: current engine)
  127855. * @param reusable If the post process can be reused on the same frame. (default: false)
  127856. * @param textureType Type of textures used when performing the post process. (default: 0)
  127857. * @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)
  127858. */
  127859. 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);
  127860. }
  127861. }
  127862. declare module BABYLON {
  127863. /** @hidden */
  127864. export var depthOfFieldMergePixelShader: {
  127865. name: string;
  127866. shader: string;
  127867. };
  127868. }
  127869. declare module BABYLON {
  127870. /**
  127871. * Options to be set when merging outputs from the default pipeline.
  127872. */
  127873. export class DepthOfFieldMergePostProcessOptions {
  127874. /**
  127875. * The original image to merge on top of
  127876. */
  127877. originalFromInput: PostProcess;
  127878. /**
  127879. * Parameters to perform the merge of the depth of field effect
  127880. */
  127881. depthOfField?: {
  127882. circleOfConfusion: PostProcess;
  127883. blurSteps: Array<PostProcess>;
  127884. };
  127885. /**
  127886. * Parameters to perform the merge of bloom effect
  127887. */
  127888. bloom?: {
  127889. blurred: PostProcess;
  127890. weight: number;
  127891. };
  127892. }
  127893. /**
  127894. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127895. */
  127896. export class DepthOfFieldMergePostProcess extends PostProcess {
  127897. private blurSteps;
  127898. /**
  127899. * Creates a new instance of DepthOfFieldMergePostProcess
  127900. * @param name The name of the effect.
  127901. * @param originalFromInput Post process which's input will be used for the merge.
  127902. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127903. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127904. * @param options The required width/height ratio to downsize to before computing the render pass.
  127905. * @param camera The camera to apply the render pass to.
  127906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127907. * @param engine The engine which the post process will be applied. (default: current engine)
  127908. * @param reusable If the post process can be reused on the same frame. (default: false)
  127909. * @param textureType Type of textures used when performing the post process. (default: 0)
  127910. * @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)
  127911. */
  127912. 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);
  127913. /**
  127914. * Updates the effect with the current post process compile time values and recompiles the shader.
  127915. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127916. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127917. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127918. * @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
  127919. * @param onCompiled Called when the shader has been compiled.
  127920. * @param onError Called if there is an error when compiling a shader.
  127921. */
  127922. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127923. }
  127924. }
  127925. declare module BABYLON {
  127926. /**
  127927. * Specifies the level of max blur that should be applied when using the depth of field effect
  127928. */
  127929. export enum DepthOfFieldEffectBlurLevel {
  127930. /**
  127931. * Subtle blur
  127932. */
  127933. Low = 0,
  127934. /**
  127935. * Medium blur
  127936. */
  127937. Medium = 1,
  127938. /**
  127939. * Large blur
  127940. */
  127941. High = 2
  127942. }
  127943. /**
  127944. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127945. */
  127946. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127947. private _circleOfConfusion;
  127948. /**
  127949. * @hidden Internal, blurs from high to low
  127950. */
  127951. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127952. private _depthOfFieldBlurY;
  127953. private _dofMerge;
  127954. /**
  127955. * @hidden Internal post processes in depth of field effect
  127956. */
  127957. _effects: Array<PostProcess>;
  127958. /**
  127959. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127960. */
  127961. focalLength: number;
  127962. /**
  127963. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127964. */
  127965. fStop: number;
  127966. /**
  127967. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127968. */
  127969. focusDistance: number;
  127970. /**
  127971. * 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.
  127972. */
  127973. lensSize: number;
  127974. /**
  127975. * Creates a new instance DepthOfFieldEffect
  127976. * @param scene The scene the effect belongs to.
  127977. * @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.
  127978. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127979. * @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)
  127980. */
  127981. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127982. /**
  127983. * Get the current class name of the current effet
  127984. * @returns "DepthOfFieldEffect"
  127985. */
  127986. getClassName(): string;
  127987. /**
  127988. * 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.
  127989. */
  127990. depthTexture: RenderTargetTexture;
  127991. /**
  127992. * Disposes each of the internal effects for a given camera.
  127993. * @param camera The camera to dispose the effect on.
  127994. */
  127995. disposeEffects(camera: Camera): void;
  127996. /**
  127997. * @hidden Internal
  127998. */
  127999. _updateEffects(): void;
  128000. /**
  128001. * Internal
  128002. * @returns if all the contained post processes are ready.
  128003. * @hidden
  128004. */
  128005. _isReady(): boolean;
  128006. }
  128007. }
  128008. declare module BABYLON {
  128009. /** @hidden */
  128010. export var displayPassPixelShader: {
  128011. name: string;
  128012. shader: string;
  128013. };
  128014. }
  128015. declare module BABYLON {
  128016. /**
  128017. * DisplayPassPostProcess which produces an output the same as it's input
  128018. */
  128019. export class DisplayPassPostProcess extends PostProcess {
  128020. /**
  128021. * Creates the DisplayPassPostProcess
  128022. * @param name The name of the effect.
  128023. * @param options The required width/height ratio to downsize to before computing the render pass.
  128024. * @param camera The camera to apply the render pass to.
  128025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128026. * @param engine The engine which the post process will be applied. (default: current engine)
  128027. * @param reusable If the post process can be reused on the same frame. (default: false)
  128028. */
  128029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128030. }
  128031. }
  128032. declare module BABYLON {
  128033. /** @hidden */
  128034. export var filterPixelShader: {
  128035. name: string;
  128036. shader: string;
  128037. };
  128038. }
  128039. declare module BABYLON {
  128040. /**
  128041. * Applies a kernel filter to the image
  128042. */
  128043. export class FilterPostProcess extends PostProcess {
  128044. /** The matrix to be applied to the image */
  128045. kernelMatrix: Matrix;
  128046. /**
  128047. *
  128048. * @param name The name of the effect.
  128049. * @param kernelMatrix The matrix to be applied to the image
  128050. * @param options The required width/height ratio to downsize to before computing the render pass.
  128051. * @param camera The camera to apply the render pass to.
  128052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128053. * @param engine The engine which the post process will be applied. (default: current engine)
  128054. * @param reusable If the post process can be reused on the same frame. (default: false)
  128055. */
  128056. constructor(name: string,
  128057. /** The matrix to be applied to the image */
  128058. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128059. }
  128060. }
  128061. declare module BABYLON {
  128062. /** @hidden */
  128063. export var fxaaPixelShader: {
  128064. name: string;
  128065. shader: string;
  128066. };
  128067. }
  128068. declare module BABYLON {
  128069. /** @hidden */
  128070. export var fxaaVertexShader: {
  128071. name: string;
  128072. shader: string;
  128073. };
  128074. }
  128075. declare module BABYLON {
  128076. /**
  128077. * Fxaa post process
  128078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128079. */
  128080. export class FxaaPostProcess extends PostProcess {
  128081. /** @hidden */
  128082. texelWidth: number;
  128083. /** @hidden */
  128084. texelHeight: number;
  128085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128086. private _getDefines;
  128087. }
  128088. }
  128089. declare module BABYLON {
  128090. /** @hidden */
  128091. export var grainPixelShader: {
  128092. name: string;
  128093. shader: string;
  128094. };
  128095. }
  128096. declare module BABYLON {
  128097. /**
  128098. * The GrainPostProcess adds noise to the image at mid luminance levels
  128099. */
  128100. export class GrainPostProcess extends PostProcess {
  128101. /**
  128102. * The intensity of the grain added (default: 30)
  128103. */
  128104. intensity: number;
  128105. /**
  128106. * If the grain should be randomized on every frame
  128107. */
  128108. animated: boolean;
  128109. /**
  128110. * Creates a new instance of @see GrainPostProcess
  128111. * @param name The name of the effect.
  128112. * @param options The required width/height ratio to downsize to before computing the render pass.
  128113. * @param camera The camera to apply the render pass to.
  128114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128115. * @param engine The engine which the post process will be applied. (default: current engine)
  128116. * @param reusable If the post process can be reused on the same frame. (default: false)
  128117. * @param textureType Type of textures used when performing the post process. (default: 0)
  128118. * @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)
  128119. */
  128120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128121. }
  128122. }
  128123. declare module BABYLON {
  128124. /** @hidden */
  128125. export var highlightsPixelShader: {
  128126. name: string;
  128127. shader: string;
  128128. };
  128129. }
  128130. declare module BABYLON {
  128131. /**
  128132. * Extracts highlights from the image
  128133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128134. */
  128135. export class HighlightsPostProcess extends PostProcess {
  128136. /**
  128137. * Extracts highlights from the image
  128138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128139. * @param name The name of the effect.
  128140. * @param options The required width/height ratio to downsize to before computing the render pass.
  128141. * @param camera The camera to apply the render pass to.
  128142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128143. * @param engine The engine which the post process will be applied. (default: current engine)
  128144. * @param reusable If the post process can be reused on the same frame. (default: false)
  128145. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128146. */
  128147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128148. }
  128149. }
  128150. declare module BABYLON {
  128151. /** @hidden */
  128152. export var mrtFragmentDeclaration: {
  128153. name: string;
  128154. shader: string;
  128155. };
  128156. }
  128157. declare module BABYLON {
  128158. /** @hidden */
  128159. export var geometryPixelShader: {
  128160. name: string;
  128161. shader: string;
  128162. };
  128163. }
  128164. declare module BABYLON {
  128165. /** @hidden */
  128166. export var geometryVertexShader: {
  128167. name: string;
  128168. shader: string;
  128169. };
  128170. }
  128171. declare module BABYLON {
  128172. /** @hidden */
  128173. interface ISavedTransformationMatrix {
  128174. world: Matrix;
  128175. viewProjection: Matrix;
  128176. }
  128177. /**
  128178. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128179. */
  128180. export class GeometryBufferRenderer {
  128181. /**
  128182. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128183. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128184. */
  128185. static readonly POSITION_TEXTURE_TYPE: number;
  128186. /**
  128187. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128188. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128189. */
  128190. static readonly VELOCITY_TEXTURE_TYPE: number;
  128191. /**
  128192. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128193. * in order to compute objects velocities when enableVelocity is set to "true"
  128194. * @hidden
  128195. */
  128196. _previousTransformationMatrices: {
  128197. [index: number]: ISavedTransformationMatrix;
  128198. };
  128199. /**
  128200. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128201. * in order to compute objects velocities when enableVelocity is set to "true"
  128202. * @hidden
  128203. */
  128204. _previousBonesTransformationMatrices: {
  128205. [index: number]: Float32Array;
  128206. };
  128207. /**
  128208. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128209. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128210. */
  128211. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128212. private _scene;
  128213. private _multiRenderTarget;
  128214. private _ratio;
  128215. private _enablePosition;
  128216. private _enableVelocity;
  128217. private _positionIndex;
  128218. private _velocityIndex;
  128219. protected _effect: Effect;
  128220. protected _cachedDefines: string;
  128221. /**
  128222. * Set the render list (meshes to be rendered) used in the G buffer.
  128223. */
  128224. renderList: Mesh[];
  128225. /**
  128226. * Gets wether or not G buffer are supported by the running hardware.
  128227. * This requires draw buffer supports
  128228. */
  128229. readonly isSupported: boolean;
  128230. /**
  128231. * Returns the index of the given texture type in the G-Buffer textures array
  128232. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128233. * @returns the index of the given texture type in the G-Buffer textures array
  128234. */
  128235. getTextureIndex(textureType: number): number;
  128236. /**
  128237. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128238. */
  128239. /**
  128240. * Sets whether or not objects positions are enabled for the G buffer.
  128241. */
  128242. enablePosition: boolean;
  128243. /**
  128244. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128245. */
  128246. /**
  128247. * Sets wether or not objects velocities are enabled for the G buffer.
  128248. */
  128249. enableVelocity: boolean;
  128250. /**
  128251. * Gets the scene associated with the buffer.
  128252. */
  128253. readonly scene: Scene;
  128254. /**
  128255. * Gets the ratio used by the buffer during its creation.
  128256. * How big is the buffer related to the main canvas.
  128257. */
  128258. readonly ratio: number;
  128259. /** @hidden */
  128260. static _SceneComponentInitialization: (scene: Scene) => void;
  128261. /**
  128262. * Creates a new G Buffer for the scene
  128263. * @param scene The scene the buffer belongs to
  128264. * @param ratio How big is the buffer related to the main canvas.
  128265. */
  128266. constructor(scene: Scene, ratio?: number);
  128267. /**
  128268. * Checks wether everything is ready to render a submesh to the G buffer.
  128269. * @param subMesh the submesh to check readiness for
  128270. * @param useInstances is the mesh drawn using instance or not
  128271. * @returns true if ready otherwise false
  128272. */
  128273. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128274. /**
  128275. * Gets the current underlying G Buffer.
  128276. * @returns the buffer
  128277. */
  128278. getGBuffer(): MultiRenderTarget;
  128279. /**
  128280. * Gets the number of samples used to render the buffer (anti aliasing).
  128281. */
  128282. /**
  128283. * Sets the number of samples used to render the buffer (anti aliasing).
  128284. */
  128285. samples: number;
  128286. /**
  128287. * Disposes the renderer and frees up associated resources.
  128288. */
  128289. dispose(): void;
  128290. protected _createRenderTargets(): void;
  128291. private _copyBonesTransformationMatrices;
  128292. }
  128293. }
  128294. declare module BABYLON {
  128295. interface Scene {
  128296. /** @hidden (Backing field) */
  128297. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128298. /**
  128299. * Gets or Sets the current geometry buffer associated to the scene.
  128300. */
  128301. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128302. /**
  128303. * Enables a GeometryBufferRender and associates it with the scene
  128304. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128305. * @returns the GeometryBufferRenderer
  128306. */
  128307. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128308. /**
  128309. * Disables the GeometryBufferRender associated with the scene
  128310. */
  128311. disableGeometryBufferRenderer(): void;
  128312. }
  128313. /**
  128314. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128315. * in several rendering techniques.
  128316. */
  128317. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128318. /**
  128319. * The component name helpful to identify the component in the list of scene components.
  128320. */
  128321. readonly name: string;
  128322. /**
  128323. * The scene the component belongs to.
  128324. */
  128325. scene: Scene;
  128326. /**
  128327. * Creates a new instance of the component for the given scene
  128328. * @param scene Defines the scene to register the component in
  128329. */
  128330. constructor(scene: Scene);
  128331. /**
  128332. * Registers the component in a given scene
  128333. */
  128334. register(): void;
  128335. /**
  128336. * Rebuilds the elements related to this component in case of
  128337. * context lost for instance.
  128338. */
  128339. rebuild(): void;
  128340. /**
  128341. * Disposes the component and the associated ressources
  128342. */
  128343. dispose(): void;
  128344. private _gatherRenderTargets;
  128345. }
  128346. }
  128347. declare module BABYLON {
  128348. /** @hidden */
  128349. export var motionBlurPixelShader: {
  128350. name: string;
  128351. shader: string;
  128352. };
  128353. }
  128354. declare module BABYLON {
  128355. /**
  128356. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128357. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128358. * As an example, all you have to do is to create the post-process:
  128359. * var mb = new BABYLON.MotionBlurPostProcess(
  128360. * 'mb', // The name of the effect.
  128361. * scene, // The scene containing the objects to blur according to their velocity.
  128362. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128363. * camera // The camera to apply the render pass to.
  128364. * );
  128365. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128366. */
  128367. export class MotionBlurPostProcess extends PostProcess {
  128368. /**
  128369. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128370. */
  128371. motionStrength: number;
  128372. /**
  128373. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128374. */
  128375. /**
  128376. * Sets the number of iterations to be used for motion blur quality
  128377. */
  128378. motionBlurSamples: number;
  128379. private _motionBlurSamples;
  128380. private _geometryBufferRenderer;
  128381. /**
  128382. * Creates a new instance MotionBlurPostProcess
  128383. * @param name The name of the effect.
  128384. * @param scene The scene containing the objects to blur according to their velocity.
  128385. * @param options The required width/height ratio to downsize to before computing the render pass.
  128386. * @param camera The camera to apply the render pass to.
  128387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128388. * @param engine The engine which the post process will be applied. (default: current engine)
  128389. * @param reusable If the post process can be reused on the same frame. (default: false)
  128390. * @param textureType Type of textures used when performing the post process. (default: 0)
  128391. * @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)
  128392. */
  128393. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128394. /**
  128395. * Excludes the given skinned mesh from computing bones velocities.
  128396. * 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.
  128397. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128398. */
  128399. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128400. /**
  128401. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128402. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128403. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128404. */
  128405. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128406. /**
  128407. * Disposes the post process.
  128408. * @param camera The camera to dispose the post process on.
  128409. */
  128410. dispose(camera?: Camera): void;
  128411. }
  128412. }
  128413. declare module BABYLON {
  128414. /** @hidden */
  128415. export var refractionPixelShader: {
  128416. name: string;
  128417. shader: string;
  128418. };
  128419. }
  128420. declare module BABYLON {
  128421. /**
  128422. * Post process which applies a refractin texture
  128423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128424. */
  128425. export class RefractionPostProcess extends PostProcess {
  128426. /** the base color of the refraction (used to taint the rendering) */
  128427. color: Color3;
  128428. /** simulated refraction depth */
  128429. depth: number;
  128430. /** the coefficient of the base color (0 to remove base color tainting) */
  128431. colorLevel: number;
  128432. private _refTexture;
  128433. private _ownRefractionTexture;
  128434. /**
  128435. * Gets or sets the refraction texture
  128436. * Please note that you are responsible for disposing the texture if you set it manually
  128437. */
  128438. refractionTexture: Texture;
  128439. /**
  128440. * Initializes the RefractionPostProcess
  128441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128442. * @param name The name of the effect.
  128443. * @param refractionTextureUrl Url of the refraction texture to use
  128444. * @param color the base color of the refraction (used to taint the rendering)
  128445. * @param depth simulated refraction depth
  128446. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128447. * @param camera The camera to apply the render pass to.
  128448. * @param options The required width/height ratio to downsize to before computing the render pass.
  128449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128450. * @param engine The engine which the post process will be applied. (default: current engine)
  128451. * @param reusable If the post process can be reused on the same frame. (default: false)
  128452. */
  128453. constructor(name: string, refractionTextureUrl: string,
  128454. /** the base color of the refraction (used to taint the rendering) */
  128455. color: Color3,
  128456. /** simulated refraction depth */
  128457. depth: number,
  128458. /** the coefficient of the base color (0 to remove base color tainting) */
  128459. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128460. /**
  128461. * Disposes of the post process
  128462. * @param camera Camera to dispose post process on
  128463. */
  128464. dispose(camera: Camera): void;
  128465. }
  128466. }
  128467. declare module BABYLON {
  128468. /** @hidden */
  128469. export var sharpenPixelShader: {
  128470. name: string;
  128471. shader: string;
  128472. };
  128473. }
  128474. declare module BABYLON {
  128475. /**
  128476. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128477. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128478. */
  128479. export class SharpenPostProcess extends PostProcess {
  128480. /**
  128481. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128482. */
  128483. colorAmount: number;
  128484. /**
  128485. * How much sharpness should be applied (default: 0.3)
  128486. */
  128487. edgeAmount: number;
  128488. /**
  128489. * Creates a new instance ConvolutionPostProcess
  128490. * @param name The name of the effect.
  128491. * @param options The required width/height ratio to downsize to before computing the render pass.
  128492. * @param camera The camera to apply the render pass to.
  128493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128494. * @param engine The engine which the post process will be applied. (default: current engine)
  128495. * @param reusable If the post process can be reused on the same frame. (default: false)
  128496. * @param textureType Type of textures used when performing the post process. (default: 0)
  128497. * @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)
  128498. */
  128499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128500. }
  128501. }
  128502. declare module BABYLON {
  128503. /**
  128504. * PostProcessRenderPipeline
  128505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128506. */
  128507. export class PostProcessRenderPipeline {
  128508. private engine;
  128509. private _renderEffects;
  128510. private _renderEffectsForIsolatedPass;
  128511. /**
  128512. * List of inspectable custom properties (used by the Inspector)
  128513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  128514. */
  128515. inspectableCustomProperties: IInspectable[];
  128516. /**
  128517. * @hidden
  128518. */
  128519. protected _cameras: Camera[];
  128520. /** @hidden */
  128521. _name: string;
  128522. /**
  128523. * Gets pipeline name
  128524. */
  128525. readonly name: string;
  128526. /** Gets the list of attached cameras */
  128527. readonly cameras: Camera[];
  128528. /**
  128529. * Initializes a PostProcessRenderPipeline
  128530. * @param engine engine to add the pipeline to
  128531. * @param name name of the pipeline
  128532. */
  128533. constructor(engine: Engine, name: string);
  128534. /**
  128535. * Gets the class name
  128536. * @returns "PostProcessRenderPipeline"
  128537. */
  128538. getClassName(): string;
  128539. /**
  128540. * If all the render effects in the pipeline are supported
  128541. */
  128542. readonly isSupported: boolean;
  128543. /**
  128544. * Adds an effect to the pipeline
  128545. * @param renderEffect the effect to add
  128546. */
  128547. addEffect(renderEffect: PostProcessRenderEffect): void;
  128548. /** @hidden */
  128549. _rebuild(): void;
  128550. /** @hidden */
  128551. _enableEffect(renderEffectName: string, cameras: Camera): void;
  128552. /** @hidden */
  128553. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  128554. /** @hidden */
  128555. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128556. /** @hidden */
  128557. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128558. /** @hidden */
  128559. _attachCameras(cameras: Camera, unique: boolean): void;
  128560. /** @hidden */
  128561. _attachCameras(cameras: Camera[], unique: boolean): void;
  128562. /** @hidden */
  128563. _detachCameras(cameras: Camera): void;
  128564. /** @hidden */
  128565. _detachCameras(cameras: Nullable<Camera[]>): void;
  128566. /** @hidden */
  128567. _update(): void;
  128568. /** @hidden */
  128569. _reset(): void;
  128570. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  128571. /**
  128572. * Disposes of the pipeline
  128573. */
  128574. dispose(): void;
  128575. }
  128576. }
  128577. declare module BABYLON {
  128578. /**
  128579. * PostProcessRenderPipelineManager class
  128580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128581. */
  128582. export class PostProcessRenderPipelineManager {
  128583. private _renderPipelines;
  128584. /**
  128585. * Initializes a PostProcessRenderPipelineManager
  128586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128587. */
  128588. constructor();
  128589. /**
  128590. * Gets the list of supported render pipelines
  128591. */
  128592. readonly supportedPipelines: PostProcessRenderPipeline[];
  128593. /**
  128594. * Adds a pipeline to the manager
  128595. * @param renderPipeline The pipeline to add
  128596. */
  128597. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  128598. /**
  128599. * Attaches a camera to the pipeline
  128600. * @param renderPipelineName The name of the pipeline to attach to
  128601. * @param cameras the camera to attach
  128602. * @param unique if the camera can be attached multiple times to the pipeline
  128603. */
  128604. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  128605. /**
  128606. * Detaches a camera from the pipeline
  128607. * @param renderPipelineName The name of the pipeline to detach from
  128608. * @param cameras the camera to detach
  128609. */
  128610. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  128611. /**
  128612. * Enables an effect by name on a pipeline
  128613. * @param renderPipelineName the name of the pipeline to enable the effect in
  128614. * @param renderEffectName the name of the effect to enable
  128615. * @param cameras the cameras that the effect should be enabled on
  128616. */
  128617. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128618. /**
  128619. * Disables an effect by name on a pipeline
  128620. * @param renderPipelineName the name of the pipeline to disable the effect in
  128621. * @param renderEffectName the name of the effect to disable
  128622. * @param cameras the cameras that the effect should be disabled on
  128623. */
  128624. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128625. /**
  128626. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  128627. */
  128628. update(): void;
  128629. /** @hidden */
  128630. _rebuild(): void;
  128631. /**
  128632. * Disposes of the manager and pipelines
  128633. */
  128634. dispose(): void;
  128635. }
  128636. }
  128637. declare module BABYLON {
  128638. interface Scene {
  128639. /** @hidden (Backing field) */
  128640. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128641. /**
  128642. * Gets the postprocess render pipeline manager
  128643. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128644. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128645. */
  128646. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128647. }
  128648. /**
  128649. * Defines the Render Pipeline scene component responsible to rendering pipelines
  128650. */
  128651. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  128652. /**
  128653. * The component name helpfull to identify the component in the list of scene components.
  128654. */
  128655. readonly name: string;
  128656. /**
  128657. * The scene the component belongs to.
  128658. */
  128659. scene: Scene;
  128660. /**
  128661. * Creates a new instance of the component for the given scene
  128662. * @param scene Defines the scene to register the component in
  128663. */
  128664. constructor(scene: Scene);
  128665. /**
  128666. * Registers the component in a given scene
  128667. */
  128668. register(): void;
  128669. /**
  128670. * Rebuilds the elements related to this component in case of
  128671. * context lost for instance.
  128672. */
  128673. rebuild(): void;
  128674. /**
  128675. * Disposes the component and the associated ressources
  128676. */
  128677. dispose(): void;
  128678. private _gatherRenderTargets;
  128679. }
  128680. }
  128681. declare module BABYLON {
  128682. /**
  128683. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128684. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128685. */
  128686. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128687. private _scene;
  128688. private _camerasToBeAttached;
  128689. /**
  128690. * ID of the sharpen post process,
  128691. */
  128692. private readonly SharpenPostProcessId;
  128693. /**
  128694. * @ignore
  128695. * ID of the image processing post process;
  128696. */
  128697. readonly ImageProcessingPostProcessId: string;
  128698. /**
  128699. * @ignore
  128700. * ID of the Fast Approximate Anti-Aliasing post process;
  128701. */
  128702. readonly FxaaPostProcessId: string;
  128703. /**
  128704. * ID of the chromatic aberration post process,
  128705. */
  128706. private readonly ChromaticAberrationPostProcessId;
  128707. /**
  128708. * ID of the grain post process
  128709. */
  128710. private readonly GrainPostProcessId;
  128711. /**
  128712. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128713. */
  128714. sharpen: SharpenPostProcess;
  128715. private _sharpenEffect;
  128716. private bloom;
  128717. /**
  128718. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128719. */
  128720. depthOfField: DepthOfFieldEffect;
  128721. /**
  128722. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128723. */
  128724. fxaa: FxaaPostProcess;
  128725. /**
  128726. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128727. */
  128728. imageProcessing: ImageProcessingPostProcess;
  128729. /**
  128730. * Chromatic aberration post process which will shift rgb colors in the image
  128731. */
  128732. chromaticAberration: ChromaticAberrationPostProcess;
  128733. private _chromaticAberrationEffect;
  128734. /**
  128735. * Grain post process which add noise to the image
  128736. */
  128737. grain: GrainPostProcess;
  128738. private _grainEffect;
  128739. /**
  128740. * Glow post process which adds a glow to emissive areas of the image
  128741. */
  128742. private _glowLayer;
  128743. /**
  128744. * Animations which can be used to tweak settings over a period of time
  128745. */
  128746. animations: Animation[];
  128747. private _imageProcessingConfigurationObserver;
  128748. private _sharpenEnabled;
  128749. private _bloomEnabled;
  128750. private _depthOfFieldEnabled;
  128751. private _depthOfFieldBlurLevel;
  128752. private _fxaaEnabled;
  128753. private _imageProcessingEnabled;
  128754. private _defaultPipelineTextureType;
  128755. private _bloomScale;
  128756. private _chromaticAberrationEnabled;
  128757. private _grainEnabled;
  128758. private _buildAllowed;
  128759. /**
  128760. * Gets active scene
  128761. */
  128762. readonly scene: Scene;
  128763. /**
  128764. * Enable or disable the sharpen process from the pipeline
  128765. */
  128766. sharpenEnabled: boolean;
  128767. private _resizeObserver;
  128768. private _hardwareScaleLevel;
  128769. private _bloomKernel;
  128770. /**
  128771. * Specifies the size of the bloom blur kernel, relative to the final output size
  128772. */
  128773. bloomKernel: number;
  128774. /**
  128775. * Specifies the weight of the bloom in the final rendering
  128776. */
  128777. private _bloomWeight;
  128778. /**
  128779. * Specifies the luma threshold for the area that will be blurred by the bloom
  128780. */
  128781. private _bloomThreshold;
  128782. private _hdr;
  128783. /**
  128784. * The strength of the bloom.
  128785. */
  128786. bloomWeight: number;
  128787. /**
  128788. * The strength of the bloom.
  128789. */
  128790. bloomThreshold: number;
  128791. /**
  128792. * The scale of the bloom, lower value will provide better performance.
  128793. */
  128794. bloomScale: number;
  128795. /**
  128796. * Enable or disable the bloom from the pipeline
  128797. */
  128798. bloomEnabled: boolean;
  128799. private _rebuildBloom;
  128800. /**
  128801. * If the depth of field is enabled.
  128802. */
  128803. depthOfFieldEnabled: boolean;
  128804. /**
  128805. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128806. */
  128807. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128808. /**
  128809. * If the anti aliasing is enabled.
  128810. */
  128811. fxaaEnabled: boolean;
  128812. private _samples;
  128813. /**
  128814. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128815. */
  128816. samples: number;
  128817. /**
  128818. * If image processing is enabled.
  128819. */
  128820. imageProcessingEnabled: boolean;
  128821. /**
  128822. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128823. */
  128824. glowLayerEnabled: boolean;
  128825. /**
  128826. * Gets the glow layer (or null if not defined)
  128827. */
  128828. readonly glowLayer: Nullable<GlowLayer>;
  128829. /**
  128830. * Enable or disable the chromaticAberration process from the pipeline
  128831. */
  128832. chromaticAberrationEnabled: boolean;
  128833. /**
  128834. * Enable or disable the grain process from the pipeline
  128835. */
  128836. grainEnabled: boolean;
  128837. /**
  128838. * @constructor
  128839. * @param name - The rendering pipeline name (default: "")
  128840. * @param hdr - If high dynamic range textures should be used (default: true)
  128841. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128842. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128843. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128844. */
  128845. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128846. /**
  128847. * Get the class name
  128848. * @returns "DefaultRenderingPipeline"
  128849. */
  128850. getClassName(): string;
  128851. /**
  128852. * Force the compilation of the entire pipeline.
  128853. */
  128854. prepare(): void;
  128855. private _hasCleared;
  128856. private _prevPostProcess;
  128857. private _prevPrevPostProcess;
  128858. private _setAutoClearAndTextureSharing;
  128859. private _depthOfFieldSceneObserver;
  128860. private _buildPipeline;
  128861. private _disposePostProcesses;
  128862. /**
  128863. * Adds a camera to the pipeline
  128864. * @param camera the camera to be added
  128865. */
  128866. addCamera(camera: Camera): void;
  128867. /**
  128868. * Removes a camera from the pipeline
  128869. * @param camera the camera to remove
  128870. */
  128871. removeCamera(camera: Camera): void;
  128872. /**
  128873. * Dispose of the pipeline and stop all post processes
  128874. */
  128875. dispose(): void;
  128876. /**
  128877. * Serialize the rendering pipeline (Used when exporting)
  128878. * @returns the serialized object
  128879. */
  128880. serialize(): any;
  128881. /**
  128882. * Parse the serialized pipeline
  128883. * @param source Source pipeline.
  128884. * @param scene The scene to load the pipeline to.
  128885. * @param rootUrl The URL of the serialized pipeline.
  128886. * @returns An instantiated pipeline from the serialized object.
  128887. */
  128888. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128889. }
  128890. }
  128891. declare module BABYLON {
  128892. /** @hidden */
  128893. export var lensHighlightsPixelShader: {
  128894. name: string;
  128895. shader: string;
  128896. };
  128897. }
  128898. declare module BABYLON {
  128899. /** @hidden */
  128900. export var depthOfFieldPixelShader: {
  128901. name: string;
  128902. shader: string;
  128903. };
  128904. }
  128905. declare module BABYLON {
  128906. /**
  128907. * BABYLON.JS Chromatic Aberration GLSL Shader
  128908. * Author: Olivier Guyot
  128909. * Separates very slightly R, G and B colors on the edges of the screen
  128910. * Inspired by Francois Tarlier & Martins Upitis
  128911. */
  128912. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128913. /**
  128914. * @ignore
  128915. * The chromatic aberration PostProcess id in the pipeline
  128916. */
  128917. LensChromaticAberrationEffect: string;
  128918. /**
  128919. * @ignore
  128920. * The highlights enhancing PostProcess id in the pipeline
  128921. */
  128922. HighlightsEnhancingEffect: string;
  128923. /**
  128924. * @ignore
  128925. * The depth-of-field PostProcess id in the pipeline
  128926. */
  128927. LensDepthOfFieldEffect: string;
  128928. private _scene;
  128929. private _depthTexture;
  128930. private _grainTexture;
  128931. private _chromaticAberrationPostProcess;
  128932. private _highlightsPostProcess;
  128933. private _depthOfFieldPostProcess;
  128934. private _edgeBlur;
  128935. private _grainAmount;
  128936. private _chromaticAberration;
  128937. private _distortion;
  128938. private _highlightsGain;
  128939. private _highlightsThreshold;
  128940. private _dofDistance;
  128941. private _dofAperture;
  128942. private _dofDarken;
  128943. private _dofPentagon;
  128944. private _blurNoise;
  128945. /**
  128946. * @constructor
  128947. *
  128948. * Effect parameters are as follow:
  128949. * {
  128950. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128951. * edge_blur: number; // from 0 to x (1 for realism)
  128952. * distortion: number; // from 0 to x (1 for realism)
  128953. * grain_amount: number; // from 0 to 1
  128954. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128955. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128956. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128957. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128958. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128959. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128960. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128961. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128962. * }
  128963. * Note: if an effect parameter is unset, effect is disabled
  128964. *
  128965. * @param name The rendering pipeline name
  128966. * @param parameters - An object containing all parameters (see above)
  128967. * @param scene The scene linked to this pipeline
  128968. * @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)
  128969. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128970. */
  128971. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128972. /**
  128973. * Get the class name
  128974. * @returns "LensRenderingPipeline"
  128975. */
  128976. getClassName(): string;
  128977. /**
  128978. * Gets associated scene
  128979. */
  128980. readonly scene: Scene;
  128981. /**
  128982. * Gets or sets the edge blur
  128983. */
  128984. edgeBlur: number;
  128985. /**
  128986. * Gets or sets the grain amount
  128987. */
  128988. grainAmount: number;
  128989. /**
  128990. * Gets or sets the chromatic aberration amount
  128991. */
  128992. chromaticAberration: number;
  128993. /**
  128994. * Gets or sets the depth of field aperture
  128995. */
  128996. dofAperture: number;
  128997. /**
  128998. * Gets or sets the edge distortion
  128999. */
  129000. edgeDistortion: number;
  129001. /**
  129002. * Gets or sets the depth of field distortion
  129003. */
  129004. dofDistortion: number;
  129005. /**
  129006. * Gets or sets the darken out of focus amount
  129007. */
  129008. darkenOutOfFocus: number;
  129009. /**
  129010. * Gets or sets a boolean indicating if blur noise is enabled
  129011. */
  129012. blurNoise: boolean;
  129013. /**
  129014. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129015. */
  129016. pentagonBokeh: boolean;
  129017. /**
  129018. * Gets or sets the highlight grain amount
  129019. */
  129020. highlightsGain: number;
  129021. /**
  129022. * Gets or sets the highlight threshold
  129023. */
  129024. highlightsThreshold: number;
  129025. /**
  129026. * Sets the amount of blur at the edges
  129027. * @param amount blur amount
  129028. */
  129029. setEdgeBlur(amount: number): void;
  129030. /**
  129031. * Sets edge blur to 0
  129032. */
  129033. disableEdgeBlur(): void;
  129034. /**
  129035. * Sets the amout of grain
  129036. * @param amount Amount of grain
  129037. */
  129038. setGrainAmount(amount: number): void;
  129039. /**
  129040. * Set grain amount to 0
  129041. */
  129042. disableGrain(): void;
  129043. /**
  129044. * Sets the chromatic aberration amount
  129045. * @param amount amount of chromatic aberration
  129046. */
  129047. setChromaticAberration(amount: number): void;
  129048. /**
  129049. * Sets chromatic aberration amount to 0
  129050. */
  129051. disableChromaticAberration(): void;
  129052. /**
  129053. * Sets the EdgeDistortion amount
  129054. * @param amount amount of EdgeDistortion
  129055. */
  129056. setEdgeDistortion(amount: number): void;
  129057. /**
  129058. * Sets edge distortion to 0
  129059. */
  129060. disableEdgeDistortion(): void;
  129061. /**
  129062. * Sets the FocusDistance amount
  129063. * @param amount amount of FocusDistance
  129064. */
  129065. setFocusDistance(amount: number): void;
  129066. /**
  129067. * Disables depth of field
  129068. */
  129069. disableDepthOfField(): void;
  129070. /**
  129071. * Sets the Aperture amount
  129072. * @param amount amount of Aperture
  129073. */
  129074. setAperture(amount: number): void;
  129075. /**
  129076. * Sets the DarkenOutOfFocus amount
  129077. * @param amount amount of DarkenOutOfFocus
  129078. */
  129079. setDarkenOutOfFocus(amount: number): void;
  129080. private _pentagonBokehIsEnabled;
  129081. /**
  129082. * Creates a pentagon bokeh effect
  129083. */
  129084. enablePentagonBokeh(): void;
  129085. /**
  129086. * Disables the pentagon bokeh effect
  129087. */
  129088. disablePentagonBokeh(): void;
  129089. /**
  129090. * Enables noise blur
  129091. */
  129092. enableNoiseBlur(): void;
  129093. /**
  129094. * Disables noise blur
  129095. */
  129096. disableNoiseBlur(): void;
  129097. /**
  129098. * Sets the HighlightsGain amount
  129099. * @param amount amount of HighlightsGain
  129100. */
  129101. setHighlightsGain(amount: number): void;
  129102. /**
  129103. * Sets the HighlightsThreshold amount
  129104. * @param amount amount of HighlightsThreshold
  129105. */
  129106. setHighlightsThreshold(amount: number): void;
  129107. /**
  129108. * Disables highlights
  129109. */
  129110. disableHighlights(): void;
  129111. /**
  129112. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129113. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129114. */
  129115. dispose(disableDepthRender?: boolean): void;
  129116. private _createChromaticAberrationPostProcess;
  129117. private _createHighlightsPostProcess;
  129118. private _createDepthOfFieldPostProcess;
  129119. private _createGrainTexture;
  129120. }
  129121. }
  129122. declare module BABYLON {
  129123. /** @hidden */
  129124. export var ssao2PixelShader: {
  129125. name: string;
  129126. shader: string;
  129127. };
  129128. }
  129129. declare module BABYLON {
  129130. /** @hidden */
  129131. export var ssaoCombinePixelShader: {
  129132. name: string;
  129133. shader: string;
  129134. };
  129135. }
  129136. declare module BABYLON {
  129137. /**
  129138. * Render pipeline to produce ssao effect
  129139. */
  129140. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129141. /**
  129142. * @ignore
  129143. * The PassPostProcess id in the pipeline that contains the original scene color
  129144. */
  129145. SSAOOriginalSceneColorEffect: string;
  129146. /**
  129147. * @ignore
  129148. * The SSAO PostProcess id in the pipeline
  129149. */
  129150. SSAORenderEffect: string;
  129151. /**
  129152. * @ignore
  129153. * The horizontal blur PostProcess id in the pipeline
  129154. */
  129155. SSAOBlurHRenderEffect: string;
  129156. /**
  129157. * @ignore
  129158. * The vertical blur PostProcess id in the pipeline
  129159. */
  129160. SSAOBlurVRenderEffect: string;
  129161. /**
  129162. * @ignore
  129163. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129164. */
  129165. SSAOCombineRenderEffect: string;
  129166. /**
  129167. * The output strength of the SSAO post-process. Default value is 1.0.
  129168. */
  129169. totalStrength: number;
  129170. /**
  129171. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129172. */
  129173. maxZ: number;
  129174. /**
  129175. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129176. */
  129177. minZAspect: number;
  129178. private _samples;
  129179. /**
  129180. * Number of samples used for the SSAO calculations. Default value is 8
  129181. */
  129182. samples: number;
  129183. private _textureSamples;
  129184. /**
  129185. * Number of samples to use for antialiasing
  129186. */
  129187. textureSamples: number;
  129188. /**
  129189. * Ratio object used for SSAO ratio and blur ratio
  129190. */
  129191. private _ratio;
  129192. /**
  129193. * Dynamically generated sphere sampler.
  129194. */
  129195. private _sampleSphere;
  129196. /**
  129197. * Blur filter offsets
  129198. */
  129199. private _samplerOffsets;
  129200. private _expensiveBlur;
  129201. /**
  129202. * If bilateral blur should be used
  129203. */
  129204. expensiveBlur: boolean;
  129205. /**
  129206. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129207. */
  129208. radius: number;
  129209. /**
  129210. * The base color of the SSAO post-process
  129211. * The final result is "base + ssao" between [0, 1]
  129212. */
  129213. base: number;
  129214. /**
  129215. * Support test.
  129216. */
  129217. static readonly IsSupported: boolean;
  129218. private _scene;
  129219. private _depthTexture;
  129220. private _normalTexture;
  129221. private _randomTexture;
  129222. private _originalColorPostProcess;
  129223. private _ssaoPostProcess;
  129224. private _blurHPostProcess;
  129225. private _blurVPostProcess;
  129226. private _ssaoCombinePostProcess;
  129227. private _firstUpdate;
  129228. /**
  129229. * Gets active scene
  129230. */
  129231. readonly scene: Scene;
  129232. /**
  129233. * @constructor
  129234. * @param name The rendering pipeline name
  129235. * @param scene The scene linked to this pipeline
  129236. * @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 }
  129237. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129238. */
  129239. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129240. /**
  129241. * Get the class name
  129242. * @returns "SSAO2RenderingPipeline"
  129243. */
  129244. getClassName(): string;
  129245. /**
  129246. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129247. */
  129248. dispose(disableGeometryBufferRenderer?: boolean): void;
  129249. private _createBlurPostProcess;
  129250. /** @hidden */
  129251. _rebuild(): void;
  129252. private _bits;
  129253. private _radicalInverse_VdC;
  129254. private _hammersley;
  129255. private _hemisphereSample_uniform;
  129256. private _generateHemisphere;
  129257. private _createSSAOPostProcess;
  129258. private _createSSAOCombinePostProcess;
  129259. private _createRandomTexture;
  129260. /**
  129261. * Serialize the rendering pipeline (Used when exporting)
  129262. * @returns the serialized object
  129263. */
  129264. serialize(): any;
  129265. /**
  129266. * Parse the serialized pipeline
  129267. * @param source Source pipeline.
  129268. * @param scene The scene to load the pipeline to.
  129269. * @param rootUrl The URL of the serialized pipeline.
  129270. * @returns An instantiated pipeline from the serialized object.
  129271. */
  129272. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129273. }
  129274. }
  129275. declare module BABYLON {
  129276. /** @hidden */
  129277. export var ssaoPixelShader: {
  129278. name: string;
  129279. shader: string;
  129280. };
  129281. }
  129282. declare module BABYLON {
  129283. /**
  129284. * Render pipeline to produce ssao effect
  129285. */
  129286. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129287. /**
  129288. * @ignore
  129289. * The PassPostProcess id in the pipeline that contains the original scene color
  129290. */
  129291. SSAOOriginalSceneColorEffect: string;
  129292. /**
  129293. * @ignore
  129294. * The SSAO PostProcess id in the pipeline
  129295. */
  129296. SSAORenderEffect: string;
  129297. /**
  129298. * @ignore
  129299. * The horizontal blur PostProcess id in the pipeline
  129300. */
  129301. SSAOBlurHRenderEffect: string;
  129302. /**
  129303. * @ignore
  129304. * The vertical blur PostProcess id in the pipeline
  129305. */
  129306. SSAOBlurVRenderEffect: string;
  129307. /**
  129308. * @ignore
  129309. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129310. */
  129311. SSAOCombineRenderEffect: string;
  129312. /**
  129313. * The output strength of the SSAO post-process. Default value is 1.0.
  129314. */
  129315. totalStrength: number;
  129316. /**
  129317. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129318. */
  129319. radius: number;
  129320. /**
  129321. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129322. * Must not be equal to fallOff and superior to fallOff.
  129323. * Default value is 0.0075
  129324. */
  129325. area: number;
  129326. /**
  129327. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129328. * Must not be equal to area and inferior to area.
  129329. * Default value is 0.000001
  129330. */
  129331. fallOff: number;
  129332. /**
  129333. * The base color of the SSAO post-process
  129334. * The final result is "base + ssao" between [0, 1]
  129335. */
  129336. base: number;
  129337. private _scene;
  129338. private _depthTexture;
  129339. private _randomTexture;
  129340. private _originalColorPostProcess;
  129341. private _ssaoPostProcess;
  129342. private _blurHPostProcess;
  129343. private _blurVPostProcess;
  129344. private _ssaoCombinePostProcess;
  129345. private _firstUpdate;
  129346. /**
  129347. * Gets active scene
  129348. */
  129349. readonly scene: Scene;
  129350. /**
  129351. * @constructor
  129352. * @param name - The rendering pipeline name
  129353. * @param scene - The scene linked to this pipeline
  129354. * @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 }
  129355. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129356. */
  129357. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129358. /**
  129359. * Get the class name
  129360. * @returns "SSAORenderingPipeline"
  129361. */
  129362. getClassName(): string;
  129363. /**
  129364. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129365. */
  129366. dispose(disableDepthRender?: boolean): void;
  129367. private _createBlurPostProcess;
  129368. /** @hidden */
  129369. _rebuild(): void;
  129370. private _createSSAOPostProcess;
  129371. private _createSSAOCombinePostProcess;
  129372. private _createRandomTexture;
  129373. }
  129374. }
  129375. declare module BABYLON {
  129376. /** @hidden */
  129377. export var standardPixelShader: {
  129378. name: string;
  129379. shader: string;
  129380. };
  129381. }
  129382. declare module BABYLON {
  129383. /**
  129384. * Standard rendering pipeline
  129385. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129386. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129387. */
  129388. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129389. /**
  129390. * Public members
  129391. */
  129392. /**
  129393. * Post-process which contains the original scene color before the pipeline applies all the effects
  129394. */
  129395. originalPostProcess: Nullable<PostProcess>;
  129396. /**
  129397. * Post-process used to down scale an image x4
  129398. */
  129399. downSampleX4PostProcess: Nullable<PostProcess>;
  129400. /**
  129401. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129402. */
  129403. brightPassPostProcess: Nullable<PostProcess>;
  129404. /**
  129405. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129406. */
  129407. blurHPostProcesses: PostProcess[];
  129408. /**
  129409. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129410. */
  129411. blurVPostProcesses: PostProcess[];
  129412. /**
  129413. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129414. */
  129415. textureAdderPostProcess: Nullable<PostProcess>;
  129416. /**
  129417. * Post-process used to create volumetric lighting effect
  129418. */
  129419. volumetricLightPostProcess: Nullable<PostProcess>;
  129420. /**
  129421. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129422. */
  129423. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129424. /**
  129425. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129426. */
  129427. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129428. /**
  129429. * Post-process used to merge the volumetric light effect and the real scene color
  129430. */
  129431. volumetricLightMergePostProces: Nullable<PostProcess>;
  129432. /**
  129433. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129434. */
  129435. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129436. /**
  129437. * Base post-process used to calculate the average luminance of the final image for HDR
  129438. */
  129439. luminancePostProcess: Nullable<PostProcess>;
  129440. /**
  129441. * Post-processes used to create down sample post-processes in order to get
  129442. * the average luminance of the final image for HDR
  129443. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129444. */
  129445. luminanceDownSamplePostProcesses: PostProcess[];
  129446. /**
  129447. * Post-process used to create a HDR effect (light adaptation)
  129448. */
  129449. hdrPostProcess: Nullable<PostProcess>;
  129450. /**
  129451. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129452. */
  129453. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129454. /**
  129455. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129456. */
  129457. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129458. /**
  129459. * Post-process used to merge the final HDR post-process and the real scene color
  129460. */
  129461. hdrFinalPostProcess: Nullable<PostProcess>;
  129462. /**
  129463. * Post-process used to create a lens flare effect
  129464. */
  129465. lensFlarePostProcess: Nullable<PostProcess>;
  129466. /**
  129467. * Post-process that merges the result of the lens flare post-process and the real scene color
  129468. */
  129469. lensFlareComposePostProcess: Nullable<PostProcess>;
  129470. /**
  129471. * Post-process used to create a motion blur effect
  129472. */
  129473. motionBlurPostProcess: Nullable<PostProcess>;
  129474. /**
  129475. * Post-process used to create a depth of field effect
  129476. */
  129477. depthOfFieldPostProcess: Nullable<PostProcess>;
  129478. /**
  129479. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129480. */
  129481. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129482. /**
  129483. * Represents the brightness threshold in order to configure the illuminated surfaces
  129484. */
  129485. brightThreshold: number;
  129486. /**
  129487. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129488. */
  129489. blurWidth: number;
  129490. /**
  129491. * Sets if the blur for highlighted surfaces must be only horizontal
  129492. */
  129493. horizontalBlur: boolean;
  129494. /**
  129495. * Gets the overall exposure used by the pipeline
  129496. */
  129497. /**
  129498. * Sets the overall exposure used by the pipeline
  129499. */
  129500. exposure: number;
  129501. /**
  129502. * Texture used typically to simulate "dirty" on camera lens
  129503. */
  129504. lensTexture: Nullable<Texture>;
  129505. /**
  129506. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  129507. */
  129508. volumetricLightCoefficient: number;
  129509. /**
  129510. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  129511. */
  129512. volumetricLightPower: number;
  129513. /**
  129514. * Used the set the blur intensity to smooth the volumetric lights
  129515. */
  129516. volumetricLightBlurScale: number;
  129517. /**
  129518. * Light (spot or directional) used to generate the volumetric lights rays
  129519. * The source light must have a shadow generate so the pipeline can get its
  129520. * depth map
  129521. */
  129522. sourceLight: Nullable<SpotLight | DirectionalLight>;
  129523. /**
  129524. * For eye adaptation, represents the minimum luminance the eye can see
  129525. */
  129526. hdrMinimumLuminance: number;
  129527. /**
  129528. * For eye adaptation, represents the decrease luminance speed
  129529. */
  129530. hdrDecreaseRate: number;
  129531. /**
  129532. * For eye adaptation, represents the increase luminance speed
  129533. */
  129534. hdrIncreaseRate: number;
  129535. /**
  129536. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129537. */
  129538. /**
  129539. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129540. */
  129541. hdrAutoExposure: boolean;
  129542. /**
  129543. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  129544. */
  129545. lensColorTexture: Nullable<Texture>;
  129546. /**
  129547. * The overall strengh for the lens flare effect
  129548. */
  129549. lensFlareStrength: number;
  129550. /**
  129551. * Dispersion coefficient for lens flare ghosts
  129552. */
  129553. lensFlareGhostDispersal: number;
  129554. /**
  129555. * Main lens flare halo width
  129556. */
  129557. lensFlareHaloWidth: number;
  129558. /**
  129559. * Based on the lens distortion effect, defines how much the lens flare result
  129560. * is distorted
  129561. */
  129562. lensFlareDistortionStrength: number;
  129563. /**
  129564. * Configures the blur intensity used for for lens flare (halo)
  129565. */
  129566. lensFlareBlurWidth: number;
  129567. /**
  129568. * Lens star texture must be used to simulate rays on the flares and is available
  129569. * in the documentation
  129570. */
  129571. lensStarTexture: Nullable<Texture>;
  129572. /**
  129573. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  129574. * flare effect by taking account of the dirt texture
  129575. */
  129576. lensFlareDirtTexture: Nullable<Texture>;
  129577. /**
  129578. * Represents the focal length for the depth of field effect
  129579. */
  129580. depthOfFieldDistance: number;
  129581. /**
  129582. * Represents the blur intensity for the blurred part of the depth of field effect
  129583. */
  129584. depthOfFieldBlurWidth: number;
  129585. /**
  129586. * Gets how much the image is blurred by the movement while using the motion blur post-process
  129587. */
  129588. /**
  129589. * Sets how much the image is blurred by the movement while using the motion blur post-process
  129590. */
  129591. motionStrength: number;
  129592. /**
  129593. * Gets wether or not the motion blur post-process is object based or screen based.
  129594. */
  129595. /**
  129596. * Sets wether or not the motion blur post-process should be object based or screen based
  129597. */
  129598. objectBasedMotionBlur: boolean;
  129599. /**
  129600. * List of animations for the pipeline (IAnimatable implementation)
  129601. */
  129602. animations: Animation[];
  129603. /**
  129604. * Private members
  129605. */
  129606. private _scene;
  129607. private _currentDepthOfFieldSource;
  129608. private _basePostProcess;
  129609. private _fixedExposure;
  129610. private _currentExposure;
  129611. private _hdrAutoExposure;
  129612. private _hdrCurrentLuminance;
  129613. private _motionStrength;
  129614. private _isObjectBasedMotionBlur;
  129615. private _floatTextureType;
  129616. private _camerasToBeAttached;
  129617. private _ratio;
  129618. private _bloomEnabled;
  129619. private _depthOfFieldEnabled;
  129620. private _vlsEnabled;
  129621. private _lensFlareEnabled;
  129622. private _hdrEnabled;
  129623. private _motionBlurEnabled;
  129624. private _fxaaEnabled;
  129625. private _motionBlurSamples;
  129626. private _volumetricLightStepsCount;
  129627. private _samples;
  129628. /**
  129629. * @ignore
  129630. * Specifies if the bloom pipeline is enabled
  129631. */
  129632. BloomEnabled: boolean;
  129633. /**
  129634. * @ignore
  129635. * Specifies if the depth of field pipeline is enabed
  129636. */
  129637. DepthOfFieldEnabled: boolean;
  129638. /**
  129639. * @ignore
  129640. * Specifies if the lens flare pipeline is enabed
  129641. */
  129642. LensFlareEnabled: boolean;
  129643. /**
  129644. * @ignore
  129645. * Specifies if the HDR pipeline is enabled
  129646. */
  129647. HDREnabled: boolean;
  129648. /**
  129649. * @ignore
  129650. * Specifies if the volumetric lights scattering effect is enabled
  129651. */
  129652. VLSEnabled: boolean;
  129653. /**
  129654. * @ignore
  129655. * Specifies if the motion blur effect is enabled
  129656. */
  129657. MotionBlurEnabled: boolean;
  129658. /**
  129659. * Specifies if anti-aliasing is enabled
  129660. */
  129661. fxaaEnabled: boolean;
  129662. /**
  129663. * Specifies the number of steps used to calculate the volumetric lights
  129664. * Typically in interval [50, 200]
  129665. */
  129666. volumetricLightStepsCount: number;
  129667. /**
  129668. * Specifies the number of samples used for the motion blur effect
  129669. * Typically in interval [16, 64]
  129670. */
  129671. motionBlurSamples: number;
  129672. /**
  129673. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129674. */
  129675. samples: number;
  129676. /**
  129677. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129678. * @constructor
  129679. * @param name The rendering pipeline name
  129680. * @param scene The scene linked to this pipeline
  129681. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  129682. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129683. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129684. */
  129685. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129686. private _buildPipeline;
  129687. private _createDownSampleX4PostProcess;
  129688. private _createBrightPassPostProcess;
  129689. private _createBlurPostProcesses;
  129690. private _createTextureAdderPostProcess;
  129691. private _createVolumetricLightPostProcess;
  129692. private _createLuminancePostProcesses;
  129693. private _createHdrPostProcess;
  129694. private _createLensFlarePostProcess;
  129695. private _createDepthOfFieldPostProcess;
  129696. private _createMotionBlurPostProcess;
  129697. private _getDepthTexture;
  129698. private _disposePostProcesses;
  129699. /**
  129700. * Dispose of the pipeline and stop all post processes
  129701. */
  129702. dispose(): void;
  129703. /**
  129704. * Serialize the rendering pipeline (Used when exporting)
  129705. * @returns the serialized object
  129706. */
  129707. serialize(): any;
  129708. /**
  129709. * Parse the serialized pipeline
  129710. * @param source Source pipeline.
  129711. * @param scene The scene to load the pipeline to.
  129712. * @param rootUrl The URL of the serialized pipeline.
  129713. * @returns An instantiated pipeline from the serialized object.
  129714. */
  129715. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129716. /**
  129717. * Luminance steps
  129718. */
  129719. static LuminanceSteps: number;
  129720. }
  129721. }
  129722. declare module BABYLON {
  129723. /** @hidden */
  129724. export var tonemapPixelShader: {
  129725. name: string;
  129726. shader: string;
  129727. };
  129728. }
  129729. declare module BABYLON {
  129730. /** Defines operator used for tonemapping */
  129731. export enum TonemappingOperator {
  129732. /** Hable */
  129733. Hable = 0,
  129734. /** Reinhard */
  129735. Reinhard = 1,
  129736. /** HejiDawson */
  129737. HejiDawson = 2,
  129738. /** Photographic */
  129739. Photographic = 3
  129740. }
  129741. /**
  129742. * Defines a post process to apply tone mapping
  129743. */
  129744. export class TonemapPostProcess extends PostProcess {
  129745. private _operator;
  129746. /** Defines the required exposure adjustement */
  129747. exposureAdjustment: number;
  129748. /**
  129749. * Creates a new TonemapPostProcess
  129750. * @param name defines the name of the postprocess
  129751. * @param _operator defines the operator to use
  129752. * @param exposureAdjustment defines the required exposure adjustement
  129753. * @param camera defines the camera to use (can be null)
  129754. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129755. * @param engine defines the hosting engine (can be ignore if camera is set)
  129756. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129757. */
  129758. constructor(name: string, _operator: TonemappingOperator,
  129759. /** Defines the required exposure adjustement */
  129760. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129761. }
  129762. }
  129763. declare module BABYLON {
  129764. /** @hidden */
  129765. export var depthVertexShader: {
  129766. name: string;
  129767. shader: string;
  129768. };
  129769. }
  129770. declare module BABYLON {
  129771. /** @hidden */
  129772. export var volumetricLightScatteringPixelShader: {
  129773. name: string;
  129774. shader: string;
  129775. };
  129776. }
  129777. declare module BABYLON {
  129778. /** @hidden */
  129779. export var volumetricLightScatteringPassVertexShader: {
  129780. name: string;
  129781. shader: string;
  129782. };
  129783. }
  129784. declare module BABYLON {
  129785. /** @hidden */
  129786. export var volumetricLightScatteringPassPixelShader: {
  129787. name: string;
  129788. shader: string;
  129789. };
  129790. }
  129791. declare module BABYLON {
  129792. /**
  129793. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129794. */
  129795. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129796. private _volumetricLightScatteringPass;
  129797. private _volumetricLightScatteringRTT;
  129798. private _viewPort;
  129799. private _screenCoordinates;
  129800. private _cachedDefines;
  129801. /**
  129802. * If not undefined, the mesh position is computed from the attached node position
  129803. */
  129804. attachedNode: {
  129805. position: Vector3;
  129806. };
  129807. /**
  129808. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129809. */
  129810. customMeshPosition: Vector3;
  129811. /**
  129812. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129813. */
  129814. useCustomMeshPosition: boolean;
  129815. /**
  129816. * If the post-process should inverse the light scattering direction
  129817. */
  129818. invert: boolean;
  129819. /**
  129820. * The internal mesh used by the post-process
  129821. */
  129822. mesh: Mesh;
  129823. /**
  129824. * @hidden
  129825. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129826. */
  129827. useDiffuseColor: boolean;
  129828. /**
  129829. * Array containing the excluded meshes not rendered in the internal pass
  129830. */
  129831. excludedMeshes: AbstractMesh[];
  129832. /**
  129833. * Controls the overall intensity of the post-process
  129834. */
  129835. exposure: number;
  129836. /**
  129837. * Dissipates each sample's contribution in range [0, 1]
  129838. */
  129839. decay: number;
  129840. /**
  129841. * Controls the overall intensity of each sample
  129842. */
  129843. weight: number;
  129844. /**
  129845. * Controls the density of each sample
  129846. */
  129847. density: number;
  129848. /**
  129849. * @constructor
  129850. * @param name The post-process name
  129851. * @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)
  129852. * @param camera The camera that the post-process will be attached to
  129853. * @param mesh The mesh used to create the light scattering
  129854. * @param samples The post-process quality, default 100
  129855. * @param samplingModeThe post-process filtering mode
  129856. * @param engine The babylon engine
  129857. * @param reusable If the post-process is reusable
  129858. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129859. */
  129860. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129861. /**
  129862. * Returns the string "VolumetricLightScatteringPostProcess"
  129863. * @returns "VolumetricLightScatteringPostProcess"
  129864. */
  129865. getClassName(): string;
  129866. private _isReady;
  129867. /**
  129868. * Sets the new light position for light scattering effect
  129869. * @param position The new custom light position
  129870. */
  129871. setCustomMeshPosition(position: Vector3): void;
  129872. /**
  129873. * Returns the light position for light scattering effect
  129874. * @return Vector3 The custom light position
  129875. */
  129876. getCustomMeshPosition(): Vector3;
  129877. /**
  129878. * Disposes the internal assets and detaches the post-process from the camera
  129879. */
  129880. dispose(camera: Camera): void;
  129881. /**
  129882. * Returns the render target texture used by the post-process
  129883. * @return the render target texture used by the post-process
  129884. */
  129885. getPass(): RenderTargetTexture;
  129886. private _meshExcluded;
  129887. private _createPass;
  129888. private _updateMeshScreenCoordinates;
  129889. /**
  129890. * Creates a default mesh for the Volumeric Light Scattering post-process
  129891. * @param name The mesh name
  129892. * @param scene The scene where to create the mesh
  129893. * @return the default mesh
  129894. */
  129895. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129896. }
  129897. }
  129898. declare module BABYLON {
  129899. interface Scene {
  129900. /** @hidden (Backing field) */
  129901. _boundingBoxRenderer: BoundingBoxRenderer;
  129902. /** @hidden (Backing field) */
  129903. _forceShowBoundingBoxes: boolean;
  129904. /**
  129905. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129906. */
  129907. forceShowBoundingBoxes: boolean;
  129908. /**
  129909. * Gets the bounding box renderer associated with the scene
  129910. * @returns a BoundingBoxRenderer
  129911. */
  129912. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129913. }
  129914. interface AbstractMesh {
  129915. /** @hidden (Backing field) */
  129916. _showBoundingBox: boolean;
  129917. /**
  129918. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129919. */
  129920. showBoundingBox: boolean;
  129921. }
  129922. /**
  129923. * Component responsible of rendering the bounding box of the meshes in a scene.
  129924. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129925. */
  129926. export class BoundingBoxRenderer implements ISceneComponent {
  129927. /**
  129928. * The component name helpfull to identify the component in the list of scene components.
  129929. */
  129930. readonly name: string;
  129931. /**
  129932. * The scene the component belongs to.
  129933. */
  129934. scene: Scene;
  129935. /**
  129936. * Color of the bounding box lines placed in front of an object
  129937. */
  129938. frontColor: Color3;
  129939. /**
  129940. * Color of the bounding box lines placed behind an object
  129941. */
  129942. backColor: Color3;
  129943. /**
  129944. * Defines if the renderer should show the back lines or not
  129945. */
  129946. showBackLines: boolean;
  129947. /**
  129948. * @hidden
  129949. */
  129950. renderList: SmartArray<BoundingBox>;
  129951. private _colorShader;
  129952. private _vertexBuffers;
  129953. private _indexBuffer;
  129954. private _fillIndexBuffer;
  129955. private _fillIndexData;
  129956. /**
  129957. * Instantiates a new bounding box renderer in a scene.
  129958. * @param scene the scene the renderer renders in
  129959. */
  129960. constructor(scene: Scene);
  129961. /**
  129962. * Registers the component in a given scene
  129963. */
  129964. register(): void;
  129965. private _evaluateSubMesh;
  129966. private _activeMesh;
  129967. private _prepareRessources;
  129968. private _createIndexBuffer;
  129969. /**
  129970. * Rebuilds the elements related to this component in case of
  129971. * context lost for instance.
  129972. */
  129973. rebuild(): void;
  129974. /**
  129975. * @hidden
  129976. */
  129977. reset(): void;
  129978. /**
  129979. * Render the bounding boxes of a specific rendering group
  129980. * @param renderingGroupId defines the rendering group to render
  129981. */
  129982. render(renderingGroupId: number): void;
  129983. /**
  129984. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129985. * @param mesh Define the mesh to render the occlusion bounding box for
  129986. */
  129987. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129988. /**
  129989. * Dispose and release the resources attached to this renderer.
  129990. */
  129991. dispose(): void;
  129992. }
  129993. }
  129994. declare module BABYLON {
  129995. /** @hidden */
  129996. export var depthPixelShader: {
  129997. name: string;
  129998. shader: string;
  129999. };
  130000. }
  130001. declare module BABYLON {
  130002. /**
  130003. * This represents a depth renderer in Babylon.
  130004. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130005. */
  130006. export class DepthRenderer {
  130007. private _scene;
  130008. private _depthMap;
  130009. private _effect;
  130010. private readonly _storeNonLinearDepth;
  130011. private readonly _clearColor;
  130012. /** Get if the depth renderer is using packed depth or not */
  130013. readonly isPacked: boolean;
  130014. private _cachedDefines;
  130015. private _camera;
  130016. /**
  130017. * Specifiess that the depth renderer will only be used within
  130018. * the camera it is created for.
  130019. * This can help forcing its rendering during the camera processing.
  130020. */
  130021. useOnlyInActiveCamera: boolean;
  130022. /** @hidden */
  130023. static _SceneComponentInitialization: (scene: Scene) => void;
  130024. /**
  130025. * Instantiates a depth renderer
  130026. * @param scene The scene the renderer belongs to
  130027. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130028. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130029. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130030. */
  130031. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130032. /**
  130033. * Creates the depth rendering effect and checks if the effect is ready.
  130034. * @param subMesh The submesh to be used to render the depth map of
  130035. * @param useInstances If multiple world instances should be used
  130036. * @returns if the depth renderer is ready to render the depth map
  130037. */
  130038. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130039. /**
  130040. * Gets the texture which the depth map will be written to.
  130041. * @returns The depth map texture
  130042. */
  130043. getDepthMap(): RenderTargetTexture;
  130044. /**
  130045. * Disposes of the depth renderer.
  130046. */
  130047. dispose(): void;
  130048. }
  130049. }
  130050. declare module BABYLON {
  130051. interface Scene {
  130052. /** @hidden (Backing field) */
  130053. _depthRenderer: {
  130054. [id: string]: DepthRenderer;
  130055. };
  130056. /**
  130057. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130058. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130059. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130060. * @returns the created depth renderer
  130061. */
  130062. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130063. /**
  130064. * Disables a depth renderer for a given camera
  130065. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130066. */
  130067. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130068. }
  130069. /**
  130070. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130071. * in several rendering techniques.
  130072. */
  130073. export class DepthRendererSceneComponent implements ISceneComponent {
  130074. /**
  130075. * The component name helpfull to identify the component in the list of scene components.
  130076. */
  130077. readonly name: string;
  130078. /**
  130079. * The scene the component belongs to.
  130080. */
  130081. scene: Scene;
  130082. /**
  130083. * Creates a new instance of the component for the given scene
  130084. * @param scene Defines the scene to register the component in
  130085. */
  130086. constructor(scene: Scene);
  130087. /**
  130088. * Registers the component in a given scene
  130089. */
  130090. register(): void;
  130091. /**
  130092. * Rebuilds the elements related to this component in case of
  130093. * context lost for instance.
  130094. */
  130095. rebuild(): void;
  130096. /**
  130097. * Disposes the component and the associated ressources
  130098. */
  130099. dispose(): void;
  130100. private _gatherRenderTargets;
  130101. private _gatherActiveCameraRenderTargets;
  130102. }
  130103. }
  130104. declare module BABYLON {
  130105. /** @hidden */
  130106. export var outlinePixelShader: {
  130107. name: string;
  130108. shader: string;
  130109. };
  130110. }
  130111. declare module BABYLON {
  130112. /** @hidden */
  130113. export var outlineVertexShader: {
  130114. name: string;
  130115. shader: string;
  130116. };
  130117. }
  130118. declare module BABYLON {
  130119. interface Scene {
  130120. /** @hidden */
  130121. _outlineRenderer: OutlineRenderer;
  130122. /**
  130123. * Gets the outline renderer associated with the scene
  130124. * @returns a OutlineRenderer
  130125. */
  130126. getOutlineRenderer(): OutlineRenderer;
  130127. }
  130128. interface AbstractMesh {
  130129. /** @hidden (Backing field) */
  130130. _renderOutline: boolean;
  130131. /**
  130132. * Gets or sets a boolean indicating if the outline must be rendered as well
  130133. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130134. */
  130135. renderOutline: boolean;
  130136. /** @hidden (Backing field) */
  130137. _renderOverlay: boolean;
  130138. /**
  130139. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130140. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130141. */
  130142. renderOverlay: boolean;
  130143. }
  130144. /**
  130145. * This class is responsible to draw bothe outline/overlay of meshes.
  130146. * It should not be used directly but through the available method on mesh.
  130147. */
  130148. export class OutlineRenderer implements ISceneComponent {
  130149. /**
  130150. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130151. */
  130152. private static _StencilReference;
  130153. /**
  130154. * The name of the component. Each component must have a unique name.
  130155. */
  130156. name: string;
  130157. /**
  130158. * The scene the component belongs to.
  130159. */
  130160. scene: Scene;
  130161. /**
  130162. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130163. */
  130164. zOffset: number;
  130165. private _engine;
  130166. private _effect;
  130167. private _cachedDefines;
  130168. private _savedDepthWrite;
  130169. /**
  130170. * Instantiates a new outline renderer. (There could be only one per scene).
  130171. * @param scene Defines the scene it belongs to
  130172. */
  130173. constructor(scene: Scene);
  130174. /**
  130175. * Register the component to one instance of a scene.
  130176. */
  130177. register(): void;
  130178. /**
  130179. * Rebuilds the elements related to this component in case of
  130180. * context lost for instance.
  130181. */
  130182. rebuild(): void;
  130183. /**
  130184. * Disposes the component and the associated ressources.
  130185. */
  130186. dispose(): void;
  130187. /**
  130188. * Renders the outline in the canvas.
  130189. * @param subMesh Defines the sumesh to render
  130190. * @param batch Defines the batch of meshes in case of instances
  130191. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130192. */
  130193. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130194. /**
  130195. * Returns whether or not the outline renderer is ready for a given submesh.
  130196. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130197. * @param subMesh Defines the submesh to check readyness for
  130198. * @param useInstances Defines wheter wee are trying to render instances or not
  130199. * @returns true if ready otherwise false
  130200. */
  130201. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130202. private _beforeRenderingMesh;
  130203. private _afterRenderingMesh;
  130204. }
  130205. }
  130206. declare module BABYLON {
  130207. /**
  130208. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130209. * @see http://doc.babylonjs.com/babylon101/sprites
  130210. */
  130211. export class SpritePackedManager extends SpriteManager {
  130212. /** defines the packed manager's name */
  130213. name: string;
  130214. /**
  130215. * Creates a new sprite manager from a packed sprite sheet
  130216. * @param name defines the manager's name
  130217. * @param imgUrl defines the sprite sheet url
  130218. * @param capacity defines the maximum allowed number of sprites
  130219. * @param scene defines the hosting scene
  130220. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130222. * @param samplingMode defines the smapling mode to use with spritesheet
  130223. * @param fromPacked set to true; do not alter
  130224. */
  130225. constructor(
  130226. /** defines the packed manager's name */
  130227. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130228. }
  130229. }
  130230. declare module BABYLON {
  130231. /**
  130232. * Defines the list of states available for a task inside a AssetsManager
  130233. */
  130234. export enum AssetTaskState {
  130235. /**
  130236. * Initialization
  130237. */
  130238. INIT = 0,
  130239. /**
  130240. * Running
  130241. */
  130242. RUNNING = 1,
  130243. /**
  130244. * Done
  130245. */
  130246. DONE = 2,
  130247. /**
  130248. * Error
  130249. */
  130250. ERROR = 3
  130251. }
  130252. /**
  130253. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130254. */
  130255. export abstract class AbstractAssetTask {
  130256. /**
  130257. * Task name
  130258. */ name: string;
  130259. /**
  130260. * Callback called when the task is successful
  130261. */
  130262. onSuccess: (task: any) => void;
  130263. /**
  130264. * Callback called when the task is not successful
  130265. */
  130266. onError: (task: any, message?: string, exception?: any) => void;
  130267. /**
  130268. * Creates a new AssetsManager
  130269. * @param name defines the name of the task
  130270. */
  130271. constructor(
  130272. /**
  130273. * Task name
  130274. */ name: string);
  130275. private _isCompleted;
  130276. private _taskState;
  130277. private _errorObject;
  130278. /**
  130279. * Get if the task is completed
  130280. */
  130281. readonly isCompleted: boolean;
  130282. /**
  130283. * Gets the current state of the task
  130284. */
  130285. readonly taskState: AssetTaskState;
  130286. /**
  130287. * Gets the current error object (if task is in error)
  130288. */
  130289. readonly errorObject: {
  130290. message?: string;
  130291. exception?: any;
  130292. };
  130293. /**
  130294. * Internal only
  130295. * @hidden
  130296. */
  130297. _setErrorObject(message?: string, exception?: any): void;
  130298. /**
  130299. * Execute the current task
  130300. * @param scene defines the scene where you want your assets to be loaded
  130301. * @param onSuccess is a callback called when the task is successfully executed
  130302. * @param onError is a callback called if an error occurs
  130303. */
  130304. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130305. /**
  130306. * Execute the current task
  130307. * @param scene defines the scene where you want your assets to be loaded
  130308. * @param onSuccess is a callback called when the task is successfully executed
  130309. * @param onError is a callback called if an error occurs
  130310. */
  130311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130312. /**
  130313. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130314. * This can be used with failed tasks that have the reason for failure fixed.
  130315. */
  130316. reset(): void;
  130317. private onErrorCallback;
  130318. private onDoneCallback;
  130319. }
  130320. /**
  130321. * Define the interface used by progress events raised during assets loading
  130322. */
  130323. export interface IAssetsProgressEvent {
  130324. /**
  130325. * Defines the number of remaining tasks to process
  130326. */
  130327. remainingCount: number;
  130328. /**
  130329. * Defines the total number of tasks
  130330. */
  130331. totalCount: number;
  130332. /**
  130333. * Defines the task that was just processed
  130334. */
  130335. task: AbstractAssetTask;
  130336. }
  130337. /**
  130338. * Class used to share progress information about assets loading
  130339. */
  130340. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130341. /**
  130342. * Defines the number of remaining tasks to process
  130343. */
  130344. remainingCount: number;
  130345. /**
  130346. * Defines the total number of tasks
  130347. */
  130348. totalCount: number;
  130349. /**
  130350. * Defines the task that was just processed
  130351. */
  130352. task: AbstractAssetTask;
  130353. /**
  130354. * Creates a AssetsProgressEvent
  130355. * @param remainingCount defines the number of remaining tasks to process
  130356. * @param totalCount defines the total number of tasks
  130357. * @param task defines the task that was just processed
  130358. */
  130359. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130360. }
  130361. /**
  130362. * Define a task used by AssetsManager to load meshes
  130363. */
  130364. export class MeshAssetTask extends AbstractAssetTask {
  130365. /**
  130366. * Defines the name of the task
  130367. */
  130368. name: string;
  130369. /**
  130370. * Defines the list of mesh's names you want to load
  130371. */
  130372. meshesNames: any;
  130373. /**
  130374. * Defines the root url to use as a base to load your meshes and associated resources
  130375. */
  130376. rootUrl: string;
  130377. /**
  130378. * Defines the filename of the scene to load from
  130379. */
  130380. sceneFilename: string;
  130381. /**
  130382. * Gets the list of loaded meshes
  130383. */
  130384. loadedMeshes: Array<AbstractMesh>;
  130385. /**
  130386. * Gets the list of loaded particle systems
  130387. */
  130388. loadedParticleSystems: Array<IParticleSystem>;
  130389. /**
  130390. * Gets the list of loaded skeletons
  130391. */
  130392. loadedSkeletons: Array<Skeleton>;
  130393. /**
  130394. * Gets the list of loaded animation groups
  130395. */
  130396. loadedAnimationGroups: Array<AnimationGroup>;
  130397. /**
  130398. * Callback called when the task is successful
  130399. */
  130400. onSuccess: (task: MeshAssetTask) => void;
  130401. /**
  130402. * Callback called when the task is successful
  130403. */
  130404. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130405. /**
  130406. * Creates a new MeshAssetTask
  130407. * @param name defines the name of the task
  130408. * @param meshesNames defines the list of mesh's names you want to load
  130409. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130410. * @param sceneFilename defines the filename of the scene to load from
  130411. */
  130412. constructor(
  130413. /**
  130414. * Defines the name of the task
  130415. */
  130416. name: string,
  130417. /**
  130418. * Defines the list of mesh's names you want to load
  130419. */
  130420. meshesNames: any,
  130421. /**
  130422. * Defines the root url to use as a base to load your meshes and associated resources
  130423. */
  130424. rootUrl: string,
  130425. /**
  130426. * Defines the filename of the scene to load from
  130427. */
  130428. sceneFilename: string);
  130429. /**
  130430. * Execute the current task
  130431. * @param scene defines the scene where you want your assets to be loaded
  130432. * @param onSuccess is a callback called when the task is successfully executed
  130433. * @param onError is a callback called if an error occurs
  130434. */
  130435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130436. }
  130437. /**
  130438. * Define a task used by AssetsManager to load text content
  130439. */
  130440. export class TextFileAssetTask extends AbstractAssetTask {
  130441. /**
  130442. * Defines the name of the task
  130443. */
  130444. name: string;
  130445. /**
  130446. * Defines the location of the file to load
  130447. */
  130448. url: string;
  130449. /**
  130450. * Gets the loaded text string
  130451. */
  130452. text: string;
  130453. /**
  130454. * Callback called when the task is successful
  130455. */
  130456. onSuccess: (task: TextFileAssetTask) => void;
  130457. /**
  130458. * Callback called when the task is successful
  130459. */
  130460. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130461. /**
  130462. * Creates a new TextFileAssetTask object
  130463. * @param name defines the name of the task
  130464. * @param url defines the location of the file to load
  130465. */
  130466. constructor(
  130467. /**
  130468. * Defines the name of the task
  130469. */
  130470. name: string,
  130471. /**
  130472. * Defines the location of the file to load
  130473. */
  130474. url: string);
  130475. /**
  130476. * Execute the current task
  130477. * @param scene defines the scene where you want your assets to be loaded
  130478. * @param onSuccess is a callback called when the task is successfully executed
  130479. * @param onError is a callback called if an error occurs
  130480. */
  130481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130482. }
  130483. /**
  130484. * Define a task used by AssetsManager to load binary data
  130485. */
  130486. export class BinaryFileAssetTask extends AbstractAssetTask {
  130487. /**
  130488. * Defines the name of the task
  130489. */
  130490. name: string;
  130491. /**
  130492. * Defines the location of the file to load
  130493. */
  130494. url: string;
  130495. /**
  130496. * Gets the lodaded data (as an array buffer)
  130497. */
  130498. data: ArrayBuffer;
  130499. /**
  130500. * Callback called when the task is successful
  130501. */
  130502. onSuccess: (task: BinaryFileAssetTask) => void;
  130503. /**
  130504. * Callback called when the task is successful
  130505. */
  130506. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  130507. /**
  130508. * Creates a new BinaryFileAssetTask object
  130509. * @param name defines the name of the new task
  130510. * @param url defines the location of the file to load
  130511. */
  130512. constructor(
  130513. /**
  130514. * Defines the name of the task
  130515. */
  130516. name: string,
  130517. /**
  130518. * Defines the location of the file to load
  130519. */
  130520. url: string);
  130521. /**
  130522. * Execute the current task
  130523. * @param scene defines the scene where you want your assets to be loaded
  130524. * @param onSuccess is a callback called when the task is successfully executed
  130525. * @param onError is a callback called if an error occurs
  130526. */
  130527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130528. }
  130529. /**
  130530. * Define a task used by AssetsManager to load images
  130531. */
  130532. export class ImageAssetTask extends AbstractAssetTask {
  130533. /**
  130534. * Defines the name of the task
  130535. */
  130536. name: string;
  130537. /**
  130538. * Defines the location of the image to load
  130539. */
  130540. url: string;
  130541. /**
  130542. * Gets the loaded images
  130543. */
  130544. image: HTMLImageElement;
  130545. /**
  130546. * Callback called when the task is successful
  130547. */
  130548. onSuccess: (task: ImageAssetTask) => void;
  130549. /**
  130550. * Callback called when the task is successful
  130551. */
  130552. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  130553. /**
  130554. * Creates a new ImageAssetTask
  130555. * @param name defines the name of the task
  130556. * @param url defines the location of the image to load
  130557. */
  130558. constructor(
  130559. /**
  130560. * Defines the name of the task
  130561. */
  130562. name: string,
  130563. /**
  130564. * Defines the location of the image to load
  130565. */
  130566. url: string);
  130567. /**
  130568. * Execute the current task
  130569. * @param scene defines the scene where you want your assets to be loaded
  130570. * @param onSuccess is a callback called when the task is successfully executed
  130571. * @param onError is a callback called if an error occurs
  130572. */
  130573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130574. }
  130575. /**
  130576. * Defines the interface used by texture loading tasks
  130577. */
  130578. export interface ITextureAssetTask<TEX extends BaseTexture> {
  130579. /**
  130580. * Gets the loaded texture
  130581. */
  130582. texture: TEX;
  130583. }
  130584. /**
  130585. * Define a task used by AssetsManager to load 2D textures
  130586. */
  130587. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  130588. /**
  130589. * Defines the name of the task
  130590. */
  130591. name: string;
  130592. /**
  130593. * Defines the location of the file to load
  130594. */
  130595. url: string;
  130596. /**
  130597. * Defines if mipmap should not be generated (default is false)
  130598. */
  130599. noMipmap?: boolean | undefined;
  130600. /**
  130601. * Defines if texture must be inverted on Y axis (default is false)
  130602. */
  130603. invertY?: boolean | undefined;
  130604. /**
  130605. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130606. */
  130607. samplingMode: number;
  130608. /**
  130609. * Gets the loaded texture
  130610. */
  130611. texture: Texture;
  130612. /**
  130613. * Callback called when the task is successful
  130614. */
  130615. onSuccess: (task: TextureAssetTask) => void;
  130616. /**
  130617. * Callback called when the task is successful
  130618. */
  130619. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  130620. /**
  130621. * Creates a new TextureAssetTask object
  130622. * @param name defines the name of the task
  130623. * @param url defines the location of the file to load
  130624. * @param noMipmap defines if mipmap should not be generated (default is false)
  130625. * @param invertY defines if texture must be inverted on Y axis (default is false)
  130626. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130627. */
  130628. constructor(
  130629. /**
  130630. * Defines the name of the task
  130631. */
  130632. name: string,
  130633. /**
  130634. * Defines the location of the file to load
  130635. */
  130636. url: string,
  130637. /**
  130638. * Defines if mipmap should not be generated (default is false)
  130639. */
  130640. noMipmap?: boolean | undefined,
  130641. /**
  130642. * Defines if texture must be inverted on Y axis (default is false)
  130643. */
  130644. invertY?: boolean | undefined,
  130645. /**
  130646. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130647. */
  130648. samplingMode?: number);
  130649. /**
  130650. * Execute the current task
  130651. * @param scene defines the scene where you want your assets to be loaded
  130652. * @param onSuccess is a callback called when the task is successfully executed
  130653. * @param onError is a callback called if an error occurs
  130654. */
  130655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130656. }
  130657. /**
  130658. * Define a task used by AssetsManager to load cube textures
  130659. */
  130660. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130661. /**
  130662. * Defines the name of the task
  130663. */
  130664. name: string;
  130665. /**
  130666. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130667. */
  130668. url: string;
  130669. /**
  130670. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130671. */
  130672. extensions?: string[] | undefined;
  130673. /**
  130674. * Defines if mipmaps should not be generated (default is false)
  130675. */
  130676. noMipmap?: boolean | undefined;
  130677. /**
  130678. * Defines the explicit list of files (undefined by default)
  130679. */
  130680. files?: string[] | undefined;
  130681. /**
  130682. * Gets the loaded texture
  130683. */
  130684. texture: CubeTexture;
  130685. /**
  130686. * Callback called when the task is successful
  130687. */
  130688. onSuccess: (task: CubeTextureAssetTask) => void;
  130689. /**
  130690. * Callback called when the task is successful
  130691. */
  130692. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130693. /**
  130694. * Creates a new CubeTextureAssetTask
  130695. * @param name defines the name of the task
  130696. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130697. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130698. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130699. * @param files defines the explicit list of files (undefined by default)
  130700. */
  130701. constructor(
  130702. /**
  130703. * Defines the name of the task
  130704. */
  130705. name: string,
  130706. /**
  130707. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130708. */
  130709. url: string,
  130710. /**
  130711. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130712. */
  130713. extensions?: string[] | undefined,
  130714. /**
  130715. * Defines if mipmaps should not be generated (default is false)
  130716. */
  130717. noMipmap?: boolean | undefined,
  130718. /**
  130719. * Defines the explicit list of files (undefined by default)
  130720. */
  130721. files?: string[] | undefined);
  130722. /**
  130723. * Execute the current task
  130724. * @param scene defines the scene where you want your assets to be loaded
  130725. * @param onSuccess is a callback called when the task is successfully executed
  130726. * @param onError is a callback called if an error occurs
  130727. */
  130728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130729. }
  130730. /**
  130731. * Define a task used by AssetsManager to load HDR cube textures
  130732. */
  130733. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130734. /**
  130735. * Defines the name of the task
  130736. */
  130737. name: string;
  130738. /**
  130739. * Defines the location of the file to load
  130740. */
  130741. url: string;
  130742. /**
  130743. * Defines the desired size (the more it increases the longer the generation will be)
  130744. */
  130745. size: number;
  130746. /**
  130747. * Defines if mipmaps should not be generated (default is false)
  130748. */
  130749. noMipmap: boolean;
  130750. /**
  130751. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130752. */
  130753. generateHarmonics: boolean;
  130754. /**
  130755. * 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)
  130756. */
  130757. gammaSpace: boolean;
  130758. /**
  130759. * Internal Use Only
  130760. */
  130761. reserved: boolean;
  130762. /**
  130763. * Gets the loaded texture
  130764. */
  130765. texture: HDRCubeTexture;
  130766. /**
  130767. * Callback called when the task is successful
  130768. */
  130769. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130770. /**
  130771. * Callback called when the task is successful
  130772. */
  130773. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130774. /**
  130775. * Creates a new HDRCubeTextureAssetTask object
  130776. * @param name defines the name of the task
  130777. * @param url defines the location of the file to load
  130778. * @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.
  130779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130780. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130781. * @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)
  130782. * @param reserved Internal use only
  130783. */
  130784. constructor(
  130785. /**
  130786. * Defines the name of the task
  130787. */
  130788. name: string,
  130789. /**
  130790. * Defines the location of the file to load
  130791. */
  130792. url: string,
  130793. /**
  130794. * Defines the desired size (the more it increases the longer the generation will be)
  130795. */
  130796. size: number,
  130797. /**
  130798. * Defines if mipmaps should not be generated (default is false)
  130799. */
  130800. noMipmap?: boolean,
  130801. /**
  130802. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130803. */
  130804. generateHarmonics?: boolean,
  130805. /**
  130806. * 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)
  130807. */
  130808. gammaSpace?: boolean,
  130809. /**
  130810. * Internal Use Only
  130811. */
  130812. reserved?: boolean);
  130813. /**
  130814. * Execute the current task
  130815. * @param scene defines the scene where you want your assets to be loaded
  130816. * @param onSuccess is a callback called when the task is successfully executed
  130817. * @param onError is a callback called if an error occurs
  130818. */
  130819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130820. }
  130821. /**
  130822. * Define a task used by AssetsManager to load Equirectangular cube textures
  130823. */
  130824. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130825. /**
  130826. * Defines the name of the task
  130827. */
  130828. name: string;
  130829. /**
  130830. * Defines the location of the file to load
  130831. */
  130832. url: string;
  130833. /**
  130834. * Defines the desired size (the more it increases the longer the generation will be)
  130835. */
  130836. size: number;
  130837. /**
  130838. * Defines if mipmaps should not be generated (default is false)
  130839. */
  130840. noMipmap: boolean;
  130841. /**
  130842. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130843. * but the standard material would require them in Gamma space) (default is true)
  130844. */
  130845. gammaSpace: boolean;
  130846. /**
  130847. * Gets the loaded texture
  130848. */
  130849. texture: EquiRectangularCubeTexture;
  130850. /**
  130851. * Callback called when the task is successful
  130852. */
  130853. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130854. /**
  130855. * Callback called when the task is successful
  130856. */
  130857. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130858. /**
  130859. * Creates a new EquiRectangularCubeTextureAssetTask object
  130860. * @param name defines the name of the task
  130861. * @param url defines the location of the file to load
  130862. * @param size defines the desired size (the more it increases the longer the generation will be)
  130863. * If the size is omitted this implies you are using a preprocessed cubemap.
  130864. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130865. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130866. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130867. * (default is true)
  130868. */
  130869. constructor(
  130870. /**
  130871. * Defines the name of the task
  130872. */
  130873. name: string,
  130874. /**
  130875. * Defines the location of the file to load
  130876. */
  130877. url: string,
  130878. /**
  130879. * Defines the desired size (the more it increases the longer the generation will be)
  130880. */
  130881. size: number,
  130882. /**
  130883. * Defines if mipmaps should not be generated (default is false)
  130884. */
  130885. noMipmap?: boolean,
  130886. /**
  130887. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130888. * but the standard material would require them in Gamma space) (default is true)
  130889. */
  130890. gammaSpace?: boolean);
  130891. /**
  130892. * Execute the current task
  130893. * @param scene defines the scene where you want your assets to be loaded
  130894. * @param onSuccess is a callback called when the task is successfully executed
  130895. * @param onError is a callback called if an error occurs
  130896. */
  130897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130898. }
  130899. /**
  130900. * This class can be used to easily import assets into a scene
  130901. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130902. */
  130903. export class AssetsManager {
  130904. private _scene;
  130905. private _isLoading;
  130906. protected _tasks: AbstractAssetTask[];
  130907. protected _waitingTasksCount: number;
  130908. protected _totalTasksCount: number;
  130909. /**
  130910. * Callback called when all tasks are processed
  130911. */
  130912. onFinish: (tasks: AbstractAssetTask[]) => void;
  130913. /**
  130914. * Callback called when a task is successful
  130915. */
  130916. onTaskSuccess: (task: AbstractAssetTask) => void;
  130917. /**
  130918. * Callback called when a task had an error
  130919. */
  130920. onTaskError: (task: AbstractAssetTask) => void;
  130921. /**
  130922. * Callback called when a task is done (whatever the result is)
  130923. */
  130924. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130925. /**
  130926. * Observable called when all tasks are processed
  130927. */
  130928. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130929. /**
  130930. * Observable called when a task had an error
  130931. */
  130932. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130933. /**
  130934. * Observable called when all tasks were executed
  130935. */
  130936. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130937. /**
  130938. * Observable called when a task is done (whatever the result is)
  130939. */
  130940. onProgressObservable: Observable<IAssetsProgressEvent>;
  130941. /**
  130942. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130944. */
  130945. useDefaultLoadingScreen: boolean;
  130946. /**
  130947. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130948. * when all assets have been downloaded.
  130949. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130950. */
  130951. autoHideLoadingUI: boolean;
  130952. /**
  130953. * Creates a new AssetsManager
  130954. * @param scene defines the scene to work on
  130955. */
  130956. constructor(scene: Scene);
  130957. /**
  130958. * Add a MeshAssetTask to the list of active tasks
  130959. * @param taskName defines the name of the new task
  130960. * @param meshesNames defines the name of meshes to load
  130961. * @param rootUrl defines the root url to use to locate files
  130962. * @param sceneFilename defines the filename of the scene file
  130963. * @returns a new MeshAssetTask object
  130964. */
  130965. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130966. /**
  130967. * Add a TextFileAssetTask to the list of active tasks
  130968. * @param taskName defines the name of the new task
  130969. * @param url defines the url of the file to load
  130970. * @returns a new TextFileAssetTask object
  130971. */
  130972. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130973. /**
  130974. * Add a BinaryFileAssetTask to the list of active tasks
  130975. * @param taskName defines the name of the new task
  130976. * @param url defines the url of the file to load
  130977. * @returns a new BinaryFileAssetTask object
  130978. */
  130979. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130980. /**
  130981. * Add a ImageAssetTask to the list of active tasks
  130982. * @param taskName defines the name of the new task
  130983. * @param url defines the url of the file to load
  130984. * @returns a new ImageAssetTask object
  130985. */
  130986. addImageTask(taskName: string, url: string): ImageAssetTask;
  130987. /**
  130988. * Add a TextureAssetTask to the list of active tasks
  130989. * @param taskName defines the name of the new task
  130990. * @param url defines the url of the file to load
  130991. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130992. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130993. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130994. * @returns a new TextureAssetTask object
  130995. */
  130996. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130997. /**
  130998. * Add a CubeTextureAssetTask to the list of active tasks
  130999. * @param taskName defines the name of the new task
  131000. * @param url defines the url of the file to load
  131001. * @param extensions defines the extension to use to load the cube map (can be null)
  131002. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131003. * @param files defines the list of files to load (can be null)
  131004. * @returns a new CubeTextureAssetTask object
  131005. */
  131006. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131007. /**
  131008. *
  131009. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131010. * @param taskName defines the name of the new task
  131011. * @param url defines the url of the file to load
  131012. * @param size defines the size you want for the cubemap (can be null)
  131013. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131014. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131015. * @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)
  131016. * @param reserved Internal use only
  131017. * @returns a new HDRCubeTextureAssetTask object
  131018. */
  131019. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131020. /**
  131021. *
  131022. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131023. * @param taskName defines the name of the new task
  131024. * @param url defines the url of the file to load
  131025. * @param size defines the size you want for the cubemap (can be null)
  131026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131027. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131028. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131029. * @returns a new EquiRectangularCubeTextureAssetTask object
  131030. */
  131031. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131032. /**
  131033. * Remove a task from the assets manager.
  131034. * @param task the task to remove
  131035. */
  131036. removeTask(task: AbstractAssetTask): void;
  131037. private _decreaseWaitingTasksCount;
  131038. private _runTask;
  131039. /**
  131040. * Reset the AssetsManager and remove all tasks
  131041. * @return the current instance of the AssetsManager
  131042. */
  131043. reset(): AssetsManager;
  131044. /**
  131045. * Start the loading process
  131046. * @return the current instance of the AssetsManager
  131047. */
  131048. load(): AssetsManager;
  131049. /**
  131050. * Start the loading process as an async operation
  131051. * @return a promise returning the list of failed tasks
  131052. */
  131053. loadAsync(): Promise<void>;
  131054. }
  131055. }
  131056. declare module BABYLON {
  131057. /**
  131058. * Wrapper class for promise with external resolve and reject.
  131059. */
  131060. export class Deferred<T> {
  131061. /**
  131062. * The promise associated with this deferred object.
  131063. */
  131064. readonly promise: Promise<T>;
  131065. private _resolve;
  131066. private _reject;
  131067. /**
  131068. * The resolve method of the promise associated with this deferred object.
  131069. */
  131070. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131071. /**
  131072. * The reject method of the promise associated with this deferred object.
  131073. */
  131074. readonly reject: (reason?: any) => void;
  131075. /**
  131076. * Constructor for this deferred object.
  131077. */
  131078. constructor();
  131079. }
  131080. }
  131081. declare module BABYLON {
  131082. /**
  131083. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131084. */
  131085. export class MeshExploder {
  131086. private _centerMesh;
  131087. private _meshes;
  131088. private _meshesOrigins;
  131089. private _toCenterVectors;
  131090. private _scaledDirection;
  131091. private _newPosition;
  131092. private _centerPosition;
  131093. /**
  131094. * Explodes meshes from a center mesh.
  131095. * @param meshes The meshes to explode.
  131096. * @param centerMesh The mesh to be center of explosion.
  131097. */
  131098. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131099. private _setCenterMesh;
  131100. /**
  131101. * Get class name
  131102. * @returns "MeshExploder"
  131103. */
  131104. getClassName(): string;
  131105. /**
  131106. * "Exploded meshes"
  131107. * @returns Array of meshes with the centerMesh at index 0.
  131108. */
  131109. getMeshes(): Array<Mesh>;
  131110. /**
  131111. * Explodes meshes giving a specific direction
  131112. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131113. */
  131114. explode(direction?: number): void;
  131115. }
  131116. }
  131117. declare module BABYLON {
  131118. /**
  131119. * Class used to help managing file picking and drag'n'drop
  131120. */
  131121. export class FilesInput {
  131122. /**
  131123. * List of files ready to be loaded
  131124. */
  131125. static readonly FilesToLoad: {
  131126. [key: string]: File;
  131127. };
  131128. /**
  131129. * Callback called when a file is processed
  131130. */
  131131. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131132. private _engine;
  131133. private _currentScene;
  131134. private _sceneLoadedCallback;
  131135. private _progressCallback;
  131136. private _additionalRenderLoopLogicCallback;
  131137. private _textureLoadingCallback;
  131138. private _startingProcessingFilesCallback;
  131139. private _onReloadCallback;
  131140. private _errorCallback;
  131141. private _elementToMonitor;
  131142. private _sceneFileToLoad;
  131143. private _filesToLoad;
  131144. /**
  131145. * Creates a new FilesInput
  131146. * @param engine defines the rendering engine
  131147. * @param scene defines the hosting scene
  131148. * @param sceneLoadedCallback callback called when scene is loaded
  131149. * @param progressCallback callback called to track progress
  131150. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131151. * @param textureLoadingCallback callback called when a texture is loading
  131152. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131153. * @param onReloadCallback callback called when a reload is requested
  131154. * @param errorCallback callback call if an error occurs
  131155. */
  131156. 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);
  131157. private _dragEnterHandler;
  131158. private _dragOverHandler;
  131159. private _dropHandler;
  131160. /**
  131161. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131162. * @param elementToMonitor defines the DOM element to track
  131163. */
  131164. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131165. /**
  131166. * Release all associated resources
  131167. */
  131168. dispose(): void;
  131169. private renderFunction;
  131170. private drag;
  131171. private drop;
  131172. private _traverseFolder;
  131173. private _processFiles;
  131174. /**
  131175. * Load files from a drop event
  131176. * @param event defines the drop event to use as source
  131177. */
  131178. loadFiles(event: any): void;
  131179. private _processReload;
  131180. /**
  131181. * Reload the current scene from the loaded files
  131182. */
  131183. reload(): void;
  131184. }
  131185. }
  131186. declare module BABYLON {
  131187. /**
  131188. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131190. */
  131191. export class SceneOptimization {
  131192. /**
  131193. * Defines the priority of this optimization (0 by default which means first in the list)
  131194. */
  131195. priority: number;
  131196. /**
  131197. * Gets a string describing the action executed by the current optimization
  131198. * @returns description string
  131199. */
  131200. getDescription(): string;
  131201. /**
  131202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131203. * @param scene defines the current scene where to apply this optimization
  131204. * @param optimizer defines the current optimizer
  131205. * @returns true if everything that can be done was applied
  131206. */
  131207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131208. /**
  131209. * Creates the SceneOptimization object
  131210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131211. * @param desc defines the description associated with the optimization
  131212. */
  131213. constructor(
  131214. /**
  131215. * Defines the priority of this optimization (0 by default which means first in the list)
  131216. */
  131217. priority?: number);
  131218. }
  131219. /**
  131220. * Defines an optimization used to reduce the size of render target textures
  131221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131222. */
  131223. export class TextureOptimization extends SceneOptimization {
  131224. /**
  131225. * Defines the priority of this optimization (0 by default which means first in the list)
  131226. */
  131227. priority: number;
  131228. /**
  131229. * 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
  131230. */
  131231. maximumSize: number;
  131232. /**
  131233. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131234. */
  131235. step: number;
  131236. /**
  131237. * Gets a string describing the action executed by the current optimization
  131238. * @returns description string
  131239. */
  131240. getDescription(): string;
  131241. /**
  131242. * Creates the TextureOptimization object
  131243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131244. * @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
  131245. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131246. */
  131247. constructor(
  131248. /**
  131249. * Defines the priority of this optimization (0 by default which means first in the list)
  131250. */
  131251. priority?: number,
  131252. /**
  131253. * 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
  131254. */
  131255. maximumSize?: number,
  131256. /**
  131257. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131258. */
  131259. step?: number);
  131260. /**
  131261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131262. * @param scene defines the current scene where to apply this optimization
  131263. * @param optimizer defines the current optimizer
  131264. * @returns true if everything that can be done was applied
  131265. */
  131266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131267. }
  131268. /**
  131269. * Defines an optimization used to increase or decrease the rendering resolution
  131270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131271. */
  131272. export class HardwareScalingOptimization extends SceneOptimization {
  131273. /**
  131274. * Defines the priority of this optimization (0 by default which means first in the list)
  131275. */
  131276. priority: number;
  131277. /**
  131278. * Defines the maximum scale to use (2 by default)
  131279. */
  131280. maximumScale: number;
  131281. /**
  131282. * Defines the step to use between two passes (0.5 by default)
  131283. */
  131284. step: number;
  131285. private _currentScale;
  131286. private _directionOffset;
  131287. /**
  131288. * Gets a string describing the action executed by the current optimization
  131289. * @return description string
  131290. */
  131291. getDescription(): string;
  131292. /**
  131293. * Creates the HardwareScalingOptimization object
  131294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131295. * @param maximumScale defines the maximum scale to use (2 by default)
  131296. * @param step defines the step to use between two passes (0.5 by default)
  131297. */
  131298. constructor(
  131299. /**
  131300. * Defines the priority of this optimization (0 by default which means first in the list)
  131301. */
  131302. priority?: number,
  131303. /**
  131304. * Defines the maximum scale to use (2 by default)
  131305. */
  131306. maximumScale?: number,
  131307. /**
  131308. * Defines the step to use between two passes (0.5 by default)
  131309. */
  131310. step?: number);
  131311. /**
  131312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131313. * @param scene defines the current scene where to apply this optimization
  131314. * @param optimizer defines the current optimizer
  131315. * @returns true if everything that can be done was applied
  131316. */
  131317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131318. }
  131319. /**
  131320. * Defines an optimization used to remove shadows
  131321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131322. */
  131323. export class ShadowsOptimization extends SceneOptimization {
  131324. /**
  131325. * Gets a string describing the action executed by the current optimization
  131326. * @return description string
  131327. */
  131328. getDescription(): string;
  131329. /**
  131330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131331. * @param scene defines the current scene where to apply this optimization
  131332. * @param optimizer defines the current optimizer
  131333. * @returns true if everything that can be done was applied
  131334. */
  131335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131336. }
  131337. /**
  131338. * Defines an optimization used to turn post-processes off
  131339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131340. */
  131341. export class PostProcessesOptimization extends SceneOptimization {
  131342. /**
  131343. * Gets a string describing the action executed by the current optimization
  131344. * @return description string
  131345. */
  131346. getDescription(): string;
  131347. /**
  131348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131349. * @param scene defines the current scene where to apply this optimization
  131350. * @param optimizer defines the current optimizer
  131351. * @returns true if everything that can be done was applied
  131352. */
  131353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131354. }
  131355. /**
  131356. * Defines an optimization used to turn lens flares off
  131357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131358. */
  131359. export class LensFlaresOptimization extends SceneOptimization {
  131360. /**
  131361. * Gets a string describing the action executed by the current optimization
  131362. * @return description string
  131363. */
  131364. getDescription(): string;
  131365. /**
  131366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131367. * @param scene defines the current scene where to apply this optimization
  131368. * @param optimizer defines the current optimizer
  131369. * @returns true if everything that can be done was applied
  131370. */
  131371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131372. }
  131373. /**
  131374. * Defines an optimization based on user defined callback.
  131375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131376. */
  131377. export class CustomOptimization extends SceneOptimization {
  131378. /**
  131379. * Callback called to apply the custom optimization.
  131380. */
  131381. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131382. /**
  131383. * Callback called to get custom description
  131384. */
  131385. onGetDescription: () => string;
  131386. /**
  131387. * Gets a string describing the action executed by the current optimization
  131388. * @returns description string
  131389. */
  131390. getDescription(): string;
  131391. /**
  131392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131393. * @param scene defines the current scene where to apply this optimization
  131394. * @param optimizer defines the current optimizer
  131395. * @returns true if everything that can be done was applied
  131396. */
  131397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131398. }
  131399. /**
  131400. * Defines an optimization used to turn particles off
  131401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131402. */
  131403. export class ParticlesOptimization extends SceneOptimization {
  131404. /**
  131405. * Gets a string describing the action executed by the current optimization
  131406. * @return description string
  131407. */
  131408. getDescription(): string;
  131409. /**
  131410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131411. * @param scene defines the current scene where to apply this optimization
  131412. * @param optimizer defines the current optimizer
  131413. * @returns true if everything that can be done was applied
  131414. */
  131415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131416. }
  131417. /**
  131418. * Defines an optimization used to turn render targets off
  131419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131420. */
  131421. export class RenderTargetsOptimization extends SceneOptimization {
  131422. /**
  131423. * Gets a string describing the action executed by the current optimization
  131424. * @return description string
  131425. */
  131426. getDescription(): string;
  131427. /**
  131428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131429. * @param scene defines the current scene where to apply this optimization
  131430. * @param optimizer defines the current optimizer
  131431. * @returns true if everything that can be done was applied
  131432. */
  131433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131434. }
  131435. /**
  131436. * Defines an optimization used to merge meshes with compatible materials
  131437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131438. */
  131439. export class MergeMeshesOptimization extends SceneOptimization {
  131440. private static _UpdateSelectionTree;
  131441. /**
  131442. * Gets or sets a boolean which defines if optimization octree has to be updated
  131443. */
  131444. /**
  131445. * Gets or sets a boolean which defines if optimization octree has to be updated
  131446. */
  131447. static UpdateSelectionTree: boolean;
  131448. /**
  131449. * Gets a string describing the action executed by the current optimization
  131450. * @return description string
  131451. */
  131452. getDescription(): string;
  131453. private _canBeMerged;
  131454. /**
  131455. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131456. * @param scene defines the current scene where to apply this optimization
  131457. * @param optimizer defines the current optimizer
  131458. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131459. * @returns true if everything that can be done was applied
  131460. */
  131461. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131462. }
  131463. /**
  131464. * Defines a list of options used by SceneOptimizer
  131465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131466. */
  131467. export class SceneOptimizerOptions {
  131468. /**
  131469. * Defines the target frame rate to reach (60 by default)
  131470. */
  131471. targetFrameRate: number;
  131472. /**
  131473. * Defines the interval between two checkes (2000ms by default)
  131474. */
  131475. trackerDuration: number;
  131476. /**
  131477. * Gets the list of optimizations to apply
  131478. */
  131479. optimizations: SceneOptimization[];
  131480. /**
  131481. * Creates a new list of options used by SceneOptimizer
  131482. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131483. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131484. */
  131485. constructor(
  131486. /**
  131487. * Defines the target frame rate to reach (60 by default)
  131488. */
  131489. targetFrameRate?: number,
  131490. /**
  131491. * Defines the interval between two checkes (2000ms by default)
  131492. */
  131493. trackerDuration?: number);
  131494. /**
  131495. * Add a new optimization
  131496. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131497. * @returns the current SceneOptimizerOptions
  131498. */
  131499. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131500. /**
  131501. * Add a new custom optimization
  131502. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131503. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131504. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131505. * @returns the current SceneOptimizerOptions
  131506. */
  131507. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  131508. /**
  131509. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  131510. * @param targetFrameRate defines the target frame rate (60 by default)
  131511. * @returns a SceneOptimizerOptions object
  131512. */
  131513. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131514. /**
  131515. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  131516. * @param targetFrameRate defines the target frame rate (60 by default)
  131517. * @returns a SceneOptimizerOptions object
  131518. */
  131519. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131520. /**
  131521. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  131522. * @param targetFrameRate defines the target frame rate (60 by default)
  131523. * @returns a SceneOptimizerOptions object
  131524. */
  131525. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131526. }
  131527. /**
  131528. * Class used to run optimizations in order to reach a target frame rate
  131529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131530. */
  131531. export class SceneOptimizer implements IDisposable {
  131532. private _isRunning;
  131533. private _options;
  131534. private _scene;
  131535. private _currentPriorityLevel;
  131536. private _targetFrameRate;
  131537. private _trackerDuration;
  131538. private _currentFrameRate;
  131539. private _sceneDisposeObserver;
  131540. private _improvementMode;
  131541. /**
  131542. * Defines an observable called when the optimizer reaches the target frame rate
  131543. */
  131544. onSuccessObservable: Observable<SceneOptimizer>;
  131545. /**
  131546. * Defines an observable called when the optimizer enables an optimization
  131547. */
  131548. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  131549. /**
  131550. * Defines an observable called when the optimizer is not able to reach the target frame rate
  131551. */
  131552. onFailureObservable: Observable<SceneOptimizer>;
  131553. /**
  131554. * Gets a boolean indicating if the optimizer is in improvement mode
  131555. */
  131556. readonly isInImprovementMode: boolean;
  131557. /**
  131558. * Gets the current priority level (0 at start)
  131559. */
  131560. readonly currentPriorityLevel: number;
  131561. /**
  131562. * Gets the current frame rate checked by the SceneOptimizer
  131563. */
  131564. readonly currentFrameRate: number;
  131565. /**
  131566. * Gets or sets the current target frame rate (60 by default)
  131567. */
  131568. /**
  131569. * Gets or sets the current target frame rate (60 by default)
  131570. */
  131571. targetFrameRate: number;
  131572. /**
  131573. * Gets or sets the current interval between two checks (every 2000ms by default)
  131574. */
  131575. /**
  131576. * Gets or sets the current interval between two checks (every 2000ms by default)
  131577. */
  131578. trackerDuration: number;
  131579. /**
  131580. * Gets the list of active optimizations
  131581. */
  131582. readonly optimizations: SceneOptimization[];
  131583. /**
  131584. * Creates a new SceneOptimizer
  131585. * @param scene defines the scene to work on
  131586. * @param options defines the options to use with the SceneOptimizer
  131587. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  131588. * @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)
  131589. */
  131590. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  131591. /**
  131592. * Stops the current optimizer
  131593. */
  131594. stop(): void;
  131595. /**
  131596. * Reset the optimizer to initial step (current priority level = 0)
  131597. */
  131598. reset(): void;
  131599. /**
  131600. * Start the optimizer. By default it will try to reach a specific framerate
  131601. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  131602. */
  131603. start(): void;
  131604. private _checkCurrentState;
  131605. /**
  131606. * Release all resources
  131607. */
  131608. dispose(): void;
  131609. /**
  131610. * Helper function to create a SceneOptimizer with one single line of code
  131611. * @param scene defines the scene to work on
  131612. * @param options defines the options to use with the SceneOptimizer
  131613. * @param onSuccess defines a callback to call on success
  131614. * @param onFailure defines a callback to call on failure
  131615. * @returns the new SceneOptimizer object
  131616. */
  131617. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  131618. }
  131619. }
  131620. declare module BABYLON {
  131621. /**
  131622. * Class used to serialize a scene into a string
  131623. */
  131624. export class SceneSerializer {
  131625. /**
  131626. * Clear cache used by a previous serialization
  131627. */
  131628. static ClearCache(): void;
  131629. /**
  131630. * Serialize a scene into a JSON compatible object
  131631. * @param scene defines the scene to serialize
  131632. * @returns a JSON compatible object
  131633. */
  131634. static Serialize(scene: Scene): any;
  131635. /**
  131636. * Serialize a mesh into a JSON compatible object
  131637. * @param toSerialize defines the mesh to serialize
  131638. * @param withParents defines if parents must be serialized as well
  131639. * @param withChildren defines if children must be serialized as well
  131640. * @returns a JSON compatible object
  131641. */
  131642. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  131643. }
  131644. }
  131645. declare module BABYLON {
  131646. /**
  131647. * Class used to host texture specific utilities
  131648. */
  131649. export class TextureTools {
  131650. /**
  131651. * Uses the GPU to create a copy texture rescaled at a given size
  131652. * @param texture Texture to copy from
  131653. * @param width defines the desired width
  131654. * @param height defines the desired height
  131655. * @param useBilinearMode defines if bilinear mode has to be used
  131656. * @return the generated texture
  131657. */
  131658. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131659. }
  131660. }
  131661. declare module BABYLON {
  131662. /**
  131663. * This represents the different options available for the video capture.
  131664. */
  131665. export interface VideoRecorderOptions {
  131666. /** Defines the mime type of the video. */
  131667. mimeType: string;
  131668. /** Defines the FPS the video should be recorded at. */
  131669. fps: number;
  131670. /** Defines the chunk size for the recording data. */
  131671. recordChunckSize: number;
  131672. /** The audio tracks to attach to the recording. */
  131673. audioTracks?: MediaStreamTrack[];
  131674. }
  131675. /**
  131676. * This can help with recording videos from BabylonJS.
  131677. * This is based on the available WebRTC functionalities of the browser.
  131678. *
  131679. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131680. */
  131681. export class VideoRecorder {
  131682. private static readonly _defaultOptions;
  131683. /**
  131684. * Returns whether or not the VideoRecorder is available in your browser.
  131685. * @param engine Defines the Babylon Engine.
  131686. * @returns true if supported otherwise false.
  131687. */
  131688. static IsSupported(engine: Engine): boolean;
  131689. private readonly _options;
  131690. private _canvas;
  131691. private _mediaRecorder;
  131692. private _recordedChunks;
  131693. private _fileName;
  131694. private _resolve;
  131695. private _reject;
  131696. /**
  131697. * True when a recording is already in progress.
  131698. */
  131699. readonly isRecording: boolean;
  131700. /**
  131701. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131702. * @param engine Defines the BabylonJS Engine you wish to record.
  131703. * @param options Defines options that can be used to customize the capture.
  131704. */
  131705. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131706. /**
  131707. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131708. */
  131709. stopRecording(): void;
  131710. /**
  131711. * Starts recording the canvas for a max duration specified in parameters.
  131712. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131713. * If null no automatic download will start and you can rely on the promise to get the data back.
  131714. * @param maxDuration Defines the maximum recording time in seconds.
  131715. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131716. * @return A promise callback at the end of the recording with the video data in Blob.
  131717. */
  131718. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131719. /**
  131720. * Releases internal resources used during the recording.
  131721. */
  131722. dispose(): void;
  131723. private _handleDataAvailable;
  131724. private _handleError;
  131725. private _handleStop;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /**
  131730. * Class containing a set of static utilities functions for screenshots
  131731. */
  131732. export class ScreenshotTools {
  131733. /**
  131734. * Captures a screenshot of the current rendering
  131735. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131736. * @param engine defines the rendering engine
  131737. * @param camera defines the source camera
  131738. * @param size This parameter can be set to a single number or to an object with the
  131739. * following (optional) properties: precision, width, height. If a single number is passed,
  131740. * it will be used for both width and height. If an object is passed, the screenshot size
  131741. * will be derived from the parameters. The precision property is a multiplier allowing
  131742. * rendering at a higher or lower resolution
  131743. * @param successCallback defines the callback receives a single parameter which contains the
  131744. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131745. * src parameter of an <img> to display it
  131746. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131747. * Check your browser for supported MIME types
  131748. */
  131749. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131750. /**
  131751. * Captures a screenshot of the current rendering
  131752. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131753. * @param engine defines the rendering engine
  131754. * @param camera defines the source camera
  131755. * @param size This parameter can be set to a single number or to an object with the
  131756. * following (optional) properties: precision, width, height. If a single number is passed,
  131757. * it will be used for both width and height. If an object is passed, the screenshot size
  131758. * will be derived from the parameters. The precision property is a multiplier allowing
  131759. * rendering at a higher or lower resolution
  131760. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131761. * Check your browser for supported MIME types
  131762. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131763. * to the src parameter of an <img> to display it
  131764. */
  131765. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131766. /**
  131767. * Generates an image screenshot from the specified camera.
  131768. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131769. * @param engine The engine to use for rendering
  131770. * @param camera The camera to use for rendering
  131771. * @param size This parameter can be set to a single number or to an object with the
  131772. * following (optional) properties: precision, width, height. If a single number is passed,
  131773. * it will be used for both width and height. If an object is passed, the screenshot size
  131774. * will be derived from the parameters. The precision property is a multiplier allowing
  131775. * rendering at a higher or lower resolution
  131776. * @param successCallback The callback receives a single parameter which contains the
  131777. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131778. * src parameter of an <img> to display it
  131779. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131780. * Check your browser for supported MIME types
  131781. * @param samples Texture samples (default: 1)
  131782. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131783. * @param fileName A name for for the downloaded file.
  131784. */
  131785. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131786. /**
  131787. * Generates an image screenshot from the specified camera.
  131788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131789. * @param engine The engine to use for rendering
  131790. * @param camera The camera to use for rendering
  131791. * @param size This parameter can be set to a single number or to an object with the
  131792. * following (optional) properties: precision, width, height. If a single number is passed,
  131793. * it will be used for both width and height. If an object is passed, the screenshot size
  131794. * will be derived from the parameters. The precision property is a multiplier allowing
  131795. * rendering at a higher or lower resolution
  131796. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131797. * Check your browser for supported MIME types
  131798. * @param samples Texture samples (default: 1)
  131799. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131800. * @param fileName A name for for the downloaded file.
  131801. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131802. * to the src parameter of an <img> to display it
  131803. */
  131804. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131805. /**
  131806. * Gets height and width for screenshot size
  131807. * @private
  131808. */
  131809. private static _getScreenshotSize;
  131810. }
  131811. }
  131812. declare module BABYLON {
  131813. /**
  131814. * Interface for a data buffer
  131815. */
  131816. export interface IDataBuffer {
  131817. /**
  131818. * Reads bytes from the data buffer.
  131819. * @param byteOffset The byte offset to read
  131820. * @param byteLength The byte length to read
  131821. * @returns A promise that resolves when the bytes are read
  131822. */
  131823. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  131824. /**
  131825. * The byte length of the buffer.
  131826. */
  131827. readonly byteLength: number;
  131828. }
  131829. /**
  131830. * Utility class for reading from a data buffer
  131831. */
  131832. export class DataReader {
  131833. /**
  131834. * The data buffer associated with this data reader.
  131835. */
  131836. readonly buffer: IDataBuffer;
  131837. /**
  131838. * The current byte offset from the beginning of the data buffer.
  131839. */
  131840. byteOffset: number;
  131841. private _dataView;
  131842. private _dataByteOffset;
  131843. /**
  131844. * Constructor
  131845. * @param buffer The buffer to read
  131846. */
  131847. constructor(buffer: IDataBuffer);
  131848. /**
  131849. * Loads the given byte length.
  131850. * @param byteLength The byte length to load
  131851. * @returns A promise that resolves when the load is complete
  131852. */
  131853. loadAsync(byteLength: number): Promise<void>;
  131854. /**
  131855. * Read a unsigned 32-bit integer from the currently loaded data range.
  131856. * @returns The 32-bit integer read
  131857. */
  131858. readUint32(): number;
  131859. /**
  131860. * Read a byte array from the currently loaded data range.
  131861. * @param byteLength The byte length to read
  131862. * @returns The byte array read
  131863. */
  131864. readUint8Array(byteLength: number): Uint8Array;
  131865. /**
  131866. * Read a string from the currently loaded data range.
  131867. * @param byteLength The byte length to read
  131868. * @returns The string read
  131869. */
  131870. readString(byteLength: number): string;
  131871. /**
  131872. * Skips the given byte length the currently loaded data range.
  131873. * @param byteLength The byte length to skip
  131874. */
  131875. skipBytes(byteLength: number): void;
  131876. }
  131877. }
  131878. declare module BABYLON {
  131879. /**
  131880. * A cursor which tracks a point on a path
  131881. */
  131882. export class PathCursor {
  131883. private path;
  131884. /**
  131885. * Stores path cursor callbacks for when an onchange event is triggered
  131886. */
  131887. private _onchange;
  131888. /**
  131889. * The value of the path cursor
  131890. */
  131891. value: number;
  131892. /**
  131893. * The animation array of the path cursor
  131894. */
  131895. animations: Animation[];
  131896. /**
  131897. * Initializes the path cursor
  131898. * @param path The path to track
  131899. */
  131900. constructor(path: Path2);
  131901. /**
  131902. * Gets the cursor point on the path
  131903. * @returns A point on the path cursor at the cursor location
  131904. */
  131905. getPoint(): Vector3;
  131906. /**
  131907. * Moves the cursor ahead by the step amount
  131908. * @param step The amount to move the cursor forward
  131909. * @returns This path cursor
  131910. */
  131911. moveAhead(step?: number): PathCursor;
  131912. /**
  131913. * Moves the cursor behind by the step amount
  131914. * @param step The amount to move the cursor back
  131915. * @returns This path cursor
  131916. */
  131917. moveBack(step?: number): PathCursor;
  131918. /**
  131919. * Moves the cursor by the step amount
  131920. * If the step amount is greater than one, an exception is thrown
  131921. * @param step The amount to move the cursor
  131922. * @returns This path cursor
  131923. */
  131924. move(step: number): PathCursor;
  131925. /**
  131926. * Ensures that the value is limited between zero and one
  131927. * @returns This path cursor
  131928. */
  131929. private ensureLimits;
  131930. /**
  131931. * Runs onchange callbacks on change (used by the animation engine)
  131932. * @returns This path cursor
  131933. */
  131934. private raiseOnChange;
  131935. /**
  131936. * Executes a function on change
  131937. * @param f A path cursor onchange callback
  131938. * @returns This path cursor
  131939. */
  131940. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131941. }
  131942. }
  131943. declare module BABYLON {
  131944. /** @hidden */
  131945. export var blurPixelShader: {
  131946. name: string;
  131947. shader: string;
  131948. };
  131949. }
  131950. declare module BABYLON {
  131951. /** @hidden */
  131952. export var pointCloudVertexDeclaration: {
  131953. name: string;
  131954. shader: string;
  131955. };
  131956. }
  131957. // Mixins
  131958. interface Window {
  131959. mozIndexedDB: IDBFactory;
  131960. webkitIndexedDB: IDBFactory;
  131961. msIndexedDB: IDBFactory;
  131962. webkitURL: typeof URL;
  131963. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131964. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131965. WebGLRenderingContext: WebGLRenderingContext;
  131966. MSGesture: MSGesture;
  131967. CANNON: any;
  131968. AudioContext: AudioContext;
  131969. webkitAudioContext: AudioContext;
  131970. PointerEvent: any;
  131971. Math: Math;
  131972. Uint8Array: Uint8ArrayConstructor;
  131973. Float32Array: Float32ArrayConstructor;
  131974. mozURL: typeof URL;
  131975. msURL: typeof URL;
  131976. VRFrameData: any; // WebVR, from specs 1.1
  131977. DracoDecoderModule: any;
  131978. setImmediate(handler: (...args: any[]) => void): number;
  131979. }
  131980. interface HTMLCanvasElement {
  131981. requestPointerLock(): void;
  131982. msRequestPointerLock?(): void;
  131983. mozRequestPointerLock?(): void;
  131984. webkitRequestPointerLock?(): void;
  131985. /** Track wether a record is in progress */
  131986. isRecording: boolean;
  131987. /** Capture Stream method defined by some browsers */
  131988. captureStream(fps?: number): MediaStream;
  131989. }
  131990. interface CanvasRenderingContext2D {
  131991. msImageSmoothingEnabled: boolean;
  131992. }
  131993. interface MouseEvent {
  131994. mozMovementX: number;
  131995. mozMovementY: number;
  131996. webkitMovementX: number;
  131997. webkitMovementY: number;
  131998. msMovementX: number;
  131999. msMovementY: number;
  132000. }
  132001. interface Navigator {
  132002. mozGetVRDevices: (any: any) => any;
  132003. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132004. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132005. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132006. webkitGetGamepads(): Gamepad[];
  132007. msGetGamepads(): Gamepad[];
  132008. webkitGamepads(): Gamepad[];
  132009. }
  132010. interface HTMLVideoElement {
  132011. mozSrcObject: any;
  132012. }
  132013. interface Math {
  132014. fround(x: number): number;
  132015. imul(a: number, b: number): number;
  132016. }
  132017. interface WebGLRenderingContext {
  132018. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132019. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132020. vertexAttribDivisor(index: number, divisor: number): void;
  132021. createVertexArray(): any;
  132022. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132023. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132024. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132025. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132026. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132027. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132028. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132029. // Queries
  132030. createQuery(): WebGLQuery;
  132031. deleteQuery(query: WebGLQuery): void;
  132032. beginQuery(target: number, query: WebGLQuery): void;
  132033. endQuery(target: number): void;
  132034. getQueryParameter(query: WebGLQuery, pname: number): any;
  132035. getQuery(target: number, pname: number): any;
  132036. MAX_SAMPLES: number;
  132037. RGBA8: number;
  132038. READ_FRAMEBUFFER: number;
  132039. DRAW_FRAMEBUFFER: number;
  132040. UNIFORM_BUFFER: number;
  132041. HALF_FLOAT_OES: number;
  132042. RGBA16F: number;
  132043. RGBA32F: number;
  132044. R32F: number;
  132045. RG32F: number;
  132046. RGB32F: number;
  132047. R16F: number;
  132048. RG16F: number;
  132049. RGB16F: number;
  132050. RED: number;
  132051. RG: number;
  132052. R8: number;
  132053. RG8: number;
  132054. UNSIGNED_INT_24_8: number;
  132055. DEPTH24_STENCIL8: number;
  132056. MIN: number;
  132057. MAX: number;
  132058. /* Multiple Render Targets */
  132059. drawBuffers(buffers: number[]): void;
  132060. readBuffer(src: number): void;
  132061. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132062. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132063. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132064. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132065. // Occlusion Query
  132066. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132067. ANY_SAMPLES_PASSED: number;
  132068. QUERY_RESULT_AVAILABLE: number;
  132069. QUERY_RESULT: number;
  132070. }
  132071. interface WebGLProgram {
  132072. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132073. }
  132074. interface EXT_disjoint_timer_query {
  132075. QUERY_COUNTER_BITS_EXT: number;
  132076. TIME_ELAPSED_EXT: number;
  132077. TIMESTAMP_EXT: number;
  132078. GPU_DISJOINT_EXT: number;
  132079. QUERY_RESULT_EXT: number;
  132080. QUERY_RESULT_AVAILABLE_EXT: number;
  132081. queryCounterEXT(query: WebGLQuery, target: number): void;
  132082. createQueryEXT(): WebGLQuery;
  132083. beginQueryEXT(target: number, query: WebGLQuery): void;
  132084. endQueryEXT(target: number): void;
  132085. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132086. deleteQueryEXT(query: WebGLQuery): void;
  132087. }
  132088. interface WebGLUniformLocation {
  132089. _currentState: any;
  132090. }
  132091. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132092. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132093. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132094. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132095. interface WebGLRenderingContext {
  132096. readonly RASTERIZER_DISCARD: number;
  132097. readonly DEPTH_COMPONENT24: number;
  132098. readonly TEXTURE_3D: number;
  132099. readonly TEXTURE_2D_ARRAY: number;
  132100. readonly TEXTURE_COMPARE_FUNC: number;
  132101. readonly TEXTURE_COMPARE_MODE: number;
  132102. readonly COMPARE_REF_TO_TEXTURE: number;
  132103. readonly TEXTURE_WRAP_R: number;
  132104. readonly HALF_FLOAT: number;
  132105. readonly RGB8: number;
  132106. readonly RED_INTEGER: number;
  132107. readonly RG_INTEGER: number;
  132108. readonly RGB_INTEGER: number;
  132109. readonly RGBA_INTEGER: number;
  132110. readonly R8_SNORM: number;
  132111. readonly RG8_SNORM: number;
  132112. readonly RGB8_SNORM: number;
  132113. readonly RGBA8_SNORM: number;
  132114. readonly R8I: number;
  132115. readonly RG8I: number;
  132116. readonly RGB8I: number;
  132117. readonly RGBA8I: number;
  132118. readonly R8UI: number;
  132119. readonly RG8UI: number;
  132120. readonly RGB8UI: number;
  132121. readonly RGBA8UI: number;
  132122. readonly R16I: number;
  132123. readonly RG16I: number;
  132124. readonly RGB16I: number;
  132125. readonly RGBA16I: number;
  132126. readonly R16UI: number;
  132127. readonly RG16UI: number;
  132128. readonly RGB16UI: number;
  132129. readonly RGBA16UI: number;
  132130. readonly R32I: number;
  132131. readonly RG32I: number;
  132132. readonly RGB32I: number;
  132133. readonly RGBA32I: number;
  132134. readonly R32UI: number;
  132135. readonly RG32UI: number;
  132136. readonly RGB32UI: number;
  132137. readonly RGBA32UI: number;
  132138. readonly RGB10_A2UI: number;
  132139. readonly R11F_G11F_B10F: number;
  132140. readonly RGB9_E5: number;
  132141. readonly RGB10_A2: number;
  132142. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132143. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132144. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132145. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132146. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132147. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132148. 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;
  132149. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132150. readonly TRANSFORM_FEEDBACK: number;
  132151. readonly INTERLEAVED_ATTRIBS: number;
  132152. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132153. createTransformFeedback(): WebGLTransformFeedback;
  132154. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132155. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132156. beginTransformFeedback(primitiveMode: number): void;
  132157. endTransformFeedback(): void;
  132158. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132159. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132160. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132161. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132162. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132163. }
  132164. interface ImageBitmap {
  132165. readonly width: number;
  132166. readonly height: number;
  132167. close(): void;
  132168. }
  132169. interface WebGLQuery extends WebGLObject {
  132170. }
  132171. declare var WebGLQuery: {
  132172. prototype: WebGLQuery;
  132173. new(): WebGLQuery;
  132174. };
  132175. interface WebGLSampler extends WebGLObject {
  132176. }
  132177. declare var WebGLSampler: {
  132178. prototype: WebGLSampler;
  132179. new(): WebGLSampler;
  132180. };
  132181. interface WebGLSync extends WebGLObject {
  132182. }
  132183. declare var WebGLSync: {
  132184. prototype: WebGLSync;
  132185. new(): WebGLSync;
  132186. };
  132187. interface WebGLTransformFeedback extends WebGLObject {
  132188. }
  132189. declare var WebGLTransformFeedback: {
  132190. prototype: WebGLTransformFeedback;
  132191. new(): WebGLTransformFeedback;
  132192. };
  132193. interface WebGLVertexArrayObject extends WebGLObject {
  132194. }
  132195. declare var WebGLVertexArrayObject: {
  132196. prototype: WebGLVertexArrayObject;
  132197. new(): WebGLVertexArrayObject;
  132198. };
  132199. // Type definitions for WebVR API
  132200. // Project: https://w3c.github.io/webvr/
  132201. // Definitions by: six a <https://github.com/lostfictions>
  132202. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132203. interface VRDisplay extends EventTarget {
  132204. /**
  132205. * Dictionary of capabilities describing the VRDisplay.
  132206. */
  132207. readonly capabilities: VRDisplayCapabilities;
  132208. /**
  132209. * z-depth defining the far plane of the eye view frustum
  132210. * enables mapping of values in the render target depth
  132211. * attachment to scene coordinates. Initially set to 10000.0.
  132212. */
  132213. depthFar: number;
  132214. /**
  132215. * z-depth defining the near plane of the eye view frustum
  132216. * enables mapping of values in the render target depth
  132217. * attachment to scene coordinates. Initially set to 0.01.
  132218. */
  132219. depthNear: number;
  132220. /**
  132221. * An identifier for this distinct VRDisplay. Used as an
  132222. * association point in the Gamepad API.
  132223. */
  132224. readonly displayId: number;
  132225. /**
  132226. * A display name, a user-readable name identifying it.
  132227. */
  132228. readonly displayName: string;
  132229. readonly isConnected: boolean;
  132230. readonly isPresenting: boolean;
  132231. /**
  132232. * If this VRDisplay supports room-scale experiences, the optional
  132233. * stage attribute contains details on the room-scale parameters.
  132234. */
  132235. readonly stageParameters: VRStageParameters | null;
  132236. /**
  132237. * Passing the value returned by `requestAnimationFrame` to
  132238. * `cancelAnimationFrame` will unregister the callback.
  132239. * @param handle Define the hanle of the request to cancel
  132240. */
  132241. cancelAnimationFrame(handle: number): void;
  132242. /**
  132243. * Stops presenting to the VRDisplay.
  132244. * @returns a promise to know when it stopped
  132245. */
  132246. exitPresent(): Promise<void>;
  132247. /**
  132248. * Return the current VREyeParameters for the given eye.
  132249. * @param whichEye Define the eye we want the parameter for
  132250. * @returns the eye parameters
  132251. */
  132252. getEyeParameters(whichEye: string): VREyeParameters;
  132253. /**
  132254. * Populates the passed VRFrameData with the information required to render
  132255. * the current frame.
  132256. * @param frameData Define the data structure to populate
  132257. * @returns true if ok otherwise false
  132258. */
  132259. getFrameData(frameData: VRFrameData): boolean;
  132260. /**
  132261. * Get the layers currently being presented.
  132262. * @returns the list of VR layers
  132263. */
  132264. getLayers(): VRLayer[];
  132265. /**
  132266. * Return a VRPose containing the future predicted pose of the VRDisplay
  132267. * when the current frame will be presented. The value returned will not
  132268. * change until JavaScript has returned control to the browser.
  132269. *
  132270. * The VRPose will contain the position, orientation, velocity,
  132271. * and acceleration of each of these properties.
  132272. * @returns the pose object
  132273. */
  132274. getPose(): VRPose;
  132275. /**
  132276. * Return the current instantaneous pose of the VRDisplay, with no
  132277. * prediction applied.
  132278. * @returns the current instantaneous pose
  132279. */
  132280. getImmediatePose(): VRPose;
  132281. /**
  132282. * The callback passed to `requestAnimationFrame` will be called
  132283. * any time a new frame should be rendered. When the VRDisplay is
  132284. * presenting the callback will be called at the native refresh
  132285. * rate of the HMD. When not presenting this function acts
  132286. * identically to how window.requestAnimationFrame acts. Content should
  132287. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132288. * asynchronously from other displays and at differing refresh rates.
  132289. * @param callback Define the eaction to run next frame
  132290. * @returns the request handle it
  132291. */
  132292. requestAnimationFrame(callback: FrameRequestCallback): number;
  132293. /**
  132294. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132295. * Repeat calls while already presenting will update the VRLayers being displayed.
  132296. * @param layers Define the list of layer to present
  132297. * @returns a promise to know when the request has been fulfilled
  132298. */
  132299. requestPresent(layers: VRLayer[]): Promise<void>;
  132300. /**
  132301. * Reset the pose for this display, treating its current position and
  132302. * orientation as the "origin/zero" values. VRPose.position,
  132303. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132304. * updated when calling resetPose(). This should be called in only
  132305. * sitting-space experiences.
  132306. */
  132307. resetPose(): void;
  132308. /**
  132309. * The VRLayer provided to the VRDisplay will be captured and presented
  132310. * in the HMD. Calling this function has the same effect on the source
  132311. * canvas as any other operation that uses its source image, and canvases
  132312. * created without preserveDrawingBuffer set to true will be cleared.
  132313. * @param pose Define the pose to submit
  132314. */
  132315. submitFrame(pose?: VRPose): void;
  132316. }
  132317. declare var VRDisplay: {
  132318. prototype: VRDisplay;
  132319. new(): VRDisplay;
  132320. };
  132321. interface VRLayer {
  132322. leftBounds?: number[] | Float32Array | null;
  132323. rightBounds?: number[] | Float32Array | null;
  132324. source?: HTMLCanvasElement | null;
  132325. }
  132326. interface VRDisplayCapabilities {
  132327. readonly canPresent: boolean;
  132328. readonly hasExternalDisplay: boolean;
  132329. readonly hasOrientation: boolean;
  132330. readonly hasPosition: boolean;
  132331. readonly maxLayers: number;
  132332. }
  132333. interface VREyeParameters {
  132334. /** @deprecated */
  132335. readonly fieldOfView: VRFieldOfView;
  132336. readonly offset: Float32Array;
  132337. readonly renderHeight: number;
  132338. readonly renderWidth: number;
  132339. }
  132340. interface VRFieldOfView {
  132341. readonly downDegrees: number;
  132342. readonly leftDegrees: number;
  132343. readonly rightDegrees: number;
  132344. readonly upDegrees: number;
  132345. }
  132346. interface VRFrameData {
  132347. readonly leftProjectionMatrix: Float32Array;
  132348. readonly leftViewMatrix: Float32Array;
  132349. readonly pose: VRPose;
  132350. readonly rightProjectionMatrix: Float32Array;
  132351. readonly rightViewMatrix: Float32Array;
  132352. readonly timestamp: number;
  132353. }
  132354. interface VRPose {
  132355. readonly angularAcceleration: Float32Array | null;
  132356. readonly angularVelocity: Float32Array | null;
  132357. readonly linearAcceleration: Float32Array | null;
  132358. readonly linearVelocity: Float32Array | null;
  132359. readonly orientation: Float32Array | null;
  132360. readonly position: Float32Array | null;
  132361. readonly timestamp: number;
  132362. }
  132363. interface VRStageParameters {
  132364. sittingToStandingTransform?: Float32Array;
  132365. sizeX?: number;
  132366. sizeY?: number;
  132367. }
  132368. interface Navigator {
  132369. getVRDisplays(): Promise<VRDisplay[]>;
  132370. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132371. }
  132372. interface Window {
  132373. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132374. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132375. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132376. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132377. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132378. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132379. }
  132380. interface Gamepad {
  132381. readonly displayId: number;
  132382. }
  132383. type XRSessionMode =
  132384. | "inline"
  132385. | "immersive-vr"
  132386. | "immersive-ar";
  132387. type XRReferenceSpaceType =
  132388. | "viewer"
  132389. | "local"
  132390. | "local-floor"
  132391. | "bounded-floor"
  132392. | "unbounded";
  132393. type XREnvironmentBlendMode =
  132394. | "opaque"
  132395. | "additive"
  132396. | "alpha-blend";
  132397. type XRVisibilityState =
  132398. | "visible"
  132399. | "visible-blurred"
  132400. | "hidden";
  132401. type XRHandedness =
  132402. | "none"
  132403. | "left"
  132404. | "right";
  132405. type XRTargetRayMode =
  132406. | "gaze"
  132407. | "tracked-pointer"
  132408. | "screen";
  132409. type XREye =
  132410. | "none"
  132411. | "left"
  132412. | "right";
  132413. interface XRSpace extends EventTarget {
  132414. }
  132415. interface XRRenderState {
  132416. depthNear?: number;
  132417. depthFar?: number;
  132418. inlineVerticalFieldOfView?: number;
  132419. baseLayer?: XRWebGLLayer;
  132420. }
  132421. interface XRInputSource {
  132422. handedness: XRHandedness;
  132423. targetRayMode: XRTargetRayMode;
  132424. targetRaySpace: XRSpace;
  132425. gripSpace: XRSpace | undefined;
  132426. gamepad: Gamepad | undefined;
  132427. profiles: Array<string>;
  132428. }
  132429. interface XRSession {
  132430. addEventListener: Function;
  132431. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132432. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132433. requestAnimationFrame: Function;
  132434. end(): Promise<void>;
  132435. renderState: XRRenderState;
  132436. inputSources: Array<XRInputSource>;
  132437. }
  132438. interface XRReferenceSpace extends XRSpace {
  132439. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132440. onreset: any;
  132441. }
  132442. interface XRFrame {
  132443. session: XRSession;
  132444. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132445. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132446. }
  132447. interface XRViewerPose extends XRPose {
  132448. views: Array<XRView>;
  132449. }
  132450. interface XRPose {
  132451. transform: XRRigidTransform;
  132452. emulatedPosition: boolean;
  132453. }
  132454. declare var XRWebGLLayer: {
  132455. prototype: XRWebGLLayer;
  132456. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132457. };
  132458. interface XRWebGLLayer {
  132459. framebuffer: WebGLFramebuffer;
  132460. framebufferWidth: number;
  132461. framebufferHeight: number;
  132462. getViewport: Function;
  132463. }
  132464. interface XRRigidTransform {
  132465. position: DOMPointReadOnly;
  132466. orientation: DOMPointReadOnly;
  132467. matrix: Float32Array;
  132468. inverse: XRRigidTransform;
  132469. }
  132470. interface XRView {
  132471. eye: XREye;
  132472. projectionMatrix: Float32Array;
  132473. transform: XRRigidTransform;
  132474. }
  132475. interface XRInputSourceChangeEvent {
  132476. session: XRSession;
  132477. removed: Array<XRInputSource>;
  132478. added: Array<XRInputSource>;
  132479. }